/* ==========================================================================
   MODERN HEADER COMPONENT
   ========================================================================== */

/* Header Container */
.main-header {
    position: sticky;
    top: 0;
    z-index: 1200;
    /* Highest - always on top */
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    height: 80px;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.05);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Scrolled state */
.main-header.scrolled {
    background: rgba(255, 255, 255, 0.98);
    height: 70px;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
}

.header-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 40px;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 32px;
}

/* Header Left - Logo */
.header-left {
    flex-shrink: 0;
}

/* Ensure header logo styles override any other .logo styles */
.main-header .logo,
.header-container .logo {
    font-size: 20px;
    font-weight: 700;
    color: #5B6EF5;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: color 0.3s ease;
    background: none !important;
    -webkit-background-clip: unset !important;
    background-clip: unset !important;
    -webkit-text-fill-color: unset !important;
}

.main-header .logo:hover,
.header-container .logo:hover {
    color: #4C5FD5;
}

.logo-icon {
    width: 32px;
    height: 32px;
    object-fit: contain;
    display: block;
    flex-shrink: 0;
}

/* Header Navigation */
.header-nav {
    display: flex;
    align-items: center;
    gap: 40px;
    flex: 1;
    justify-content: center;
}

/* Ensure header nav-link styles override any other nav-link styles */
.main-header .nav-link,
.header-nav .nav-link {
    font-size: 15px;
    font-weight: 500;
    color: #4B5563;
    text-decoration: none;
    position: relative;
    transition: color 0.3s ease;
    white-space: nowrap;
}

.main-header .nav-link:hover,
.header-nav .nav-link:hover {
    color: #2563EB;
}

.main-header .nav-link.active,
.header-nav .nav-link.active {
    color: #2563EB;
    font-weight: 600;
}

.nav-link::after {
    content: '';
    position: absolute;
    bottom: -4px;
    left: 0;
    width: 0;
    height: 2px;
    background: #2563EB;
    transition: width 0.3s ease;
}

.nav-link:hover::after,
.nav-link.active::after {
    width: 100%;
}

/* Vendor CTA Link in Header */
.vendor-cta-link {
    color: #667eea;
    font-weight: 600;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.vendor-cta-link:hover {
    color: #764ba2;
    transform: translateY(-1px);
}

.vendor-cta-link i {
    font-size: 14px;
}

.vendor-cta-link.active {
    color: #667eea;
}

/* Wishlist nav link */
.wishlist-nav-link {
    display: flex;
    align-items: center;
    gap: 6px;
}

.wishlist-nav-link .wishlist-text {
    display: inline-block;
}

.wishlist-badge {
    background-color: #5b6ef5;
    color: #fff;
    border-radius: 50%;
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    line-height: 1;
    flex-shrink: 0;
}

/* Header Right - User Section */
.header-right {
    display: flex;
    align-items: center;
    gap: 20px;
    flex-shrink: 0;
}

.user-email {
    font-size: 14px;
    color: #6B7280;
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.user-email-icon {
    font-size: 16px;
}

.btn-dashboard,
.btn-logout {
    font-size: 14px;
    font-weight: 500;
    padding: 10px 20px;
    border-radius: 8px;
    text-decoration: none;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.btn-dashboard {
    background: #5B6EF5;
    color: white;
}

.btn-dashboard:hover {
    background: #4C5FD5;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(91, 110, 245, 0.3);
}

.btn-logout {
    background: transparent;
    color: #6B7280;
    border: 1px solid #E5E7EB;
}

.btn-logout:hover {
    background: #F9FAFB;
    color: #374151;
    border-color: #D1D5DB;
}

.btn-login {
    background: #5B6EF5;
    color: white;
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.3s ease;
}

.btn-login:hover {
    background: #4C5FD5;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(91, 110, 245, 0.3);
}

/* Mobile Menu Toggle Button */
.mobile-menu-toggle {
    display: none;
    flex-direction: column;
    justify-content: space-around;
    width: 28px;
    height: 28px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0;
    z-index: 1001;
    transition: opacity 0.3s ease;
}

.mobile-menu-toggle span {
    width: 100%;
    height: 2px;
    background: #1F2937;
    border-radius: 2px;
    transition: all 0.3s ease;
}

/* Completely remove hamburger from layout when menu is open
   (Previously used opacity: 0 which left white space)
   Updated: 2026-01-23 - Cache busting fix */
.mobile-menu-toggle.active {
    display: none !important;
}

/* REMOVED - Hamburger transform to X - No longer needed since hamburger is hidden when menu open */
/*
.mobile-menu-toggle.active span:nth-child(1) {
    transform: rotate(45deg) translate(8px, 8px);
}

.mobile-menu-toggle.active span:nth-child(2) {
    opacity: 0;
}

.mobile-menu-toggle.active span:nth-child(3) {
    transform: rotate(-45deg) translate(8px, -8px);
}
*/

/* Mobile Menu */
.mobile-menu {
    display: none;
    position: fixed;
    top: 70px;
    /* Start below header */
    left: 0;
    right: 0;
    bottom: 0;
    height: calc(100vh - 70px);
    /* Full viewport height minus header */
    min-height: calc(100vh - 70px);
    /* Ensure minimum height */
    max-height: calc(100vh - 70px);
    /* Prevent overflow */
    background: white;
    z-index: 1100;
    /* Above everything except header */
    padding: 32px 24px 24px;
    /* Reduced top padding, bottom padding for scroll */
    overflow-y: auto;
    overflow-x: hidden;
    /* Prevent horizontal scroll */
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    /* Add shadow for depth */
    box-sizing: border-box;
    /* Include padding in height calculation */
}

.mobile-menu.active {
    transform: translateX(0);
}

/* Overlay behind mobile menu */
.mobile-menu-overlay {
    display: none;
    position: fixed;
    top: 70px;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1099;
    /* Below menu, above content */
    opacity: 0;
    transition: opacity 0.3s ease;
}

.mobile-menu-overlay.active {
    display: block;
    opacity: 1;
}

.mobile-menu-close {
    position: absolute;
    top: 16px;
    /* Adjusted for new menu top position */
    right: 20px;
    width: 44px;
    height: 44px;
    background: #F3F4F6;
    border: none;
    border-radius: 50%;
    font-size: 20px;
    color: #1F2937;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    z-index: 1101;
    /* Above menu content */
}

.mobile-menu-close i {
    font-size: 20px;
    line-height: 1;
}

.mobile-menu-close:hover {
    background: #E5E7EB;
    transform: scale(1.05);
}

.mobile-nav {
    display: flex;
    flex-direction: column;
    gap: 15px;
    padding: 10px 0;
}

.mobile-nav-link {
    font-size: 18px;
    font-weight: 500;
    color: #1F2937;
    text-decoration: none;
    padding: 10px 20px;
    margin-bottom: 0;
    border-bottom: 1px solid #E5E7EB;
    transition: color 0.3s ease;
}

.mobile-nav-link.wishlist-nav-link {
    display: flex;
    align-items: center;
    gap: 8px;
}

.mobile-nav-link:hover,
.mobile-nav-link.active {
    color: #2563EB;
}

/* Small gap before Login/Register section */
.mobile-nav .vendor-cta-link {
    margin-bottom: 5px;
}

/* CRITICAL: Remove gap between Become a Vendor and Login/Register */
.mobile-user-section {
    margin-top: 0 !important;
    margin-bottom: 10px;
    padding: 5px 20px;
    border-top: 2px solid #E5E7EB;
}

.mobile-user-email {
    font-size: 16px;
    color: #6B7280;
    margin-bottom: 24px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.mobile-user-actions {
    display: flex;
    flex-direction: row;
    gap: 10px;
    margin: 0;
}

.mobile-user-actions .btn-dashboard,
.mobile-user-actions .btn-logout {
    flex: 1;
    width: auto;
    padding: 10px 16px;
    text-align: center;
    justify-content: center;
}

.mobile-user-actions .mobile-nav-link,
.mobile-user-actions .btn-login {
    flex: 1;
    padding: 10px 16px;
    margin: 0;
    text-align: center;
}

/* ==========================================================================
   RESPONSIVE DESIGN
   ========================================================================== */

/* Tablet */
@media (max-width: 992px) {
    .header-container {
        padding: 0 24px;
        gap: 24px;
    }

    .header-nav {
        gap: 32px;
    }

    .nav-link {
        font-size: 14px;
    }
}

/* Mobile */
@media (max-width: 768px) {

    /* Ensure body/html don't add padding/margin to header */
    body {
        margin-left: 0 !important;
        margin-right: 0 !important;
        padding-left: 0 !important;
        padding-right: 0 !important;
    }

    html {
        margin-left: 0 !important;
        margin-right: 0 !important;
        padding-left: 0 !important;
        padding-right: 0 !important;
    }

    .main-header {
        height: 70px;
        margin-left: 0 !important;
        /* Remove any left margin */
        margin-right: 0 !important;
        /* Remove any right margin */
        padding-left: 0 !important;
        /* Remove any left padding */
        padding-right: 0 !important;
        /* Remove any right padding */
        width: 100% !important;
        /* Full width */
        max-width: 100% !important;
        /* Full width */
        left: 0 !important;
        /* Ensure starts from left edge */
        right: 0 !important;
        /* Ensure extends to right edge */
    }

    .header-container {
        padding: 0 20px;
        gap: 16px;
        justify-content: space-between !important;
        /* Space between logo and hamburger */
        align-items: center !important;
        /* Vertically center items */
        max-width: 100% !important;
        /* Full width on mobile */
        margin-left: 0 !important;
        /* Remove auto margin */
        margin-right: 0 !important;
        /* Remove auto margin */
        width: 100% !important;
        /* Full width */
    }

    .logo {
        font-size: 20px;
    }

    /* Hide desktop nav and user section */
    .header-nav,
    .header-right {
        display: none;
    }

    /* Hide language switcher on mobile (it's inside header-right) */
    .language-switcher {
        display: none;
    }

    /* Show mobile menu toggle - Force visibility */
    .mobile-menu-toggle {
        display: flex !important;
        visibility: visible !important;
        opacity: 1 !important;
        margin-left: auto;
        /* Push hamburger to the right */
        position: relative;
        z-index: 1002;
        width: 28px !important;
        height: 28px !important;
    }

    /* Hide hamburger when menu is open (override display: flex) */
    .mobile-menu-toggle.active {
        display: none !important;
        visibility: hidden !important;
        opacity: 0 !important;
        margin-left: 0 !important;
        /* Remove margin when hidden to prevent white space */
    }

    /* Ensure hamburger is visible when menu is closed */
    .mobile-menu-toggle:not(.active) {
        display: flex !important;
        visibility: visible !important;
        opacity: 1 !important;
    }

    /* Ensure language switcher is hidden on mobile */
    .header-right .language-switcher {
        display: none !important;
    }

    /* Show mobile menu */
    .mobile-menu {
        display: block;
    }

    /* Prevent white space when hamburger is hidden
       Container only takes space needed for logo, not full width */
    .header-left {
        flex-shrink: 0;
    }

    /* When menu is open and hamburger is hidden, ensure container doesn't leave white space */
    body.mobile-menu-open .header-container {
        justify-content: flex-start !important;
        max-width: 100% !important;
        /* Remove max-width constraint */
        margin-left: 0 !important;
        /* Remove auto margin */
        margin-right: 0 !important;
        /* Remove auto margin */
        width: 100% !important;
        /* Full width */
    }
}

/* Small Mobile */
@media (max-width: 480px) {
    .header-container {
        padding: 0 16px;
    }

    .logo {
        font-size: 18px;
    }

    .mobile-menu {
        padding: 60px 24px 24px;
        /* Reduced top padding on small screens */
        height: calc(100vh - 70px);
        /* Ensure full height */
        min-height: calc(100vh - 70px);
        max-height: calc(100vh - 70px);
    }

    .mobile-nav-link {
        font-size: 16px;
    }
}

/* ==========================================================================
   ACCESSIBILITY — Focus styles
   Outline shown ONLY on keyboard navigation (:focus-visible).
   Mouse/touch clicks produce no visible outline anywhere in the header.
   ========================================================================== */

/* Remove outline on mouse/touch for ALL header interactive elements */
.logo:focus,
.btn-dashboard:focus,
.btn-logout:focus,
.btn-login:focus,
.mobile-menu-toggle:focus,
.mobile-menu-close:focus,
.mobile-nav-link:focus,
.mobile-menu-language-buttons .lang-btn:focus,
.main-header .nav-link:focus,
.header-nav .nav-link:focus {
    outline: none;
}

/* Show outline only when navigating via keyboard (:focus-visible) */
.logo:focus-visible,
.btn-dashboard:focus-visible,
.btn-logout:focus-visible,
.btn-login:focus-visible,
.mobile-menu-toggle:focus-visible,
.mobile-menu-close:focus-visible,
.mobile-nav-link:focus-visible,
.mobile-menu-language-buttons .lang-btn:focus-visible {
    outline: 3px solid #2563EB;
    outline-offset: 2px;
}


/* Skip link for screen readers */
.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: #1F2937;
    color: white;
    padding: 8px 16px;
    text-decoration: none;
    z-index: 10000;
}

.skip-link:focus {
    top: 0;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {

    .main-header,
    .nav-link,
    .btn-dashboard,
    .btn-logout,
    .btn-login,
    .mobile-menu-toggle span,
    .mobile-menu {
        transition: none;
    }
}

/* ==========================================================================
   MOBILE LANGUAGE SWITCHER
   ========================================================================== */

/* Language section container - compact for single-screen fit */
.mobile-menu-language {
    padding: 10px 20px;
    background-color: #f9fafb;
    border-radius: 8px;
    margin: 0 10px 5px 10px;
}

/* Language title with icon */
.mobile-menu-language-title {
    font-size: 13px;
    font-weight: 600;
    color: #6b7280;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.mobile-menu-language-title i {
    color: #3b82f6;
    font-size: 16px;
}

/* Language buttons container */
.mobile-menu-language-buttons {
    display: flex;
    gap: 5px;
    justify-content: space-between;
}

/* Individual language button - touch-friendly (min 44px) */
.mobile-menu-language-buttons .lang-btn {
    flex: 1;
    min-height: 44px;
    padding: 10px 6px;
    text-align: center;
    background-color: white;
    border: 1.5px solid #d1d5db;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    color: #374151;
    text-decoration: none;
    transition: all 0.2s ease;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mobile-menu-language-buttons .lang-btn:hover {
    background-color: #eff6ff;
    border-color: #3b82f6;
    color: #3b82f6;
}

.mobile-menu-language-buttons .lang-btn.active {
    background-color: #3b82f6;
    color: white;
    border-color: #3b82f6;
    box-shadow: 0 2px 4px rgba(59, 130, 246, 0.2);
}

/* Small screens optimization */
@media (max-width: 360px) {
    .mobile-menu-language-buttons .lang-btn {
        font-size: 12px;
        padding: 8px 4px;
    }
}

/* Hide on desktop - desktop has its own language switcher */
@media (min-width: 768px) {
    .mobile-menu-language {
        display: none;
    }
}