/**
 * Netable_MinicartUpsell - Professional Minicart Styling
 *
 * Matches Porto theme with Flexo font, #1aa1f0 brand color.
 * Provides animated progress bar, product carousel with navigation arrows,
 * skeleton loaders, and Quick Add button states.
 *
 * Responsive: Desktop (448px slide), Tablet (768px), Mobile (100vw),
 *             iOS Safari, Android Chrome.
 */

/* ============================================
   FREE SHIPPING PROGRESS BAR
   ============================================ */

.netable-free-shipping-bar {
    padding: 16px 0 14px;
    border-top: 1px solid #e8e8e8;
    margin-top: 2px;
    font-family: 'Flexo', 'Helvetica Neue', Arial, sans-serif;
    transition: all 0.3s ease;
}

/* Message Row */
.nfs-message {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
    font-size: 13px;
    font-weight: 700;
    color: #1aa1f0;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    line-height: 1.3;
}

.nfs-message.nfs-success {
    color: #1aa1f0;
}

.nfs-icon {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.nfs-icon-truck {
    color: #1aa1f0;
}

.nfs-text {
    flex: 1;
}

/* Progress Track */
.nfs-progress-track {
    width: 100%;
    height: 10px;
    background: #e5e7eb;
    border-radius: 99px;
    overflow: hidden;
    position: relative;
}

.nfs-progress-fill {
    height: 100%;
    border-radius: 99px;
    transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1),
                background-color 0.4s ease;
    position: relative;
    min-width: 0;
    background-image: linear-gradient(
        90deg,
        rgba(255,255,255,0) 0%,
        rgba(255,255,255,0.25) 50%,
        rgba(255,255,255,0) 100%
    );
    background-size: 200% 100%;
    animation: nfs-shimmer 2s infinite linear;
}

.nfs-progress-fill.nfs-pulse {
    animation: nfs-shimmer 2s infinite linear, nfs-celebrate 0.6s ease-in-out;
}

@keyframes nfs-shimmer {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

@keyframes nfs-celebrate {
    0%   { transform: scaleY(1); }
    50%  { transform: scaleY(1.3); }
    100% { transform: scaleY(1); }
}

/* Threshold Met State */
.netable-free-shipping-bar.threshold-met .nfs-progress-track {
    background: #e0f2fe;
}


/* ============================================
   UPSELL / FREQUENTLY BOUGHT TOGETHER
   ============================================ */

.netable-minicart-upsell {
    padding: 14px 0 8px;
    border-top: 1px solid #e8e8e8;
    margin-top: 4px;
    font-family: 'Flexo', 'Helvetica Neue', Arial, sans-serif;
}

/* Section Title */
.nmu-title {
    font-size: 13px;
    font-weight: 700;
    color: #1aa1f0;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-bottom: 14px;
    line-height: 1.3;
}

/* ============================================
   CAROUSEL WRAPPER WITH ARROWS
   ============================================ */

.nmu-carousel-wrapper {
    position: relative;
    overflow: visible;
}

/* Navigation Arrows */
.netable-minicart-upsell .nmu-carousel-arrow,
.nmu-carousel-arrow {
    position: absolute !important;
    top: 50% !important;
    transform: translateY(-60%) !important;
    z-index: 5 !important;
    width: 30px !important;
    height: 30px !important;
    border-radius: 50% !important;
    background: #fff !important;
    border: 1px solid #d1d5db !important;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12) !important;
    display: flex;
    align-items: center !important;
    justify-content: center !important;
    cursor: pointer !important;
    color: #333 !important;
    transition: background 0.2s ease, box-shadow 0.2s ease, color 0.2s ease, opacity 0.2s ease !important;
    padding: 0 !important;
    margin: 0 !important;
    outline: none !important;
    -webkit-appearance: none !important;
    -webkit-tap-highlight-color: transparent !important;
}

.netable-minicart-upsell .nmu-carousel-arrow[style*="display: none"],
.nmu-carousel-arrow[style*="display: none"] {
    display: none !important;
}

.netable-minicart-upsell .nmu-carousel-arrow:hover,
.nmu-carousel-arrow:hover {
    background: #1aa1f0 !important;
    border-color: #1aa1f0 !important;
    color: #fff !important;
    box-shadow: 0 3px 8px rgba(26, 161, 240, 0.3) !important;
}

.netable-minicart-upsell .nmu-carousel-arrow:active,
.nmu-carousel-arrow:active {
    transform: translateY(-60%) scale(0.92) !important;
}

.netable-minicart-upsell .nmu-carousel-arrow em,
.nmu-carousel-arrow em {
    display: inline-block !important;
    width: 16px !important;
    height: 16px !important;
    background-size: contain !important;
    background-repeat: no-repeat !important;
    background-position: center !important;
    margin: 0 !important;
    padding: 0 !important;
}

.netable-minicart-upsell .nmu-arrow-left em,
.nmu-arrow-left em {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23333333' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='15 18 9 12 15 6'%3E%3C/polyline%3E%3C/svg%3E") !important;
}

.netable-minicart-upsell .nmu-carousel-arrow:hover .nmu-arrow-left em,
.netable-minicart-upsell .nmu-carousel-arrow:hover.nmu-arrow-left em,
.nmu-carousel-arrow:hover .nmu-arrow-left em {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23ffffff' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='15 18 9 12 15 6'%3E%3C/polyline%3E%3C/svg%3E") !important;
}

.netable-minicart-upsell .nmu-arrow-right em,
.nmu-arrow-right em {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23333333' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='9 18 15 12 9 6'%3E%3C/polyline%3E%3C/svg%3E") !important;
}

.netable-minicart-upsell .nmu-carousel-arrow:hover .nmu-arrow-right em,
.netable-minicart-upsell .nmu-carousel-arrow:hover.nmu-arrow-right em,
.nmu-carousel-arrow:hover .nmu-arrow-right em {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23ffffff' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='9 18 15 12 9 6'%3E%3C/polyline%3E%3C/svg%3E") !important;
}

.netable-minicart-upsell .nmu-carousel-arrow em::before,
.nmu-carousel-arrow em::before {
    content: "" !important;
    display: none !important;
}

.netable-minicart-upsell .nmu-arrow-left,
.nmu-arrow-left {
    left: -10px !important;
}

.netable-minicart-upsell .nmu-arrow-right,
.nmu-arrow-right {
    right: -10px !important;
}

/* Scrollable Product Row */
.nmu-products-scroll {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch; /* iOS momentum scroll */
    padding: 4px 4px 8px 4px;
    margin: 0;

    /* Scroll snap for mobile touch */
    scroll-snap-type: x mandatory;

    /* Hide scrollbar on all browsers */
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.nmu-products-scroll::-webkit-scrollbar {
    display: none;
}

/* Product Card */
.nmu-product-card {
    flex: 0 0 120px;
    min-width: 120px;
    max-width: 120px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    background: #fafafa;
    border: 1px solid #eee;
    border-radius: 8px;
    padding: 10px 8px;
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
    cursor: pointer;
    position: relative;
    scroll-snap-align: start;
    box-sizing: border-box;

    /* Prevent iOS text size adjust */
    -webkit-text-size-adjust: 100%;
}

.nmu-product-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    border-color: #1aa1f0;
}

/* Product Image */
.nmu-product-image {
    display: flex;
    width: 80px;
    height: 80px;
    margin-bottom: 8px;
    overflow: hidden;
    border-radius: 4px;
    background: #fff;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.nmu-product-image img {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    transition: transform 0.3s ease;

    /* Prevent iOS image dragging */
    -webkit-user-drag: none;
    user-select: none;
}

.nmu-product-card:hover .nmu-product-image img {
    transform: scale(1.05);
}

/* Product Name */
.nmu-product-name {
    font-size: 11px;
    font-weight: 700;
    color: #1a1a1a;
    line-height: 1.3;
    margin-bottom: 4px;
    max-height: 28px;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    text-decoration: none;
    width: 100%;
    font-family: 'Flexo', 'Helvetica Neue', Arial, sans-serif;
    word-break: break-word;
}

.nmu-product-name:hover {
    color: #1aa1f0;
    text-decoration: none;
}

/* Price */
.nmu-product-price {
    font-size: 12px;
    font-weight: 400;
    color: #333;
    margin-bottom: 8px;
    line-height: 1.2;
}

/* Quick Add Button */
.netable-minicart-upsell .nmu-quick-add,
.netable-minicart-upsell button.nmu-quick-add,
.netable-minicart-upsell a.nmu-quick-add {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 100% !important;
    padding: 6px 8px !important;
    font-size: 11px !important;
    font-weight: 700 !important;
    font-family: 'Flexo', 'Helvetica Neue', Arial, sans-serif !important;
    text-transform: uppercase !important;
    letter-spacing: 0.3px !important;
    color: #fff !important;
    background: #1aa1f0 !important;
    border: 1px solid #1aa1f0 !important;
    border-radius: 4px !important;
    cursor: pointer !important;
    transition: background-color 0.2s ease, border-color 0.2s ease, transform 0.15s ease !important;
    text-decoration: none !important;
    line-height: 1.3 !important;
    margin-top: auto !important;
    position: relative !important;
    overflow: hidden !important;
    min-height: 28px !important;
    height: 28px !important;
    box-sizing: border-box !important;
    -webkit-appearance: none !important;
    -webkit-tap-highlight-color: transparent !important;
    touch-action: manipulation !important;
}

.netable-minicart-upsell .nmu-quick-add:hover,
.netable-minicart-upsell button.nmu-quick-add:hover,
.netable-minicart-upsell a.nmu-quick-add:hover {
    background: #333 !important;
    border-color: #333 !important;
    color: #fff !important;
    text-decoration: none !important;
}

.netable-minicart-upsell .nmu-quick-add:active,
.netable-minicart-upsell button.nmu-quick-add:active,
.netable-minicart-upsell a.nmu-quick-add:active {
    transform: scale(0.96) !important;
}

.netable-minicart-upsell .nmu-quick-add:focus,
.netable-minicart-upsell button.nmu-quick-add:focus,
.netable-minicart-upsell a.nmu-quick-add:focus {
    outline: none !important;
}

/* View Product variant matches standard Quick Add */
.netable-minicart-upsell .nmu-view-product,
.netable-minicart-upsell a.nmu-view-product {
    background: #1aa1f0 !important;
    color: #fff !important;
    border-color: #1aa1f0 !important;
}

.netable-minicart-upsell .nmu-view-product:hover,
.netable-minicart-upsell a.nmu-view-product:hover {
    background: #333 !important;
    border-color: #333 !important;
    color: #fff !important;
}

/* Button States */
.nmu-btn-loading,
.nmu-btn-check {
    display: none;
}

.nmu-quick-add.nmu-adding .nmu-btn-text {
    display: none;
}

.nmu-quick-add.nmu-adding .nmu-btn-loading {
    display: inline-flex;
}

.nmu-quick-add.nmu-added .nmu-btn-text,
.nmu-quick-add.nmu-added .nmu-btn-loading {
    display: none;
}

.nmu-quick-add.nmu-added .nmu-btn-check {
    display: inline-flex;
    font-size: 14px;
}

.netable-minicart-upsell .nmu-quick-add.nmu-added,
.netable-minicart-upsell button.nmu-quick-add.nmu-added {
    background: #1aa1f0 !important;
    border-color: #1aa1f0 !important;
}

/* Spinner Animation */
.nmu-spinner {
    animation: nmu-spin 0.8s linear infinite;
}

@keyframes nmu-spin {
    0%   { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}


/* ============================================
   SKELETON LOADING
   ============================================ */

.nmu-skeleton-row {
    display: flex;
    gap: 12px;
    overflow: hidden;
    padding-bottom: 4px;
}

.nmu-skeleton-card {
    flex: 0 0 120px;
    min-width: 120px;
    display: flex;
    flex-direction: column;
    align-items: center;
    background: #fafafa;
    border: 1px solid #eee;
    border-radius: 8px;
    padding: 10px 8px;
}

.nmu-skeleton-img {
    width: 80px;
    height: 80px;
    border-radius: 4px;
    margin-bottom: 8px;
    background: linear-gradient(90deg, #eee 25%, #f5f5f5 50%, #eee 75%);
    background-size: 200% 100%;
    animation: nmu-skeleton-pulse 1.5s ease-in-out infinite;
}

.nmu-skeleton-text {
    width: 90%;
    height: 12px;
    border-radius: 3px;
    margin-bottom: 6px;
    background: linear-gradient(90deg, #eee 25%, #f5f5f5 50%, #eee 75%);
    background-size: 200% 100%;
    animation: nmu-skeleton-pulse 1.5s ease-in-out infinite;
    animation-delay: 0.15s;
}

.nmu-skeleton-price {
    width: 60%;
    height: 10px;
    border-radius: 3px;
    background: linear-gradient(90deg, #eee 25%, #f5f5f5 50%, #eee 75%);
    background-size: 200% 100%;
    animation: nmu-skeleton-pulse 1.5s ease-in-out infinite;
    animation-delay: 0.3s;
}

@keyframes nmu-skeleton-pulse {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}


/* ============================================
   INTEGRATION: Proper ordering inside minicart
   ============================================ */

/* Ensure widgets area takes full width and proper ordering */
#minicart-content-wrapper .block-content .minicart-widgets,
#minicart-content-wrapper #minicart-widgets {
    width: 100%;
    margin-top: 0;
    order: 4;
}

/* Prevent minicart content overflow from arrows */
#minicart-content-wrapper {
    overflow-x: hidden;
}


/* ============================================
   RESPONSIVE — TABLET (≤768px)
   ============================================ */

@media (max-width: 768px) {
    .netable-minicart-upsell .nmu-carousel-arrow,
    .nmu-carousel-arrow {
        width: 28px !important;
        height: 28px !important;
    }

    .netable-minicart-upsell .nmu-arrow-left,
    .nmu-arrow-left {
        left: -6px !important;
    }

    .netable-minicart-upsell .nmu-arrow-right,
    .nmu-arrow-right {
        right: -6px !important;
    }

    .nmu-product-card {
        flex: 0 0 115px;
        min-width: 115px;
        max-width: 115px;
    }
}


/* ============================================
   RESPONSIVE — MOBILE (≤480px)
   Minicart is 100vw on mobile
   ============================================ */

@media (max-width: 480px) {
    .netable-free-shipping-bar {
        padding: 14px 0 12px;
    }

    .nfs-message {
        font-size: 12px;
    }

    /* Hide arrows on mobile — touch scroll is native */
    .nmu-carousel-arrow {
        display: none !important;
    }

    .nmu-product-card {
        flex: 0 0 105px;
        min-width: 105px;
        max-width: 105px;
        padding: 8px 6px;
    }

    .nmu-product-image {
        width: 70px;
        height: 70px;
    }

    .nmu-product-name {
        font-size: 10px;
    }

    .nmu-product-price {
        font-size: 11px;
    }

    .nmu-quick-add {
        font-size: 10px;
        padding: 5px 6px;
    }

    .nmu-skeleton-card {
        flex: 0 0 105px;
        min-width: 105px;
    }

    .nmu-skeleton-img {
        width: 70px;
        height: 70px;
    }
}


/* ============================================
   iOS SPECIFIC FIXES
   ============================================ */

/* Fix for iOS Safari rubber-banding on nested scrollables */
@supports (-webkit-touch-callout: none) {
    .nmu-products-scroll {
        -webkit-overflow-scrolling: touch;
        scroll-snap-type: x proximity; /* Less aggressive snap on iOS */
    }

    /* Prevent iOS double-tap zoom on buttons */
    .nmu-quick-add,
    .nmu-carousel-arrow {
        touch-action: manipulation;
    }

    /* Fix iOS rendering of border-radius on scrolling containers */
    .nmu-product-card {
        -webkit-transform: translateZ(0);
        transform: translateZ(0);
    }
}


/* ============================================
   SAFE AREA INSETS (iPhone X+ notch devices)
   ============================================ */

@supports (padding-left: env(safe-area-inset-left)) {
    .nmu-products-scroll {
        padding-left: max(4px, env(safe-area-inset-left));
        padding-right: max(4px, env(safe-area-inset-right));
    }
}


/* ============================================
   REDUCED MOTION PREFERENCE
   ============================================ */

@media (prefers-reduced-motion: reduce) {
    .nfs-progress-fill {
        animation: none;
        transition: width 0.3s ease;
    }

    .nmu-product-card,
    .nmu-quick-add,
    .nmu-product-image img {
        transition: none;
    }

    .nmu-skeleton-img,
    .nmu-skeleton-text,
    .nmu-skeleton-price {
        animation: none;
        background: #eee;
    }

    .nmu-spinner {
        animation-duration: 1.5s;
    }
}
