/**
 * Kosmetics - Critical UI Fixes (Round 3)
 * ========================================
 * Master override file. Loaded LAST with highest priority.
 * Fixes: header sticky, brand-text dark mode, related products cards,
 * bottom-nav z-index, dots, sidebar improvements, cart mobile, search.
 */

/* ==========================================================================
   1. HEADER STICKY + AESTHETICS (Forced)
   ========================================================================== */
html body .site-header.main-header.k-header {
    position: -webkit-sticky !important;
    position: sticky !important;
    top: 0 !important;
    z-index: 9999 !important;
    /* Higher than anything */
    /* Default state: Transparent or White depending on page logic handled below */
    transition: box-shadow 0.3s ease, background 0.3s ease;
    width: 100% !important;
}

/* 1.1 Non-Home Pages: ALWAYS White/Solid */
html body:not(.home) .site-header.main-header.k-header {
    background: rgba(255, 255, 255, 0.95) !important;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

/* 1.2 Home Page: RESPONSIVE BEHAVIOR */

/* --- DESKTOP: Transparent Header over Banner --- */
@media (min-width: 769px) {
    html body.home .site-header.main-header.k-header:not(.header-scrolled) {
        position: sticky !important;
        background: rgba(255, 255, 255, 0.1) !important;
        backdrop-filter: blur(12px) !important;
        -webkit-backdrop-filter: blur(12px) !important;
        border-bottom: 1px solid rgba(255, 255, 255, 0.15) !important;
        box-shadow: none !important;
        top: 0 !important;
        transition: all 0.3s ease !important;
    }

    /* Black text color for transparent state (Light Mode) */
    html:not([data-theme="dark"]) body.home .site-header.main-header.k-header:not(.header-scrolled) .nav-menu>li>a,
    html:not([data-theme="dark"]) body.home .site-header.main-header.k-header:not(.header-scrolled) .header-actions i,
    html:not([data-theme="dark"]) body.home .site-header.main-header.k-header:not(.header-scrolled) .header-actions a,
    html:not([data-theme="dark"]) body.home .site-header.main-header.k-header:not(.header-scrolled) .header-actions button,
    html:not([data-theme="dark"]) body.home .site-header.main-header.k-header:not(.header-scrolled) .header-actions svg {
        color: #000000 !important;
        text-shadow: none !important;
    }

    /* Black logo (Light Mode) */
    html:not([data-theme="dark"]) body.home .site-header.main-header.k-header:not(.header-scrolled) .logo-image,
    html:not([data-theme="dark"]) body.home .site-header.main-header.k-header:not(.header-scrolled) .header-logo-dynamic,
    html:not([data-theme="dark"]) body.home .site-header.main-header.k-header:not(.header-scrolled) .k-header-logo svg {
        filter: none !important;
        color: #000000 !important;
    }

    /* White text color for transparent state (Dark Mode) */
    html[data-theme="dark"] body.home .site-header.main-header.k-header:not(.header-scrolled) .nav-menu>li>a,
    html[data-theme="dark"] body.home .site-header.main-header.k-header:not(.header-scrolled) .header-actions i,
    html[data-theme="dark"] body.home .site-header.main-header.k-header:not(.header-scrolled) .header-actions a,
    html[data-theme="dark"] body.home .site-header.main-header.k-header:not(.header-scrolled) .header-actions button,
    html[data-theme="dark"] body.home .site-header.main-header.k-header:not(.header-scrolled) .header-actions svg {
        color: #ffffff !important;
        text-shadow: 0 1px 3px rgba(0, 0, 0, 0.3) !important;
    }

    html[data-theme="dark"] body.home .site-header.main-header.k-header:not(.header-scrolled) .search-field {
        color: #ffffff !important;
    }

    /* White logo (Dark Mode) */
    html[data-theme="dark"] body.home .site-header.main-header.k-header:not(.header-scrolled) .logo-image,
    html[data-theme="dark"] body.home .site-header.main-header.k-header:not(.header-scrolled) .header-logo-dynamic,
    html[data-theme="dark"] body.home .site-header.main-header.k-header:not(.header-scrolled) .k-header-logo svg {
        filter: brightness(0) invert(1) drop-shadow(0 1px 2px rgba(0, 0, 0, 0.3)) !important;
        color: #ffffff !important;
    }
}

/* --- MOBILE: Solid Header --- */
@media (max-width: 768px) {
    html body.home .site-header.main-header.k-header {
        position: sticky !important;
        background: #ffffff !important;
        border-bottom: 1px solid rgba(0, 0, 0, 0.05) !important;
        transition: background 0.2s ease !important;
    }

    html[data-theme="dark"] body.home .site-header.main-header.k-header {
        background: #1c1c1e !important;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1) !important;
    }
}


/* --- HEADER SCROLL & TRANSPARENCY RULES --- */
/* Light Mode: 100% Opaque Scrolled */
html:not([data-theme="dark"]) body .site-header.main-header.k-header.is-scrolled-custom {
    background: #ffffff !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06) !important;
    box-shadow: 0 4px 20px -5px rgba(0, 0, 0, 0.1) !important;
}

html body.header-no-sticky .site-header.main-header.k-header {
    position: relative !important;
    /* Changed from static to relative */
    top: auto !important;
}

/* Dark Mode: Transparent Unscrolled */
html[data-theme="dark"] body .site-header.main-header.k-header:not(.is-scrolled-custom) {
    background: rgba(28, 28, 30, 0.65) !important;
    backdrop-filter: blur(12px) !important;
    -webkit-backdrop-filter: blur(12px) !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05) !important;
}

/* Dark Mode: 100% Opaque Scrolled */
html[data-theme="dark"] body .site-header.main-header.k-header.is-scrolled-custom {
    background: #1c1c1e !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08) !important;
}

/* Desktop: banner starts AT TOP (under header) */
@media (min-width: 769px) {
    html body.home .hero-section {
        position: relative !important;
        margin-top: -85px !important;
        /* Pull under the transparent header */
        height: calc(100vh - 35px) !important;
        /* Screen height minus topbar */
        overflow: hidden !important;
    }

    html body.home .hero-section .hero-slide-content {
        height: calc(100vh - 35px) !important;
        aspect-ratio: auto !important;
        background-position: center center !important;
        display: flex !important;
        align-items: center !important;
        padding-top: 85px !important;
        /* Push content down to avoid overlapping header */
    }
}

/* Mobile: banner flush below header */
@media (max-width: 768px) {
    html body.home .hero-section {
        margin-top: 0 !important;
        /* Header is sticky now, no need for margin */
        margin-bottom: 0 !important;
        aspect-ratio: 10 / 9 !important;
        height: auto !important;
    }

    /* Move dots OVER the image to eliminate white band below */
    .hero-swiper .swiper-pagination {
        bottom: 25px !important;
        z-index: 10 !important;
    }

    /* Hero slide fits the parent aspect ratio */
    html body.home .hero-section .hero-slide-content {
        background-position: top center !important;
        aspect-ratio: unset !important;
        height: 100% !important;
        /* Fill the newly restricted parent container */
    }

    /* Ajuste para que el slider toque los bordes del dispositivo en móviles (Omitir padding del container) */
    html body.home .hero-section .container {
        padding-left: 0 !important;
        padding-right: 0 !important;
        max-width: 100% !important;
    }

    /* Pull stories rail flush against the banner */
    .stories-rail,
    .k-mobile-stories-section {
        margin-top: 5px !important;
        /* Spacing now looks natural */
        padding-top: 10px !important;
        position: relative;
        z-index: 20;
    }
}

/* ==========================================================================
   2. STORIES SECTION HEADER (CUSTOM STYLING)
   ========================================================================== */
.stories-rail .section-header {
    display: block;
    margin-bottom: 20px;
    padding: 0 15px;
}

.stories-rail .section-header .section-subtitle {
    display: inline-flex;
    align-items: center;
    font-size: 0.70rem;
    font-weight: 800;
    color: var(--color-primary, #6b46c1);
    /* Fallback to purple if var fails */
    letter-spacing: 2px;
    margin-bottom: 6px;
    text-transform: uppercase;
}

.stories-rail .section-header .section-subtitle::before {
    content: '';
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: var(--color-primary, #6b46c1);
    margin-right: 8px;
}

.stories-rail .section-header h2 {
    font-size: 1.6rem;
    font-weight: 900;
    margin: 0;
    color: var(--color-text);
    line-height: 1.1;
    letter-spacing: -0.5px;
}

@media (max-width: 768px) {
    .stories-rail .section-header {
        margin-bottom: 15px;
    }

    .stories-rail .section-header h2 {
        font-size: 1.45rem;
    }
}

/* ==========================================================================
   3. BOTTOM NAV - Z-INDEX + DOTS
   ========================================================================== */
.k-bottom-nav,
#k-bottom-nav {
    z-index: 99997 !important;
    position: fixed !important;
    bottom: 0 !important;
}

/* Dot badges on bottom nav */
.k-bottom-nav .dot-badge,
#k-bottom-nav .dot-badge,
.k-bottom-nav .nav-icon-container .dot-badge {
    position: absolute !important;
    top: -2px !important;
    right: -4px !important;
    width: 8px !important;
    height: 8px !important;
    background-color: #8257E5 !important;
    border: 2px solid #fff !important;
    border-radius: 50% !important;
    z-index: 1000000 !important;
    z-index: 1000000 !important;
    pointer-events: none;
    display: none;
    /* Hidden by default, JS shows it */
}

.k-bottom-nav .nav-icon-container {
    overflow: visible !important;
    position: relative !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

/* Force show if style attribute is set (JS override) */
.k-bottom-nav .dot-badge[style*="display: block"] {
    display: block !important;
}

[data-theme="dark"] .k-bottom-nav .dot-badge,
[data-theme="dark"] #k-bottom-nav .dot-badge {
    border-color: #1c1c1e !important;
}

/* Dot badge positioning for global dots */
.dot-badge-global {
    display: none !important;
    /* Remove legacy global positioned dots */
}

/* ==========================================================================
   3. BRAND TEXT - DARK MODE FIX (Nuclear Specifity Level 9000)
   ========================================================================== */
html[data-theme="dark"] body .brand-text,
html[data-theme="dark"] body span.brand-text,
html[data-theme="dark"] body .mgc-brand-badge-static span,
html[data-theme="dark"] body .mgc-brand-badge-static .brand-text,
html[data-theme="dark"] body .mgc-card-header .brand-text,
html[data-theme="dark"] body .mgc-product-card .brand-text,
html[data-theme="dark"] body .mgc-product-card .mgc-brand-badge-static span,
html[data-theme="dark"] body .product .brand-text,
html[data-theme="dark"] body .product .mgc-brand-badge-static span,
html[data-theme="dark"] body li.product .brand-text,
html[data-theme="dark"] body .products .brand-text,
/* Add ID selectors for max priority */
html[data-theme="dark"] #main-content .brand-text,
html[data-theme="dark"] #page .brand-text {
    color: #c4a8ff !important;
    text-shadow: none !important;
    opacity: 1 !important;
    visibility: visible !important;
    -webkit-text-fill-color: #c4a8ff !important;
    /* Force override webkit fill */
}

html[data-theme="dark"] body .mgc-card-header {
    background-color: transparent !important;
    border-bottom-color: rgba(255, 255, 255, 0.08) !important;
}

/* Force filled heart when added (bypasses HTML cache issues) */
.mgc-custom-wishlist-btn.added:not(.wishlist-remove-btn) i::before {
    content: "\f004" !important;
    /* fa-heart solid code */
    font-weight: 900 !important;
    color: #EF4444 !important;
}

.mgc-custom-wishlist-btn.added:not(.wishlist-remove-btn) i {
    color: #EF4444 !important;
    font-weight: 900 !important;
}

/* ==========================================================================
   4. RELATED PRODUCTS - FLEXBOX FALLBACK (Robust)
   ========================================================================== */
@media (max-width: 768px) {

    /* Reset Grid completely and use Flex wrap */
    .k-related-products-section ul.products,
    .k-related-products-section .products {
        display: flex !important;
        flex-wrap: wrap !important;
        gap: 0 !important;
        /* Handle gap via padding */
        padding: 0 8px !important;
        margin: 0 -8px !important;
        /* Negative margin for padding balance */
        grid-template-columns: none !important;
    }

    .k-related-products-section ul.products::before,
    .k-related-products-section ul.products::after {
        display: none !important;
    }

    .k-related-products-section ul.products li.product,
    .k-related-products-section .products .product {
        width: 50% !important;
        /* Force 2 columns */
        flex: 0 0 50% !important;
        max-width: 50% !important;
        padding: 0 8px 16px !important;
        /* Gap simulation */
        margin: 0 !important;
        float: none !important;
        clear: none !important;
        box-sizing: border-box !important;
    }

    .k-related-products-section .mgc-product-card {
        height: 100% !important;
        width: 100% !important;
        display: flex !important;
        flex-direction: column !important;
    }

    .k-related-products-section .mgc-image-container {
        width: 100% !important;
        aspect-ratio: 1 / 1 !important;
        height: auto !important;
        overflow: hidden !important;
        position: relative !important;
    }

    .k-related-products-section img {
        width: 100% !important;
        height: 100% !important;
        object-fit: contain !important;
        /* Contain to prevent cropping */
        position: absolute !important;
        top: 0;
        left: 0;
    }

    /* Title clamp */
    .k-related-products-section h2,
    .k-related-products-section .woocommerce-loop-product__title {
        font-size: 18px !important;
        height: 2.6em !important;
        /* aprox 2 liines */
        overflow: hidden !important;
        margin: 8px 0 4px !important;
    }

    .k-related-products-section ul.products li.product .price {
        font-size: 14px !important;
        padding: 0 8px 8px !important;
    }

    .k-related-products-section>section {
        padding: 16px !important;
        border-radius: 12px !important;
    }
}

/* ==========================================================================
   5. SIDEBAR BURGER - IMPROVED UI/UX
   ========================================================================== */
.mobile-sidebar,
#main-sidebar {
    width: 85vw !important;
    max-width: 360px !important;
    z-index: 999999;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
}

.mobile-sidebar .sidebar-user-header {
    flex-shrink: 0;
}

/* Make everything after user header scrollable */
#main-sidebar {
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

/* Sidebar header: premium gradient */
.mobile-sidebar .sidebar-user-header {
    background: linear-gradient(135deg, #8B5CF6, #7C3AED) !important;
    padding: 28px 20px 20px !important;
    border-bottom: none !important;
}

.mobile-sidebar .sidebar-user-header .greeting,
.mobile-sidebar .sidebar-user-header .username {
    color: #fff !important;
}

.mobile-sidebar .sidebar-user-header .view-profile-link {
    color: rgba(255, 255, 255, 0.8) !important;
}

.mobile-sidebar .sidebar-user-header .user-avatar-placeholder {
    background: rgba(255, 255, 255, 0.2) !important;
    color: #fff !important;
}

/* Close button: floating */
.mobile-sidebar .close-sidebar-btn-modern {
    position: absolute !important;
    top: 12px !important;
    right: 12px !important;
    width: 32px !important;
    height: 32px !important;
    min-width: 32px !important;
    min-height: 32px !important;
    border-radius: 50% !important;
    background: rgba(255, 255, 255, 0.2) !important;
    color: #fff !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    border: none !important;
    cursor: pointer !important;
    z-index: 5 !important;
    aspect-ratio: 1 !important;
}

/* Section labels */
.mobile-sidebar .section-label {
    padding: 18px 20px 8px !important;
    margin: 0 !important;
    font-size: 10px !important;
    font-weight: 700 !important;
    letter-spacing: 1.2px !important;
    text-transform: uppercase !important;
    color: #999 !important;
}

/* Nav links: clean list */
.mobile-sidebar .clean-nav-list {
    padding: 0 !important;
    margin: 0 !important;
    list-style: none !important;
}

.mobile-sidebar .clean-nav-list li a {
    display: flex !important;
    align-items: center !important;
    gap: 14px !important;
    padding: 14px 20px !important;
    font-size: 15px !important;
    font-weight: 500 !important;
    color: #333 !important;
    text-decoration: none !important;
    transition: background 0.15s !important;
    border-bottom: 1px solid #f3f3f3 !important;
    background: transparent !important;
}

.mobile-sidebar .clean-nav-list li a:active {
    background: #f5f5f5 !important;
}

/* Accordion headers */
.mobile-sidebar .sidebar-accordion-header {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    padding: 14px 20px !important;
    width: 100% !important;
    font-size: 15px !important;
    font-weight: 500 !important;
    background: transparent !important;
    border: none !important;
    border-bottom: 1px solid #f3f3f3 !important;
    cursor: pointer !important;
    color: #333 !important;
}

/* Promo widget */
.mobile-sidebar .sidebar-promo-widget {
    margin: 16px !important;
    padding: 16px !important;
    border-radius: 14px !important;
    background: linear-gradient(135deg, #f5f0ff, #ede9fe) !important;
    color: #5b21b6 !important;
}

/* DARK MODE SIDEBAR */
[data-theme="dark"] .mobile-sidebar,
[data-theme="dark"] #main-sidebar {
    background-color: #1c1c1e !important;
}

[data-theme="dark"] .mobile-sidebar .sidebar-user-header {
    background: linear-gradient(135deg, #5b21b6, #4c1d95) !important;
}

[data-theme="dark"] .mobile-sidebar .clean-nav-list li a {
    color: #e0e0e0 !important;
    border-bottom-color: #2c2c2e !important;
}

[data-theme="dark"] .mobile-sidebar .clean-nav-list li a:active {
    background: #2c2c2e !important;
}

[data-theme="dark"] .mobile-sidebar .sidebar-accordion-header {
    color: #e0e0e0 !important;
    border-bottom-color: #2c2c2e !important;
}

[data-theme="dark"] .mobile-sidebar .section-label {
    color: #888 !important;
}

[data-theme="dark"] .mobile-sidebar .list-text {
    color: #e0e0e0 !important;
}

[data-theme="dark"] .mobile-sidebar .list-icon-simple {
    filter: brightness(1.6) saturate(0.8) !important;
}

[data-theme="dark"] .mobile-sidebar .sidebar-accordion-header i,
[data-theme="dark"] .mobile-sidebar .clean-nav-list .arrow {
    color: #a1a1aa;
}

.mobile-sidebar .sidebar-accordion-header i.fa-chevron-down {
    transition: transform 0.3s ease !important;
}

[data-theme="dark"] .mobile-sidebar .close-sidebar-btn-modern {
    background: rgba(255, 255, 255, 0.15) !important;
    color: #fff !important;
}

[data-theme="dark"] .mobile-sidebar .sidebar-promo-widget {
    background: linear-gradient(135deg, #2c2c2e, #3a3a3c) !important;
    color: #c4a8ff !important;
}

[data-theme="dark"] .mobile-sidebar .user-profile-card,
[data-theme="dark"] .mobile-sidebar .user-profile-card.guest {
    background: transparent !important;
}

[data-theme="dark"] .mobile-sidebar .clean-nav-list-sub li a {
    color: #ccc !important;
}

/* Sidebar backdrop */
.sidebar-backdrop {
    z-index: 99998 !important;
}

.mobile-sidebar {
    z-index: 99999999 !important;
}

/* ==========================================================================
   6. CART MOBILE - IMPROVED LAYOUT (GRID BASED)
   ========================================================================== */
@media (max-width: 767px) {
    .woocommerce-cart-form table.shop_table {
        display: block !important;
        width: 100% !important;
        border: none !important;
    }

    .woocommerce-cart-form table.shop_table thead {
        display: none !important;
    }

    .woocommerce-cart-form table.shop_table tbody {
        display: flex !important;
        flex-direction: column !important;
        gap: 16px !important;
    }

    /* Grid Layout for each item */
    .woocommerce-cart-form table.shop_table tr.cart_item {
        display: grid !important;
        grid-template-columns: 85px 1fr !important;
        grid-template-rows: auto auto auto !important;
        gap: 6px 16px !important;
        padding: 16px !important;
        background: var(--bg-surface, #fff) !important;
        border-radius: 16px !important;
        border: 1px solid var(--color-border-subtle, #f0f0f0) !important;
        box-shadow: 0 4px 15px rgba(0, 0, 0, 0.03) !important;
        position: relative !important;
        align-items: start !important;
    }

    /* Product thumbnail */
    .woocommerce-cart-form tr.cart_item td.product-thumbnail {
        grid-column: 1 !important;
        grid-row: 1 / span 3 !important;
        width: 100% !important;
        padding: 0 !important;
        border: none !important;
        align-self: center !important;
    }

    .woocommerce-cart-form tr.cart_item td.product-thumbnail img {
        width: 85px !important;
        height: 85px !important;
        object-fit: cover !important;
        border-radius: 12px !important;
    }

    /* Product name */
    .woocommerce-cart-form tr.cart_item td.product-name {
        grid-column: 2 !important;
        grid-row: 1 !important;
        padding: 0 28px 0 0 !important;
        /* Space for absolute remove button */
        border: none !important;
        font-size: 14.5px !important;
        font-weight: 600 !important;
        line-height: 1.3 !important;
    }

    .woocommerce-cart-form tr.cart_item td.product-name a {
        color: var(--color-text, #1a1a2e) !important;
        text-decoration: none !important;
    }

    /* Price / Subtotal */
    .woocommerce-cart-form tr.cart_item td.product-price {
        display: none !important;
        /* Hide individual unit price to save space */
    }

    .woocommerce-cart-form tr.cart_item td.product-subtotal {
        grid-column: 2 !important;
        grid-row: 2 !important;
        padding: 0 !important;
        border: none !important;
        font-size: 16px !important;
        font-weight: 700 !important;
        color: #8257E5 !important;
        align-self: end !important;
    }

    /* Quantity */
    .woocommerce-cart-form tr.cart_item td.product-quantity {
        grid-column: 2 !important;
        grid-row: 3 !important;
        padding: 6px 0 0 !important;
        border: none !important;
    }

    .woocommerce-cart-form tr.cart_item td.product-quantity .quantity {
        display: inline-flex !important;
        align-items: center !important;
        border: 1px solid #e5e5e5 !important;
        border-radius: 10px !important;
        overflow: hidden !important;
        background: #f9f9fc !important;
        height: 38px !important;
    }

    .woocommerce-cart-form tr.cart_item td.product-quantity .quantity input.qty {
        width: 40px !important;
        height: 100% !important;
        text-align: center !important;
        border: none !important;
        background: transparent !important;
        font-size: 15px !important;
        font-weight: 600 !important;
        padding: 0 !important;
        color: #1a1a2e !important;
    }

    /* Remove button */
    .woocommerce-cart-form tr.cart_item td.product-remove {
        position: absolute !important;
        top: 12px !important;
        right: 12px !important;
        padding: 0 !important;
        border: none !important;
    }

    .woocommerce-cart-form tr.cart_item td.product-remove a {
        width: 28px !important;
        height: 28px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        border-radius: 50% !important;
        background: #fdf2f2 !important;
        color: #EF4444 !important;
        text-decoration: none !important;
        font-size: 14px !important;
        transition: transform 0.2s !important;
    }

    .woocommerce-cart-form tr.cart_item td.product-remove a:hover {
        transform: scale(1.1) !important;
    }

    /* Dark mode overrrides */
    [data-theme="dark"] .woocommerce-cart-form tr.cart_item {
        background: #1e1e2c !important;
        border-color: #2d2d3e !important;
    }

    [data-theme="dark"] .woocommerce-cart-form tr.cart_item td.product-name a {
        color: #f0f0f4 !important;
    }

    [data-theme="dark"] .woocommerce-cart-form tr.cart_item td.product-subtotal {
        color: #a78bfa !important;
    }

    [data-theme="dark"] .woocommerce-cart-form tr.cart_item td.product-quantity .quantity {
        border-color: #3a3a4e !important;
        background: #151520 !important;
    }

    [data-theme="dark"] .woocommerce-cart-form tr.cart_item td.product-quantity .quantity input.qty {
        color: #f0f0f4 !important;
    }

    [data-theme="dark"] .woocommerce-cart-form tr.cart_item td.product-remove a {
        background: rgba(239, 68, 68, 0.15) !important;
        color: #fc8181 !important;
    }

    /* Cart totals container */
    .cart_totals {
        background: var(--bg-surface, #fff) !important;
        border-radius: 16px !important;
        padding: 24px !important;
        margin-top: 24px !important;
        border: 1px solid var(--color-border-subtle, #f0f0f0) !important;
        box-shadow: 0 8px 25px rgba(0, 0, 0, 0.04) !important;
    }

    [data-theme="dark"] .cart_totals {
        background: #1e1e2c !important;
        border-color: #2d2d3e !important;
    }
}

/* ==========================================================================
   7. SEARCH DRAWER IMPROVEMENTS
   ========================================================================== */
.bottom-drawer .k-search-results {
    max-height: calc(100vh - 120px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

/* Search history section */
.k-search-history {
    padding: 16px 0;
}

.k-search-history-title {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #999;
    padding: 0 0 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.k-search-history-clear {
    font-size: 12px;
    color: #7C3AED;
    cursor: pointer;
    font-weight: 500;
    text-transform: none;
    letter-spacing: 0;
}

.k-search-history-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.k-search-history-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: #f5f5f5;
    border-radius: 20px;
    font-size: 13px;
    color: #555;
    cursor: pointer;
    transition: background 0.15s;
}

.k-search-history-item:hover {
    background: #eee;
}

.k-search-history-item i {
    font-size: 11px;
    color: #999;
}

[data-theme="dark"] .k-search-history-item {
    background: #2c2c2e;
    color: #ccc;
}

/* Trending / Recommendations */
.k-search-trending {
    padding: 16px 0;
    border-top: 1px solid #f0f0f0;
}

.k-search-trending-title {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #999;
    padding: 0 0 10px;
}

.k-search-trending-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
    cursor: pointer;
}

.k-search-trending-item i {
    color: #7C3AED;
    font-size: 14px;
    width: 20px;
    text-align: center;
}

.k-search-trending-item span {
    font-size: 14px;
    color: #333;
}

[data-theme="dark"] .k-search-trending {
    border-top-color: #2c2c2e;
}

[data-theme="dark"] .k-search-trending-item span {
    color: #e0e0e0;
}

/* ==========================================================================
   8. MY ACCOUNT RESPONSIVE IMPROVEMENTS
   ========================================================================== */
@media (max-width: 480px) {
    .k-account-header {
        padding: 20px 16px;
    }

    .k-avatar-img {
        width: 52px !important;
        height: 52px !important;
    }

    .k-account-name {
        font-size: 16px;
    }

    .k-account-email {
        font-size: 12px;
    }

    .k-wallet-balance {
        font-size: 18px;
    }
}

/* WooCommerce form inputs on My Account */
.woocommerce-account .woocommerce-EditAccountForm input[type="text"],
.woocommerce-account .woocommerce-EditAccountForm input[type="email"],
.woocommerce-account .woocommerce-EditAccountForm input[type="password"],
.woocommerce-account .woocommerce-address-fields input[type="text"],
.woocommerce-account .woocommerce-address-fields input[type="tel"],
.woocommerce-account .woocommerce-address-fields input[type="email"],
.woocommerce-account .woocommerce-address-fields select,
.woocommerce-account .k-endpoint-content input[type="text"],
.woocommerce-account .k-endpoint-content input[type="email"],
.woocommerce-account .k-endpoint-content input[type="tel"],
.woocommerce-account .k-endpoint-content input[type="password"],
.woocommerce-account .k-endpoint-content select,
.woocommerce-account .k-endpoint-content textarea {
    width: 100% !important;
    padding: 12px 16px !important;
    border: 1px solid #e0e0e0 !important;
    border-radius: 12px !important;
    font-size: 15px !important;
    font-family: inherit !important;
    background: #fff !important;
    color: #333 !important;
    transition: border-color 0.2s, box-shadow 0.2s !important;
    -webkit-appearance: none !important;
    appearance: none !important;
    box-sizing: border-box !important;
}

.woocommerce-account .k-endpoint-content input:focus,
.woocommerce-account .k-endpoint-content select:focus,
.woocommerce-account .k-endpoint-content textarea:focus {
    border-color: #7C3AED !important;
    box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.1) !important;
    outline: none !important;
}

[data-theme="dark"] .woocommerce-account .k-endpoint-content input,
[data-theme="dark"] .woocommerce-account .k-endpoint-content select,
[data-theme="dark"] .woocommerce-account .k-endpoint-content textarea {
    background: #2c2c2e !important;
    border-color: #3a3a3c !important;
    color: #e0e0e0 !important;
}

/* Form labels */
.woocommerce-account .k-endpoint-content label {
    font-size: 13px !important;
    font-weight: 600 !important;
    color: #555 !important;
    margin-bottom: 6px !important;
    display: block !important;
}

[data-theme="dark"] .woocommerce-account .k-endpoint-content label {
    color: #aaa !important;
}

/* Save button */
.woocommerce-account .k-endpoint-content button[type="submit"],
.woocommerce-account .k-endpoint-content .button {
    width: 100% !important;
    padding: 14px !important;
    background: linear-gradient(135deg, #8B5CF6, #7C3AED) !important;
    color: #fff !important;
    border: none !important;
    border-radius: 12px !important;
    font-size: 15px !important;
    font-weight: 600 !important;
    cursor: pointer !important;
    transition: transform 0.2s, box-shadow 0.2s !important;
    margin-top: 16px !important;
}

.woocommerce-account .k-endpoint-content button[type="submit"]:hover,
.woocommerce-account .k-endpoint-content .button:hover {
    transform: translateY(-1px) !important;
    box-shadow: 0 4px 12px rgba(124, 58, 237, 0.3) !important;
}

/* Scroll lock for body when sidebar is open */
body.sidebar-open {
    overflow: hidden !important;
    position: fixed !important;
    width: 100% !important;
    height: 100% !important;
}

/* ==========================================================================
   9. RELATED PRODUCTS DESKTOP OVERRIDE
   ========================================================================== */
@media (min-width: 768px) {

    .k-related-products-section ul.products,
    .related.products ul.products,
    .k-related-products-section .products,
    .k-related-products-section .mgc-products-grid {
        grid-template-columns: repeat(4, 1fr) !important;
        gap: 24px !important;
    }

    .k-related-products-section ul.products li.product a img,
    .related.products ul.products li.product a img {
        max-height: 260px !important;
        min-height: 200px !important;
        margin-bottom: 16px !important;
    }

    .k-related-products-section ul.products li.product h2.woocommerce-loop-product__title {
        font-size: 16px !important;
        padding: 0 8px !important;
    }

    .k-related-products-section ul.products li.product .price {
        font-size: 18px !important;
    }
}

/* ==========================================================================
   10. WISHLIST OUT OF STOCK STYLING
   ========================================================================== */
.wishlist-item.out-of-stock .wishlist-item-image img,
.wishlist-item.out-of-stock .wishlist-item-title,
.wishlist-item.out-of-stock .wishlist-item-price {
    opacity: 0.5;
    filter: grayscale(100%);
    pointer-events: none;
}

.wishlist-item.out-of-stock .wishlist-item-info {
    position: relative;
}

/* ==========================================================================
   11. CUSTOM PRODUCT CARD REDESIGN
   ========================================================================== */
.woocommerce ul.products li.product.custom-card-design {
    background-color: #fcfcfc !important;
    border-radius: 12px !important;
    overflow: hidden !important;
    position: relative !important;
    display: flex !important;
    flex-direction: column !important;
    transition: all 0.3s ease !important;
    border: 1px solid rgba(0, 0, 0, 0.05) !important;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.02) !important;
    height: 100% !important;
    /* Ensure all cards are equal height in grid */
    padding: 0 !important;
    margin-bottom: 0 !important;
}

.woocommerce ul.products li.product.custom-card-design:hover {
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.06) !important;
    transform: translateY(-4px) !important;
}

html[data-theme="dark"] body .woocommerce ul.products li.product.custom-card-design {
    background-color: #1c1c1e !important;
    border: 1px solid rgba(255, 255, 255, 0.08) !important;
}

.k-product-card-inner {
    display: flex !important;
    flex-direction: column !important;
    height: 100% !important;
}

/* Image Container */
.k-product-image-wrap {
    position: relative !important;
    width: 100% !important;
    aspect-ratio: 1 / 1 !important;
    background: #fcfcfc !important;
    overflow: hidden !important;
}

html[data-theme="dark"] body .k-product-image-wrap {
    background: #111 !important;
}

.k-product-image-wrap img {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    /* Adjust to contain if images cut off */
}

/* Badges */
.k-product-badges {
    position: absolute !important;
    top: 12px !important;
    left: 12px !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 6px !important;
    z-index: 2 !important;
}

.k-badge {
    padding: 4px 12px !important;
    border-radius: 20px !important;
    font-size: 11px !important;
    font-weight: 700 !important;
    color: white !important;
    text-transform: uppercase !important;
    letter-spacing: 0.5px !important;
}

.k-badge-best {
    background: linear-gradient(135deg, #a855f7, #8257E5) !important;
}

.k-badge-new {
    background: linear-gradient(135deg, #10b981, #059669) !important;
}

/* Wishlist */
.k-wishlist-wrapper {
    position: absolute !important;
    top: 16px !important; /* Updated to match 16px uniform padding */
    right: 16px !important; /* Aligns perfectly with the add to cart button which has 16px padding */
    z-index: 2 !important;
}

/* Ensure no margins from YITH container */
.k-wishlist-wrapper .yith-wcwl-add-to-wishlist,
.k-wishlist-wrapper .yith-add-to-wishlist-button-block {
    margin: 0 !important;
}

/* Base button styling (matches Add to Cart) */
.k-wishlist-wrapper a {
    width: 36px !important;
    height: 36px !important;
    background-color: #8257E5 !important;
    border-radius: 50% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    color: white !important;
    /* Force white text/icon color */
    padding: 10px !important;
    border: none !important;
    overflow: hidden !important;
    line-height: 1 !important;
    transition: transform 0.2s, background-color 0.2s !important;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1) !important;
    position: relative !important;
    text-decoration: none !important;
    box-sizing: border-box !important;
}

.k-wishlist-wrapper a:hover {
    transform: scale(1.05) !important;
    background-color: #6d42c7 !important;
}

/* Make sure the native icon is properly sized and visible */
.k-wishlist-wrapper a i,
.k-wishlist-wrapper a svg,
.k-wishlist-wrapper a .yith-wcwl-icon {
    font-size: 14px !important;
    margin: 0 !important;
    display: inline-block !important;
}

/* Not Added (Stroke only) */
body .woocommerce ul.products li.product .k-wishlist-wrapper a.add_to_wishlist:not(.added) i,
body .woocommerce ul.products li.product .k-wishlist-wrapper a.add_to_wishlist:not(.added) svg,
body .woocommerce ul.products li.product .k-wishlist-wrapper a.add_to_wishlist:not(.added) svg path,
body .woocommerce ul.products li.product .k-wishlist-wrapper a.add_to_wishlist:not(.added) .yith-wcwl-icon,
body .woocommerce ul.products li.product .k-wishlist-wrapper a.fallback-wishlist i {
    color: #ffffff !important;
    fill: transparent !important;
    stroke: #ffffff !important;
    stroke-width: 1.5px !important;
}

/* Added (Solid / Filled) */
body .woocommerce ul.products li.product .k-wishlist-wrapper .yith-wcwl-wishlistaddedbrowse a i,
body .woocommerce ul.products li.product .k-wishlist-wrapper .yith-wcwl-wishlistexistsbrowse a i,
body .woocommerce ul.products li.product .k-wishlist-wrapper .yith-wcwl-wishlistaddedbrowse a svg,
body .woocommerce ul.products li.product .k-wishlist-wrapper .yith-wcwl-wishlistaddedbrowse a svg path,
body .woocommerce ul.products li.product .k-wishlist-wrapper .yith-wcwl-wishlistexistsbrowse a svg,
body .woocommerce ul.products li.product .k-wishlist-wrapper .yith-wcwl-wishlistexistsbrowse a svg path,
body .woocommerce ul.products li.product .k-wishlist-wrapper .yith-wcwl-wishlistaddedbrowse a .yith-wcwl-icon,
body .woocommerce ul.products li.product .k-wishlist-wrapper .yith-wcwl-wishlistexistsbrowse a .yith-wcwl-icon,
body .woocommerce ul.products li.product .k-wishlist-wrapper a.delete_item i,
body .woocommerce ul.products li.product .k-wishlist-wrapper a.delete_item svg,
body .woocommerce ul.products li.product .k-wishlist-wrapper a.delete_item svg path,
body .woocommerce ul.products li.product .k-wishlist-wrapper a.delete_item .yith-wcwl-icon,
body .woocommerce ul.products li.product .k-wishlist-wrapper a.added i,
body .woocommerce ul.products li.product .k-wishlist-wrapper a.added svg,
body .woocommerce ul.products li.product .k-wishlist-wrapper a.added svg path,
body .woocommerce ul.products li.product .k-wishlist-wrapper a.added .yith-wcwl-icon {
    color: #ffffff !important;
    fill: #ffffff !important;
    stroke: #ffffff !important;
}

/* Hide native text span but keep icon */
.k-wishlist-wrapper a span {
    display: none !important;
}

/* =========================================================
   Global Notification Center
   ========================================================= */
#k-notification-center {
    position: fixed !important;
    top: 80px !important;
    right: 20px !important;
    z-index: 99999 !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 12px !important;
    width: 320px !important;
    max-width: calc(100vw - 40px) !important;
    pointer-events: none !important;
}

.k-notification {
    background: #ffffff !important;
    border-radius: 12px !important;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1) !important;
    padding: 16px !important;
    animation: k-notif-slide-in 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards !important;
    border: 1px solid rgba(0,0,0,0.05) !important;
    pointer-events: auto !important;
}

.k-notification.k-notif-hide {
    animation: k-notif-slide-out 0.3s forwards !important;
}

@keyframes k-notif-slide-in {
    from { transform: translateX(120%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes k-notif-slide-out {
    from { transform: translateX(0); opacity: 1; }
    to { transform: translateX(120%); opacity: 0; }
}

.k-notif-header {
    display: flex !important;
    align-items: center !important;
    margin-bottom: 12px !important;
}

.k-notif-icon {
    width: 24px !important;
    height: 24px !important;
    border-radius: 50% !important;
    border: 1.5px solid #111 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    margin-right: 12px !important;
    color: #111 !important;
    flex-shrink: 0 !important;
}
.k-notif-icon svg { 
    width: 14px !important; 
    height: 14px !important; 
    stroke-width: 2 !important;
}

.k-notif-msg {
    font-size: 14px !important;
    font-weight: 500 !important;
    color: #333 !important;
    flex-grow: 1 !important;
    font-family: inherit !important;
}

.k-notif-close {
    background: #f3f4f6 !important;
    border: none !important;
    width: 28px !important;
    height: 28px !important;
    border-radius: 50% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    cursor: pointer !important;
    color: #666 !important;
    transition: background 0.2s !important;
    flex-shrink: 0 !important;
    padding: 0 !important;
}
.k-notif-close:hover { background: #e5e7eb !important; color: #111 !important; }
.k-notif-close svg { width: 14px !important; height: 14px !important; }

.k-notif-body {
    display: flex !important;
    align-items: flex-start !important;
    gap: 12px !important;
}

.k-notif-img {
    width: 60px !important;
    height: 60px !important;
    object-fit: cover !important;
    border-radius: 8px !important;
    background: #f9fafb !important;
    flex-shrink: 0 !important;
}

.k-notif-info {
    display: flex !important;
    flex-direction: column !important;
}

.k-notif-title {
    font-size: 13px !important;
    color: #4b5563 !important;
    line-height: 1.3 !important;
    margin-bottom: 6px !important;
    display: -webkit-box !important;
    -webkit-line-clamp: 2 !important;
    -webkit-box-orient: vertical !important;
    overflow: hidden !important;
    font-family: inherit !important;
}

.k-notif-price {
    font-size: 14px !important;
    font-weight: 700 !important;
    color: #111 !important;
}

/* Dark mode support */
html[data-theme="dark"] body .k-notification {
    background: #1c1c1e !important;
    border-color: rgba(255,255,255,0.08) !important;
}
html[data-theme="dark"] body .k-notif-icon { border-color: #fff !important; color: #fff !important; }
html[data-theme="dark"] body .k-notif-msg, 
html[data-theme="dark"] body .k-notif-price { color: #fff !important; }
html[data-theme="dark"] body .k-notif-close { background: #2c2c2e !important; color: #aaa !important; }
html[data-theme="dark"] body .k-notif-close:hover { background: #3a3a3c !important; color: #fff !important; }
html[data-theme="dark"] body .k-notif-title { color: #d1d5db !important; }

/* Content Container */
.k-product-content-wrap {
    padding: 16px !important;
    display: flex !important;
    flex-direction: column !important;
    flex-grow: 1 !important;
}

.k-product-brand {
    font-size: 11px !important;
    font-weight: 700 !important;
    text-transform: uppercase !important;
    letter-spacing: 1px !important;
    color: #4b5563 !important;
    margin-bottom: 6px !important;
}

html[data-theme="dark"] body .k-product-brand {
    color: #9ca3af !important;
}

.k-product-title-link {
    text-decoration: none !important;
}

.k-product-title {
    font-size: 13px !important;
    font-weight: 500 !important;
    line-height: 1.4 !important;
    color: #111827 !important;
    margin: 0 0 16px 0 !important;
    display: -webkit-box !important;
    -webkit-line-clamp: 2 !important;
    -webkit-box-orient: vertical !important;
    overflow: hidden !important;
}

html[data-theme="dark"] body .k-product-title {
    color: #f3f4f6 !important;
}

/* Price and Action Row */
.k-product-bottom-row {
    display: flex !important;
    justify-content: space-between !important;
    align-items: flex-end !important;
    margin-top: auto !important;
}

.k-product-price-block {
    display: flex !important;
    flex-direction: column !important;
}

.k-price-strikethrough {
    font-size: 12px !important;
    color: #9ca3af !important;
    text-decoration: line-through !important;
    margin-bottom: 2px !important;
}

.k-price-sale-row {
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
}

.k-price-percentage {
    font-size: 14px !important;
    font-weight: 700 !important;
    color: #ef4444 !important;
}

.k-price-final {
    font-size: 16px !important;
    font-weight: 700 !important;
    color: #111827 !important;
}

html[data-theme="dark"] body .k-price-final {
    color: #f3f4f6 !important;
}

/* Circular Action Button */
.k-product-action-block .add_to_cart_button,
.k-product-action-block .product_type_simple,
.k-product-action-block .product_type_variable {
    width: 36px !important;
    height: 36px !important;
    border-radius: 50% !important;
    background-color: #8257E5 !important;
    /* Purple */
    color: transparent !important;
    position: relative !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 0 !important;
    min-height: unset !important;
    font-size: 0 !important;
    border: none !important;
    overflow: hidden !important;
    line-height: 1 !important;
    transition: transform 0.2s, background-color 0.2s !important;
}

.k-product-action-block .add_to_cart_button:hover {
    transform: scale(1.05) !important;
    background-color: #6d42c7 !important;
}

.k-product-action-block .add_to_cart_button::after {
    content: "+" !important;
    color: white !important;
    font-size: 22px !important;
    font-weight: 400 !important;
    position: absolute !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
    font-family: inherit !important;
    line-height: 1 !important;
}

.k-product-action-block .add_to_cart_button.loading::after {
    content: "↻" !important;
    animation: spin 1s linear infinite !important;
}

.k-product-action-block .add_to_cart_button.added::after {
    content: "✓" !important;
}

/* Hide native elements if generated outside */
.woocommerce ul.products li.product.custom-card-design>.woocommerce-loop-product__title,
.woocommerce ul.products li.product.custom-card-design>.price {
    display: none !important;
}