/**
 * ESP Category Demo - Full Page Styles
 * Version 4.6.0 - Fixed mobile subcategory navigation z-index/pointer-events
 */

/* ============================================
   CSS Variables / Design Tokens
   ============================================

   NOTE: All design tokens are inherited from homepage.css
   Only demo-specific variables are defined here.
   ============================================ */
:root {
    /* SMALink-inspired colors (demo-specific) */
    --esp-navy: #001e62;
    --esp-burgundy: #9d2235;

    /* Missing color definitions for drawer backgrounds */
    --esp-white: #ffffff;
    --esp-bg-light: #f3f4f6;
}

/* ============================================
   Reset & Base
   ============================================ */
*, *::before, *::after {
    box-sizing: border-box;
}

body.esp-demo-body {
    margin: 0;
    padding: 0;
    font-family: var(--esp-font-sans);
    font-size: 1rem;
    line-height: 1.5;
    color: var(--esp-text);
    background: var(--esp-bg);
    -webkit-font-smoothing: antialiased;
}

a {
    color: inherit;
    text-decoration: none;
}

ul, ol {
    list-style: none;
    margin: 0;
    padding: 0;
}

img {
    max-width: 100%;
    height: auto;
}

/* Container - uses homepage.css responsive container styles */
/* (removed duplicate .esp-container to avoid overriding responsive breakpoints) */

/* ============================================
   Demo Badge
   ============================================ */
.esp-demo-badge {
    background: linear-gradient(90deg, var(--esp-primary), var(--esp-primary-dark));
    color: var(--esp-black);
    text-align: center;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-weight: 600;
}

.esp-demo-badge span {
    background: var(--esp-black);
    color: var(--esp-primary);
    padding: 0.125rem 0.5rem;
    border-radius: 3px;
    margin-right: 0.5rem;
    font-weight: 700;
}

/* ============================================
   Header, Top Bar, Logo Bar, Navigation Bar
   ============================================

   NOTE: Header/navigation styles are inherited from homepage.css
   This file only contains demo-specific overrides and extensions.

   Inherited from homepage.css:
   - .esp-header
   - .esp-topbar, .esp-topbar__inner, .esp-topbar__link
   - .esp-logobar, .esp-logobar__inner, .esp-logo
   - .esp-search, .esp-search__form, .esp-search__input-wrap
   - .esp-mobile-nav-toggle
   - .esp-account-link, .esp-cart-link
   - .esp-nav, .esp-nav__menu, .esp-nav__dropdown
   - .esp-nav__products-btn
   ============================================ */

/* ============================================
   Drawer Overlay
   ============================================ */
.esp-drawer-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 98;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.esp-drawer-overlay.is-visible {
    display: block;
    opacity: 0.8;
}

/* Body scroll lock when drawer is open */
body.esp-drawer-open {
    overflow: hidden;
}

/* ============================================
   Category Drawer (SMALink-style slide down)
   ============================================ */
.esp-category-drawer {
    display: none;
    position: absolute;
    left: 0;
    right: 0;
    z-index: 999;
    background: transparent;
    overflow: hidden;
}

.esp-category-drawer.is-open {
    display: flex;
}

/* First Level Categories (Left Panel) */
.esp-drawer__first-levels {
    width: 354px;
    min-width: 354px;
    max-width: 354px;
    background: var(--esp-bg-light);
    border-right: 1px solid var(--esp-border);
    overflow-y: auto;
    flex-shrink: 0;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}

/* Custom scrollbar for first levels */
.esp-drawer__first-levels::-webkit-scrollbar {
    width: 8px;
}

.esp-drawer__first-levels::-webkit-scrollbar-track {
    background: var(--esp-bg-light);
}

.esp-drawer__first-levels::-webkit-scrollbar-thumb {
    background: var(--esp-primary);
    border-radius: 4px;
    border: 2px solid var(--esp-bg-light);
}

.esp-drawer__first-levels::-webkit-scrollbar-thumb:hover {
    background: var(--esp-primary-dark);
}

.esp-drawer__first-list {
    padding: 0;
    margin: 0;
}

.esp-drawer__first-item {
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.esp-drawer__first-item > a {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.875rem 1.25rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--esp-text);
    cursor: pointer;
    transition: background-color var(--esp-transition), color var(--esp-transition);
}

.esp-drawer__first-item > a span {
    flex: 1;
}

.esp-drawer__first-item > a i {
    color: var(--esp-text-light);
    font-size: 0.75rem;
    transition: color var(--esp-transition);
}

.esp-drawer__first-item:hover > a,
.esp-drawer__first-item.is-active > a {
    background: var(--esp-primary);
    color: var(--esp-black);
}

.esp-drawer__first-item:hover > a i,
.esp-drawer__first-item.is-active > a i {
    color: var(--esp-black);
}

/* No children - direct link styling */
.esp-drawer__first-item.no-children > a:hover {
    background: var(--esp-primary-light);
    color: var(--esp-primary-dark);
}

/* Second Level Categories (Right Panel) - Slide out from left */
.esp-drawer__second-levels {
    width: 0;
    min-width: 0;
    flex: 0 0 0;
    display: flex;
    flex-direction: column;
    padding: 0;
    overflow: hidden;
    background: var(--esp-white);
    transition: width 0.3s ease, min-width 0.3s ease, flex 0.3s ease, padding 0.3s ease;
}

.esp-drawer__second-levels.is-visible {
    width: auto;
    min-width: 400px;
    flex: 1;
    padding: 1.5rem 2rem;
    overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}

/* Custom scrollbar for second levels */
.esp-drawer__second-levels::-webkit-scrollbar {
    width: 8px;
}

.esp-drawer__second-levels::-webkit-scrollbar-track {
    background: var(--esp-bg-light);
}

.esp-drawer__second-levels::-webkit-scrollbar-thumb {
    background: var(--esp-primary);
    border-radius: 4px;
    border: 2px solid var(--esp-bg-light);
}

.esp-drawer__second-levels::-webkit-scrollbar-thumb:hover {
    background: var(--esp-primary-dark);
}

.esp-drawer__second-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    padding-bottom: 0.75rem;
    border-bottom: 2px solid var(--esp-primary);
}

.esp-drawer__parent-name {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--esp-primary-dark);
}

.esp-drawer__view-all {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--esp-primary-dark);
    transition: color var(--esp-transition);
}

.esp-drawer__view-all:hover {
    color: var(--esp-primary);
    text-decoration: underline;
}

/* Subcategories Grid */
.esp-drawer__grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 1.5rem;
}

.esp-drawer__cat-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 1rem;
    border-radius: 0.5rem;
    transition: background-color var(--esp-transition), transform var(--esp-transition);
}

.esp-drawer__cat-card:hover {
    background: var(--esp-bg-light);
    transform: translateY(-3px);
}

.esp-drawer__cat-img {
    width: 120px;
    height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--esp-white);
    border: 1px solid var(--esp-border);
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 0.75rem;
    position: relative; /* For skeleton positioning */
    padding: 0.5rem;
    transition: box-shadow var(--esp-transition), border-color var(--esp-transition);
}

.esp-drawer__cat-card:hover .esp-drawer__cat-img {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
    border-color: var(--esp-primary);
}

.esp-drawer__cat-img img {
    max-width: 100px;
    max-height: 100px;
    object-fit: contain;
}

.esp-drawer__cat-name {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--esp-text);
    line-height: 1.3;
}

.esp-drawer__cat-card:hover .esp-drawer__cat-name {
    color: var(--esp-primary-dark);
}

.esp-drawer__cat-arrow {
    color: var(--esp-primary-dark);
    font-size: 0.75rem;
    margin-top: 0.375rem;
}

/* Loading State - Desktop Skeleton Grid */
.esp-drawer__loading {
    display: block;
    padding: 1rem;
    flex: 1;
}

.esp-drawer__skeleton-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 1rem;
}

/* Fallback spinner (not used by default, but kept for compatibility) */
.esp-drawer__spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--esp-bg-light);
    border-top-color: var(--esp-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Empty State */
.esp-drawer__empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 200px;
    text-align: center;
    color: var(--esp-text-light);
}

.esp-drawer__shop-link {
    margin-top: 1rem;
    padding: 0.625rem 1.25rem;
    background: var(--esp-primary);
    color: var(--esp-black);
    border-radius: 0.375rem;
    font-weight: 600;
    transition: background-color var(--esp-transition);
}

.esp-drawer__shop-link:hover {
    background: var(--esp-primary-dark);
}

/* Promo Panel - Hidden by default, drawer starts with just category list */
.esp-drawer__promo {
    display: none;
}

.esp-drawer__promo-content {
    text-align: center;
    max-width: 450px;
}

.esp-drawer__promo-content h3 {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--esp-navy);
    margin: 0 0 1rem 0;
}

.esp-drawer__promo-content p {
    color: var(--esp-text-light);
    font-size: 1rem;
    margin: 0 0 2rem 0;
}

.esp-drawer__promo-links {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

.esp-drawer__promo-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.875rem 1.5rem;
    background: var(--esp-primary);
    color: var(--esp-black);
    border-radius: 0.375rem;
    font-weight: 600;
    font-size: 0.9375rem;
    transition: background-color var(--esp-transition), transform var(--esp-transition);
}

.esp-drawer__promo-link:hover {
    background: var(--esp-primary-dark);
    transform: translateY(-2px);
}

/* ============================================
   Hero Section - Uses homepage.css base styles
   Only add drawer-specific overrides here
   ============================================ */

/* ============================================
   Main Content
   ============================================ */
.esp-main {
    padding: 3rem 0;
}

/* Section Titles */
.esp-section-title {
    font-size: 2rem;
    font-weight: 700;
    color: var(--esp-navy);
    text-align: center;
    margin: 0 0 0.5rem 0;
}

.esp-section-subtitle {
    font-size: 1rem;
    color: var(--esp-text-light);
    text-align: center;
    margin: 0 0 2rem 0;
}

/* Featured Categories Grid */
.esp-featured-cats {
    margin-bottom: 4rem;
}

.esp-cat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1.5rem;
    max-width: 1000px;
    margin: 0 auto;
}

.esp-cat-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 1.5rem 1rem;
    background: var(--esp-white);
    border: 1px solid var(--esp-border);
    border-radius: 0.75rem;
    transition: all var(--esp-transition);
}

.esp-cat-card:hover {
    border-color: var(--esp-primary);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
    transform: translateY(-4px);
}

.esp-cat-card img {
    width: 100px !important;
    height: 100px !important;
    max-width: 100px !important;
    max-height: 100px !important;
    object-fit: contain !important;
    margin-bottom: 1rem;
}

.esp-cat-card span {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--esp-text);
}

.esp-cat-card:hover span {
    color: var(--esp-primary-dark);
}

/* Demo Info Section */
.esp-demo-section {
    background: var(--esp-bg-light);
    padding: 3rem 2rem;
    border-radius: 1rem;
}

.esp-demo-info h2 {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--esp-navy);
    text-align: center;
    margin: 0 0 2rem 0;
}

.esp-demo-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.5rem;
}

.esp-demo-feature {
    text-align: center;
    padding: 1.5rem;
    background: var(--esp-white);
    border-radius: 0.75rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.esp-demo-feature i {
    font-size: 2rem;
    color: var(--esp-primary);
    margin-bottom: 1rem;
}

.esp-demo-feature h3 {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--esp-text);
    margin: 0 0 0.5rem 0;
}

.esp-demo-feature p {
    font-size: 0.875rem;
    color: var(--esp-text-light);
    margin: 0;
    line-height: 1.5;
}

/* ============================================
   Footer
   ============================================

   NOTE: Footer styles are inherited from homepage.css
   This file only contains demo-specific overrides.

   Inherited from homepage.css:
   - .esp-footer, .esp-footer__grid, .esp-footer__col
   - .esp-footer__logo, .esp-footer__heading
   - .esp-footer__list, .esp-footer__contact
   - .esp-footer__copyright, .esp-footer-cta
   ============================================ */

/* Demo-specific footer note */
.esp-footer__demo-note {
    color: var(--esp-primary) !important;
    font-weight: 600;
}

.esp-footer__demo-note i {
    margin-right: 0.375rem;
}

/* ============================================
   Responsive Adjustments for Drawer
   ============================================ */
@media (max-width: 1023px) {
    .esp-drawer__first-levels {
        width: 280px;
        min-width: 280px;
    }

    .esp-drawer__grid {
        grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
        gap: 1rem;
    }

    .esp-drawer__cat-img {
        width: 100px;
        height: 100px;
    }

    .esp-drawer__cat-img img {
        max-width: 80px;
        max-height: 80px;
    }
}

@media (max-width: 767px) {
    /* Mobile: Full-width drawer with accordion-style subcategories */
    .esp-category-drawer {
        flex-direction: column;
        background: var(--esp-bg-light);
    }

    .esp-drawer__first-levels {
        width: 100%;
        min-width: 100%;
        max-width: 100%;
        max-height: none;
        border-right: none;
        overflow-y: auto;
    }

    /* Hide the right panel on mobile - subcategories appear inline */
    .esp-drawer__second-levels {
        display: none !important;
    }

    .esp-drawer__promo {
        display: none !important;
    }

    /* Mobile accordion subcategories - appear under each category */
    .esp-drawer__mobile-subcats {
        display: none;
        background: var(--esp-white);
        border-top: 1px solid var(--esp-border);
        padding: 0.75rem;
        max-height: 300px;
        overflow-y: auto;
    }

    .esp-drawer__first-item.is-expanded .esp-drawer__mobile-subcats {
        display: block;
    }

    .esp-drawer__mobile-grid {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 0.5rem;
    }

    .esp-drawer__mobile-subcat {
        display: flex;
        align-items: center;
        gap: 0.5rem;
        padding: 0.5rem;
        background: var(--esp-bg-light);
        border-radius: 0.25rem;
        text-decoration: none;
        transition: background-color var(--esp-transition);
        /* iOS touch optimization - removes 300ms tap delay */
        touch-action: manipulation;
        -webkit-tap-highlight-color: rgba(230, 172, 44, 0.3);
        cursor: pointer;
        /* Ensure link receives its own click events, not intercepted by parent */
        pointer-events: auto;
        position: relative;
        z-index: 10;
    }

    .esp-drawer__mobile-subcat:hover {
        background: var(--esp-primary-light);
    }

    .esp-drawer__mobile-subcat-img {
        width: 40px;
        height: 40px;
        flex-shrink: 0;
        background: var(--esp-white);
        border: 1px solid var(--esp-border);
        border-radius: 4px;
        overflow: hidden;
        display: flex;
        align-items: center;
        justify-content: center;
        position: relative; /* For skeleton positioning */
    }

    .esp-drawer__mobile-subcat-img img {
        max-width: 32px;
        max-height: 32px;
        object-fit: contain;
    }

    .esp-drawer__mobile-subcat-name {
        font-size: 0.75rem;
        font-weight: 500;
        color: var(--esp-text);
        line-height: 1.2;
        flex: 1;
    }

    /* Expanded state - highlight the active category (override hover states) */
    .esp-drawer__first-item.is-expanded > a {
        background: var(--esp-primary) !important;
        color: var(--esp-black) !important;
    }

    .esp-drawer__first-item.is-expanded > a i {
        color: var(--esp-black) !important;
        transform: rotate(90deg);
    }

    .esp-drawer__first-item > a i {
        transition: transform 0.2s ease;
    }

    /* Mobile loading state - skeleton cards */
    .esp-drawer__mobile-loading {
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 1rem;
    }

    /* Fallback spinner (kept for compatibility) */
    .esp-drawer__mobile-spinner {
        width: 24px;
        height: 24px;
        border: 3px solid var(--esp-bg-light);
        border-top-color: var(--esp-primary);
        border-radius: 50%;
        animation: spin 0.8s linear infinite;
    }

    /* Mobile skeleton grid uses styles from loading-states.css */

    /* View all link for mobile */
    .esp-drawer__mobile-view-all {
        display: block;
        text-align: center;
        padding: 0.5rem;
        margin-top: 0.5rem;
        background: var(--esp-primary);
        color: var(--esp-black);
        font-size: 0.75rem;
        font-weight: 600;
        border-radius: 0.25rem;
        text-decoration: none;
        /* iOS touch optimization - removes 300ms tap delay */
        touch-action: manipulation;
        -webkit-tap-highlight-color: rgba(230, 172, 44, 0.3);
        cursor: pointer;
        /* Ensure link receives its own click events, not intercepted by parent */
        pointer-events: auto;
        position: relative;
        z-index: 10;
    }

    .esp-drawer__mobile-view-all:hover {
        background: var(--esp-primary-dark);
    }
}

/* ============================================
   Category Groups
   ============================================ */
.esp-drawer__group-header {
    background: #eef2f7;
    color: var(--esp-navy);
    padding: 0.75rem 1.25rem;
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--esp-border);
    border-top: 1px solid var(--esp-border);
    position: sticky;
    top: 0;
    z-index: 5;
}

/* Remove top border if it's the very first element (though sticky might need top border if scrolling) */
.esp-drawer__first-levels .esp-drawer__group-header:first-child {
    border-top: none;
}
