/**
 * NFP Minicart Widget Styles
 *
 * @package NFP_Product_Page
 * @since 1.0.0
 */

/* Container */
.nfp-minicart-container {
    position: relative;
    display: inline-block;
    z-index: 1; /* Default value when closed */
}

/* Toggle Button */
.nfp-minicart-toggle {
    display: flex;
    align-items: center;
    cursor: pointer;
    user-select: none;
}

.nfp-minicart-icon {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.nfp-icon-wrapper {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 24px; /* Default size, will be overridden by Elementor */
}

/* Support for all icon types */
.nfp-minicart-icon i {
    font-size: inherit;
}

.nfp-minicart-icon .nfp-cart-icon-svg {
    width: 1em;
    height: 1em;
    vertical-align: middle;
}

/* Badge positioning */
.nfp-cart-count {
    position: absolute;
    top: -8px;
    right: -8px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 19px;
    height: 19px;
    line-height: 19px;
    border-radius: 50% 50% 50% 50%;
    background-color: #C50F0F; /* Using brand-500 color from theme */
    color: #ffffff;
    font-size: 12px;
    font-weight: 700;
    text-align: center;
    z-index: 1; /* Ensure the badge is above the icon */
    transition: all 0.3s ease;
}

/* Add elementor customizable version to match wishlist style */
.elementor-widget-nfp_minicart .nfp-cart-count {
    color: #ffffff;
    background-color: var( --e-global-color-text );
    width: 19px;
    height: 19px;
    line-height: 19px;
    border-radius: 50% 50% 50% 50%;
}

.nfp-minicart-subtotal {
    margin-left: 8px;
    font-size: 14px;
    font-weight: 500;
}

/* Dropdown Content */
.nfp-minicart-content {
    display: none;
    position: absolute;
    right: 0;
    top: 100%;
    width: 320px;
    padding: 16px;
    background-color: #ffffff;
    border: 1px solid #e5e5e5;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 9999; /* High, but below WordPress admin bar (99999) */
}

/* For flexbox layout in offcanvas and modal */
.nfp-display-offcanvas .nfp-minicart-content,
.nfp-display-modal .nfp-minicart-content {
    display: flex;
    flex-direction: column;
}

/* Only show dropdown on hover if it has the hover-enabled class */
.nfp-minicart-container.nfp-hover-enabled:hover .nfp-minicart-content {
    display: block;
}

/* When the cart is opened via JS, show it */
.nfp-minicart-container.nfp-cart-open .nfp-minicart-content {
    display: block;
}

/* Offcanvas and modal when open should use flexbox */
.nfp-display-offcanvas.nfp-cart-open .nfp-minicart-content,
.nfp-display-modal.nfp-cart-open .nfp-minicart-content {
    display: flex !important;
    flex-direction: column;
}

/* Overlay for modal and offcanvas */
.nfp-minicart-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 9000; /* Much lower than content */
    display: none;
    pointer-events: none; /* Initially doesn't intercept clicks */
}

.nfp-minicart-overlay.nfp-overlay-active {
    display: block;
    pointer-events: auto; /* Now intercepts clicks when active */
}

/* Make sure the minicart container has appropriate z-index when open */
.nfp-minicart-container.nfp-cart-open {
    z-index: 99990; /* High, but below WordPress admin bar (99999) */
}

/* Body class to prevent scrolling when cart is open */
body.nfp-cart-open-body {
    overflow: hidden;
}

/* Header */
.nfp-minicart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 1px solid #e5e5e5;
    flex-shrink: 0; /* Don't allow header to shrink */
}

.nfp-minicart-title {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.nfp-minicart-close {
    background: #C50F0F;
    color: #fff;
    border: none;
    font-size: 24px;
    line-height: 12px;
    cursor: pointer;
    padding: 6px;
}
/* Body */
.nfp-minicart-body {
    max-height: 80%;
    overflow-y: auto;
    margin-bottom: 16px;
    flex: 1 1 auto; /* Allow this to grow and shrink */
}

.nfp-minicart-empty {
    text-align: center;
    padding: 16px 0;
}

.nfp-empty-cart-actions {
    margin-top: 16px;
    display: flex;
    justify-content: center;
}

/* Shop Now button */
.nfp-shop-now {
    display: inline-block;
    padding: 10px 20px;
    background-color: #C50F0F; /* Using brand-500 color from theme */
    color: #ffffff;
    text-decoration: none;
    text-align: center;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s ease;
}

.nfp-shop-now:hover {
    background-color: #940909; /* Using brand-700 color from theme */
    color: #ffffff;
    text-decoration: none;
}

/* Footer */
.nfp-minicart-footer {
    margin-top: auto;
    padding-top: 15px;
    border-top: 1px solid #e5e5e5;
    flex-shrink: 0;
    padding-bottom: env(safe-area-inset-bottom, 0px); /* Safe area for iOS/Android */
}

.nfp-minicart-total {
    display: flex;
    justify-content: space-between;
    font-weight: 600;
    margin-bottom: 15px;
    font-size: 16px;
}

.nfp-minicart-total-label {
    color: #333;
}

.nfp-minicart-total-price {
    text-align: right;
}

/* Footer buttons */
.nfp-minicart-footer-buttons {
    display: flex;
    gap: 10px;
}

.nfp-minicart-view-cart-button, 
.nfp-minicart-checkout-button {
    flex: 1;
    padding: 12px 15px;
    text-align: center;
    font-weight: 600;
    font-size: 14px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.nfp-minicart-view-cart-button {
    /* background-color: #f0f0f0;
    color: #333; */
}

.nfp-minicart-view-cart-button:hover {
    /* background-color: #e5e5e5; */
    text-decoration: none!important;
}

.nfp-minicart-checkout-button {
    /* background-color: #333; */
    /* color: #fff; */
}

.nfp-minicart-checkout-button:hover {
    /* background-color: #444; */
    text-decoration: none!important;
}

/* Responsive styles */
@media (max-width: 767px) {
    .nfp-minicart-content {
        width: 280px;
    }
    
    .nfp-minicart-buttons {
        flex-direction: column;
    }
    
    /* Handle admin bar in mobile */
    .admin-bar .nfp-display-offcanvas .nfp-minicart-content {
        top: 46px;
        height: calc(100vh - 46px);
    }
}

/* Handle admin bar in desktop */
.admin-bar .nfp-display-offcanvas .nfp-minicart-content {
    top: 32px;
    height: calc(100vh - 32px);
}

/* Display types - fully implemented */

/* Offcanvas */
.nfp-display-offcanvas .nfp-minicart-content {
    position: fixed;
    top: 0; /* Default, will be overridden by JS for admin bar or safe area */
    right: -100%;
    height: 100dvh; /* Use dynamic viewport height for mobile */
    width: 45vw;
    max-width: 600px;
    padding: 16px;
    margin: 0;
    border-radius: 0;
    box-shadow: -2px 0 10px rgba(0, 0, 0, 0.1);
    overflow-y: auto;
    transition: right 0.3s ease;
    z-index: 99990;
    /* Safe area for iOS */
    padding-top: env(safe-area-inset-top, 0px);
}

.nfp-display-offcanvas.nfp-cart-open .nfp-minicart-content {
    right: 0; /* Slide in */
}

/* Responsive widths for different device sizes */
/* Tablet (medium screens) */
@media screen and (max-width: 992px) {
    .nfp-display-offcanvas .nfp-minicart-content {
        width: 60vw; /* Tablet: 60% of viewport width */
        max-width: none; /* Remove max-width constraint for tablets */
    }
}

/* Mobile (small screens) */
@media screen and (max-width: 576px) {
    .nfp-display-offcanvas .nfp-minicart-content {
        width: 90vw; /* Mobile: 90% of viewport width */
    }
    
    /* Adjust padding for smaller screens */
    .nfp-display-offcanvas .nfp-minicart-content {
        padding: 12px;
    }
}

/* Modal */
.nfp-display-modal .nfp-minicart-content {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.9);
    width: 400px;
    max-width: 90vw;
    max-height: 80vh;
    overflow-y: auto;
    border-radius: 8px;
    opacity: 0;
    transition: transform 0.3s ease, opacity 0.3s ease;
    z-index: 99990; /* High, but below WordPress admin bar */
}

.nfp-display-modal.nfp-cart-open .nfp-minicart-content {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
}

/* Admin bar compatibility - ensure proper spacing */
.admin-bar .nfp-display-dropdown .nfp-minicart-content {
    /* No special handling needed for dropdown */
}

/* Additional CSS to ensure the minicart appears in the right location
 * with or without the admin bar, without trying to overlay it
 */
.admin-bar .nfp-display-modal .nfp-minicart-content {
    /* For modal, no special positioning needed relative to admin bar */
    /* Since modal is centered in viewport */
}

/* Mobile admin bar adjustments */
@media screen and (max-width: 600px) {
    /* On mobile, admin bar is absolutely positioned and only 46px tall */
    .admin-bar .nfp-display-offcanvas .nfp-minicart-content {
        top: 46px;
        height: calc(100vh - 46px);
    }
}

/* Tablet/Desktop admin bar adjustments */
@media screen and (min-width: 601px) {
    /* On larger screens, admin bar is fixed and 32px tall */
    .admin-bar .nfp-display-offcanvas .nfp-minicart-content {
        top: 32px;
        height: calc(100vh - 32px);
    }
}

/* Cart items styling */
.nfp-minicart-items {
    margin-top: 15px;
}

.nfp-minicart-item {
    display: grid;
    grid-template-columns: 100px 1fr auto;
    padding: 10px;
    margin-bottom: 10px;
    border: 1px solid #d8d8d8;
    border-radius: 5px;
    position: relative;
}

.nfp-minicart-item:last-child {
    margin-bottom: 0;
}

/* Item loading states */
.nfp-minicart-item.nfp-updating {
    opacity: 0.7;
    background-color: rgba(246, 246, 246, 0.5);
}

.nfp-minicart-item.nfp-removing {
    opacity: 0.5;
    background-color: rgba(255, 240, 240, 0.5);
}

.nfp-minicart-item-image {
    margin-right: 10px;
    width: 100px;
    height: 100px;
    flex-shrink: 0;
    overflow: hidden;
}

.nfp-minicart-item-image img {
    width: 100%;
    height: 100%;
    max-width: none;
    max-height: none;
    display: block;
    object-fit: cover;
}

.nfp-minicart-item-details {
    display: flex;
    flex-direction: column;
    flex: 1;
    padding: 0 5px;
}

.nfp-minicart-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.nfp-minicart-item-reviews {
    color: #d7d7d7;
    font-size: 12px;
    line-height: 10px;
}

.nfp-minicart-item-title {
    font-weight: 600;
    font-size: 0.875rem;
    text-align: left;
}

.nfp-minicart-item-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-bottom: 2px;
    padding-bottom: 4px;
    border-bottom: 1px solid #e0e0e0;
}

.nfp-minicart-item-bottom {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 10px;
}

.nfp-minicart-price-regular {
    text-decoration: line-through;
    color: #666;
    margin-right: 6px;
}

.nfp-minicart-price-sale,
.nfp-minicart-item-price {
    color: #C50F0F;
    font-weight: 600;
}

.nfp-minicart-stock-status {
    display: flex;
    align-items: center;
    font-size: 13px;
    white-space: nowrap;
    padding: 4px 8px;
    border-radius: 4px;
}

.nfp-minicart-stock-status.in-stock {
    color: #10c410;
    background: #d7fad7;
}

.nfp-minicart-stock-status.low-stock {
    color: #c48810;
    background: #faeed7;
}

.nfp-minicart-stock-status.out-of-stock {
    color: #c41010;
    background: #fad7d7;
}

.nfp-minicart-quantity-control {
    display: flex;
    align-items: center;
    border: none;
    border-radius: 3px;
    overflow: hidden;
}

.nfp-minicart-quantity-decrease, .nfp-minicart-quantity-increase {
    line-height: 1;
    border-radius: 0px!important;
    min-width: 24px;
    min-height: 31px;
    border: 1px solid #000!important;
}

.nfp-minicart-input {
    height: 31px!important;
    text-align: center;
    font-size: 14px;
    padding: 2px 5px!important;
    border: 1px solid #000!important;
    border-left: 0px!important;
    border-radius: 0!important;
    -moz-appearance: textfield;
    border-right: 0px!important;
    border-top: 1px;
    border-bottom: 1px;
}

.nfp-minicart-input::-webkit-inner-spin-button,
.nfp-minicart-input::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* Minicart Input styling */
.nfp-minicart-input {
    width: 40px;
    height: 100%;
    border: none;
    text-align: center;
    font-size: 14px;
    padding: 0 5px;
    -moz-appearance: textfield;
}

.nfp-minicart-input::-webkit-inner-spin-button,
.nfp-minicart-input::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* Quantity input styling */
.nfp-minicart-quantity-input {
    display: flex;
    align-items: center;
    height: 32px;
    border: 1px solid #ddd;
    border-radius: 4px;
    overflow: hidden;
}

.nfp-minicart-quantity-decrease,
.nfp-minicart-quantity-increase {
    width: 30px;
    height: 100%;
    background: #f5f5f5;
    border: none;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    color: #333;
    transition: background-color 0.2s ease;
}

.nfp-minicart-quantity-decrease:hover,
.nfp-minicart-quantity-increase:hover {
    background-color: #e0e0e0;
}

.nfp-minicart-input {
    width: 40px;
    height: 100%;
    border: none;
    text-align: center;
    font-size: 14px;
    padding: 0 5px;
    -moz-appearance: textfield;
}

.nfp-minicart-input::-webkit-inner-spin-button,
.nfp-minicart-input::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* Footer styles */
.nfp-minicart-footer {
    margin-top: 15px;
    border-top: 1px solid #e0e0e0;
    padding-top: 15px;
}

.nfp-minicart-total {
    display: flex;
    justify-content: space-between;
    margin-bottom: 15px;
    font-weight: 600;
}

.nfp-minicart-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.nfp-minicart-action {
    padding: 10px;
    text-align: center;
    border-radius: 3px;
    font-weight: 500;
    transition: all 0.2s ease;
    text-decoration: none;
}

.nfp-minicart-view-cart {
    background-color: #f5f5f5;
    border: 1px solid #d8d8d8;
    color: #333;
}

.nfp-minicart-view-cart:hover {
    background-color: #e0e0e0;
}

.nfp-minicart-checkout {
    background-color: #000;
    color: #fff;
    border: 1px solid #000;
}

.nfp-minicart-checkout:hover {
    background-color: #333;
}

/* Price and quantity controls wrapper for flexbox alignment */
.nfp-minicart-price-controls-wrap {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    margin-top: 4px;
}

.nfp-minicart-badge {
    display: inline-block;
    padding: 3px 6px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    text-transform: capitalize;
    line-height: 1rem;
}

.nfp-minicart-price-sale, .nfp-minicart-item-price {
    color: #C50F0F;
    font-weight: 600;
    font-size: 14px;
}

button.nfp-minicart-quantity-decrease {
    padding: 0px 4px;
    border: none;
    background: #000;
    color: #fff;
}

button.nfp-minicart-quantity-increase {
    padding: 0px 4px;
    border: none;
    background: #000;
    color: #fff;
}
a.nfp-minicart-view-cart-button {
    text-transform: capitalize;
}
.nfp-minicart-badge.bundle {
    background-color: #000;
    color: #fff;
}

.nfp-minicart-badge.save {
    background-color: var(--color-success-500);
    color: #fff;
}
.woocommerce div.product div.images .woocommerce-product-gallery__trigger{
    z-index: 8!important;
}

.nfp-minicart-remove-item {
    position: absolute;
    top: 5px;
    right: 5px;
    border: none;
    font-size: 14px;
    cursor: pointer;
    color: #C50F0F;
    padding: 0;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Stock warning notification */
.nfp-stock-warning {
    background-color: #fff3cd;
    color: #856404;
    border: 1px solid #ffeeba;
    padding: 12px 30px 12px 15px;
    margin: 0 0 15px 0;
    border-radius: 4px;
    position: relative;
    font-size: 14px;
    animation: nfp-fade-in 0.3s ease-in-out;
}

.nfp-close-warning {
    position: absolute;
    right: 10px;
    top: 10px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    padding: 0;
    color: #856404;
}

@keyframes nfp-fade-in {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Responsive minicart item layout for mobile */
@media (max-width: 480px) {
  .nfp-minicart-item {
    grid-template-columns: 60px 1fr; /* Smaller image, more space for text */
    padding: 8px;
    gap: 8px;
  }
  .nfp-minicart-item-image {
    width: 60px;
    height: 60px;
    margin-right: 0;
  }
  .nfp-minicart-item-details {
    padding: 0 2px;
  }
  .nfp-minicart-item-title {
    font-size: 13px;
    word-break: break-word;
    white-space: normal;
  }
  .nfp-minicart-remove-item {
    top: 2px;
    right: 2px;
    width: 18px;
    height: 18px;
    font-size: 13px;
  }
  .nfp-minicart-badge {
        font-size: 12px;
        padding: 2px 4px;
        font-weight: bolder;
    }
  .nfp-minicart-item-price {
    font-size: 13px;
  }
  .nfp-minicart-price-controls-wrap{
  flex-wrap: wrap;
  }
  .nfp-minicart-quantity-decrease, .nfp-minicart-quantity-increase{
    min-width: 12px;
  }
  .nfp-minicart-quantity-control{
    width: 55px;
  }
  .nfp-hide-mobile {
    display: none !important;
  }
}

/* Clamp product title to 2 lines with ellipsis in minicart */
.nfp-minicart-item-title span {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: normal;
  max-height: 2.8em; /* fallback for 2 lines, adjust as needed */
  line-height: 1.4em;
}

/* Add color for filled review stars in minicart */
.nfp-minicart-item-reviews .nfp-star-filled {
  color: #C50F0F;
}
.nfp-minicart-item-reviews .nfp-star-empty {
  color: #d7d7d7;
} 