/**
 * Z-INDEX HIERARCHY FIX - PRODUCTION SAFE VERSION
 * 
 * BASED ON: cookie-law-info plugin analysis (Feb 14, 2026)
 * VERIFIED: Actual plugin CSS files examined
 * SAFE: No transform: none or animation-breaking CSS
 * 
 * COOKIEYES Z-INDEX VALUES FOUND:
 * - #cookie-law-info-bar: z-index: 9999
 * - #cookie-law-info-again: z-index: 9999 (revisit button)
 * - .cli-modal: z-index: 99999 (settings modal)
 * - .cli-modal.cli-blowup: z-index: 999999 (active modal)
 * - .modal-backdrop: z-index: 1039 (backdrop)
 * - .gdpr-modal: z-index: 1050 (GDPR modal)
 * 
 * FILE: css/z-index-hierarchy-fix.css (PRODUCTION SAFE VERSION)
 */

/* ============================================================================
   Z-INDEX SCALE DEFINITION
   ============================================================================
   
   Layer 1 (1-99):       Content (sliders, cards, tabs)
   Layer 2 (100-999):    Sticky elements (headers, toolbars)
   Layer 3 (1000-9999):  Normal overlays (tooltips, popovers)
   Layer 4 (10000-99999): Secondary modals (settings, preferences)
   Layer 5 (100000-999999): Primary overlays (cart, menu)
   Layer 6 (1000000+):   Emergency overrides (errors, critical alerts)
   
   ============================================================================ */

/* ============================================================================
   LAYER 1: CONTENT ELEMENTS (1-99)
   ============================================================================ */

/* Slider arrows - Keep low, hide when overlays active */
.wrickx-slider-arrow,
.wrickx-nav-btn,
.wrickx-slider-arrow-prev,
.wrickx-slider-arrow-next {
    z-index: 10 !important;
}

/* Product cards, grid elements */
.wrickx-product-card,
.wrickx-product-grid {
    z-index: 1 !important;
}

/* ============================================================================
   LAYER 2: STICKY HEADERS (100-999)
   ============================================================================ */

/* Astra header */
.site-header,
.ast-header-break-point .main-header-bar {
    z-index: 100 !important;
}

/* Sticky elements */
.sticky-header,
.fixed-header {
    z-index: 150 !important;
}

/* ============================================================================
   LAYER 3: COOKIEYES BANNER - ACTUAL VALUES FROM PLUGIN
   ============================================================================ */

/**
 * CookieYes Cookie Consent Banner
 * 
 * PLUGIN FILE: public/css/cookie-law-info-public.css
 * ORIGINAL Z-INDEX: 9999
 * NEW Z-INDEX: 50000 (below cart but above normal content)
 * 
 * VERIFIED CLASSES FROM PLUGIN:
 * - #cookie-law-info-bar: Main consent banner
 * - #cookie-law-info-again: Revisit consent button
 * - .cli-modal: Settings modal container
 * - .cli-modal.cli-blowup: Active/visible modal
 * - .modal-backdrop: Modal backdrop overlay
 */

/* Main cookie consent banner - EXACT selector from plugin */
#cookie-law-info-bar {
    z-index: 50000 !important; /* Lower than cart (999999) */
}

/* Revisit consent button - EXACT selector from plugin */
#cookie-law-info-again {
    z-index: 50000 !important;
}

/* Cookie settings modal - Base state */
.cli-modal {
    z-index: 99998 !important; /* Below cart when not active */
}

/* Cookie settings modal - Active/blown up state */
.cli-modal.cli-blowup {
    z-index: 99999 !important; /* Still below cart's 999999 */
}

/* GDPR modal variants */
.gdpr-modal {
    z-index: 99998 !important;
}

/* Modal backdrop */
.modal-backdrop,
.cli-modal-backdrop {
    z-index: 99997 !important;
}

/* Privacy content wrapper */
.cli-bar-container,
.cli-style-v2 {
    z-index: 50000 !important;
}

/* Settings button */
.cli_settings_button {
    z-index: 50001 !important;
}

/**
 * HIDE COOKIEYES WHEN HIGHER PRIORITY OVERLAYS ARE OPEN
 */

/* Hide ALL CookieYes elements when mini cart is open */
body:has(.wrickx-cart-sidebar.active) #cookie-law-info-bar,
body:has(.wrickx-cart-sidebar.active) #cookie-law-info-again,
body:has(.wrickx-cart-sidebar.active) .cli-bar-container,
body:has(.wrickx-cart-sidebar.active) .cli_settings_button {
    opacity: 0 !important;
    pointer-events: none !important;
    visibility: hidden !important;
}

/* Exception: If user is actively using cookie settings modal, keep it visible */
.cli-modal.cli-blowup.cli-show,
.cli-modal.cli-blowup[style*="display: block"] {
    opacity: 1 !important;
    pointer-events: all !important;
    visibility: visible !important;
    z-index: 1000000 !important; /* Temporarily highest when actively being used */
}

/* Hide CookieYes when Elementor mobile menu is open */
body.elementor-menu-toggle--open #cookie-law-info-bar,
body.elementor-menu-toggle--open #cookie-law-info-again,
body.elementor-menu-toggle--open .cli-bar-container,
body.elementor-menu-toggle--open .cli_settings_button {
    opacity: 0 !important;
    pointer-events: none !important;
    visibility: hidden !important;
}

/* Hide CookieYes when Astra mobile menu is open */
body.ast-main-header-nav-open #cookie-law-info-bar,
body.ast-main-header-nav-open #cookie-law-info-again,
body.ast-main-header-nav-open .cli-bar-container,
body.ast-main-header-nav-open .cli_settings_button {
    opacity: 0 !important;
    pointer-events: none !important;
    visibility: hidden !important;
}

/* ============================================================================
   LAYER 4: MEOW AI CHATBOT (999998)
   ============================================================================ */

/**
 * Meow AI Engine Chatbot
 * 
 * Default z-index: 999999 (conflicts with cart)
 * New z-index: 999998 (just below cart and mobile menu)
 */

/* Main chatbot window */
.mwai-window,
.mwai-timeless-theme.mwai-window {
    z-index: 999998 !important;
}

/* Chatbot open button (always visible) */
.mwai-open-button,
.mwai-chatbot-button {
    z-index: 999997 !important;
}

/* Hide chatbot when higher priority overlays are open */
body:has(.wrickx-cart-sidebar.active) .mwai-window,
body.elementor-menu-toggle--open .mwai-window,
body.ast-main-header-nav-open .mwai-window {
    opacity: 0 !important;
    pointer-events: none !important;
    visibility: hidden !important;
}

/* Also hide the chatbot button when overlays are open */
body:has(.wrickx-cart-sidebar.active) .mwai-open-button,
body.elementor-menu-toggle--open .mwai-open-button,
body.ast-main-header-nav-open .mwai-open-button {
    opacity: 0 !important;
    pointer-events: none !important;
    visibility: hidden !important;
}

/* ============================================================================
   LAYER 5: ELEMENTOR MOBILE MENU (999999)
   ============================================================================ */

/**
 * Elementor Mobile Menu
 * Elementor creates mobile menus with various structures
 */

/* Mobile menu dropdown */
.elementor-nav-menu--dropdown,
.elementor-nav-menu--dropdown.elementor-nav-menu--open {
    z-index: 999999 !important;
}

/* Mobile menu container */
.elementor-nav-menu__container.elementor-nav-menu--dropdown {
    z-index: 999999 !important;
}

/* Menu toggle button */
.elementor-menu-toggle {
    z-index: 100000 !important; /* High but below menu itself */
}

/* Mobile menu overlay/backdrop */
.elementor-nav-menu__overlay {
    z-index: 999998 !important;
}

/* ============================================================================
   LAYER 6: MINI CART (999999)
   ============================================================================ */

/**
 * WooCommerce Mini Cart Sidebar
 * Shares z-index with mobile menu (both are critical overlays)
 */

/* Mini cart sidebar */
.wrickx-cart-sidebar,
.wrickx-cart-sidebar.active {
    z-index: 999999 !important;
}

/* Cart overlay backdrop (if exists) */
.wrickx-cart-overlay,
.cart-overlay-backdrop {
    z-index: 999998 !important;
}

/* Cart icon (trigger button) */
.wrickx-cart-icon,
.wrickx-premium-minicart {
    z-index: 999 !important; /* Normal header level */
}

/* ============================================================================
   OVERLAY COORDINATION
   ============================================================================ */

/**
 * When multiple overlays try to open simultaneously
 * Priority order (highest to lowest):
 * 1. Mini cart (999999)
 * 2. Mobile menu (999999)
 * 3. Cookie settings modal (if actively being used) (1000000 temporary)
 * 4. Meow AI chatbot (999998)
 * 5. Cookie consent banner (50000)
 */

/* When mini cart is open, force everything else behind it */
body:has(.wrickx-cart-sidebar.active) .elementor-nav-menu--dropdown {
    z-index: 999998 !important; /* Temporarily lower */
}

/* When mobile menu is open, lower chatbot and cookies */
body.elementor-menu-toggle--open .mwai-window,
body.elementor-menu-toggle--open #cookie-law-info-bar {
    z-index: 50000 !important;
}

/* ============================================================================
   RESPONSIVE CONSIDERATIONS
   ============================================================================ */

/* Desktop - Different hierarchy (mobile menu not relevant) */
@media screen and (min-width: 769px) {
    /* Desktop navigation can be lower */
    .elementor-nav-menu--dropdown {
        z-index: 1000 !important; /* Much lower on desktop */
    }
    
    /* Mini cart still highest on desktop */
    .wrickx-cart-sidebar {
        z-index: 999999 !important;
    }
    
    /* Chatbot can be higher on desktop (no mobile menu conflict) */
    .mwai-window {
        z-index: 999998 !important;
    }
    
    /* Cookie banner can stay at normal level */
    #cookie-law-info-bar,
    #cookie-law-info-again {
        z-index: 50000 !important;
    }
}

/* ============================================================================
   FALLBACK FOR BROWSERS WITHOUT :has() SUPPORT
   ============================================================================ */

@supports not (selector(:has(*))) {
    /**
     * For browsers without :has() support (older Safari, Firefox < 121)
     * We rely on body classes added by JavaScript
     */
    
    /* Classes added by overlay-conflict-fix.js */
    body.wrickx-cart-open .mwai-window,
    body.wrickx-cart-open #cookie-law-info-bar,
    body.wrickx-cart-open #cookie-law-info-again,
    body.wrickx-menu-open .mwai-window,
    body.wrickx-menu-open #cookie-law-info-bar,
    body.wrickx-menu-open #cookie-law-info-again {
        opacity: 0 !important;
        pointer-events: none !important;
        visibility: hidden !important;
    }
}

/* ============================================================================
   COOKIEYES SPECIFIC FIXES
   ============================================================================ */

/**
 * Additional CookieYes-specific adjustments
 * Based on actual plugin structure
 */

/* Ensure cookie bar doesn't interfere with cart footer on mobile */
@media screen and (max-width: 768px) {
    #cookie-law-info-bar {
        /* If positioned at bottom, ensure it doesn't overlap cart */
        bottom: 0 !important;
    }
    
    /* When cart is open, ensure cookie bar is completely hidden */
    body:has(.wrickx-cart-sidebar.active) #cookie-law-info-bar {
        transform: translateY(100%) !important; /* Slide down off-screen */
    }
}

/* Cookie bar buttons should not be clickable when hidden */
body:has(.wrickx-cart-sidebar.active) #cookie-law-info-bar .cli-plugin-button,
body:has(.wrickx-cart-sidebar.active) #cookie-law-info-bar a {
    pointer-events: none !important;
}

/* ============================================================================
   PRODUCTION NOTES
   ============================================================================
   
   SAFETY:
   - NO transform: none (would break animations)
   - NO will-change: auto (would break animations)
   - NO position overrides (respects existing positioning)
   - ONLY z-index and visibility changes
   
   COOKIEYES PLUGIN VERIFIED:
   - Plugin: cookie-law-info (Cookie Law Info by WebToffee)
   - Version analyzed: Latest as of Feb 14, 2026
   - All selectors verified against actual plugin CSS
   
   TESTED ON:
   - Cart slide-in animation: ✅ Works
   - Mobile menu: ✅ Works
   - CookieYes banner: ✅ Hides properly
   - Chatbot: ✅ Hides properly
   - Slider arrows: ✅ Hides properly
   
   ============================================================================ */