/**
 * Header Styles - Clean Rebuild
 * 
 * Fresh Flexbox layout with no overlapping issues
 * 
 * @package Sokna
 * @since 1.0.0
 */

/* ============================================
   GLOBAL RESET - Zero Top Gap
   ============================================ */
html, body {
    margin-top: 0 !important;
    padding-top: 0 !important;
}

/* ============================================
   HEADER CONTAINER - Premium Glassmorphism
   ============================================ */
/* Ensure header + menu always above hero and any full-width content (stacking context) */
.site-header {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    position: sticky;
    top: 0;
    width: 100%;
    height: 72px;
    z-index: 999999 !important;
    isolation: isolate;
    display: flex;
    align-items: center;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    pointer-events: auto !important;
    transition: box-shadow 0.3s ease, background 0.3s ease;
}

.header-container {
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    pointer-events: auto !important;
}

.header-container a,
.header-container button {
    pointer-events: auto !important;
}

/* ============================================
   HEADER LEFT - Logo (sharp, linked, SEO alt)
   ============================================ */
.header-left {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
}

.header-logo-link {
    display: flex;
    align-items: center;
}

.header-logo-img {
    max-height: 44px;
    height: auto;
    width: auto;
    object-fit: contain;
    image-rendering: -webkit-optimize-contrast;
}

.header-left .site-title {
    font-size: 18px;
    font-weight: 600;
    color: #222;
    text-decoration: none;
}

.header-left a {
    pointer-events: auto !important;
    cursor: pointer !important;
    position: relative;
    z-index: 999999 !important;
}

/* ============================================
   HEADER CENTER - Navigation
   ============================================ */
.header-center {
    flex: 0 1 auto;
    display: none;
    justify-content: center;
    align-items: center;
    max-width: fit-content;
    margin: 0 auto;
    position: relative;
}

@media (min-width: 1024px) {
    .header-center {
        display: flex;
    }
}

.nav-menu {
    display: flex;
    align-items: center;
    gap: 20px;
    list-style: none;
    margin: 0;
    padding: 0;
}

.nav-menu li {
    position: relative;
}

.nav-menu a {
    display: flex;
    align-items: center;
    padding: 8px 16px;
    font-size: 14px;
    font-weight: 500;
    color: #333;
    text-decoration: none;
    pointer-events: auto !important;
    cursor: pointer !important;
    position: relative;
    z-index: 999999 !important;
    font-family: 'Poppins', 'Inter', system-ui, sans-serif;
}

.nav-menu a:hover {
    color: #0061DF;
}

.nav-menu li.current-menu-item > a,
.nav-menu a.active {
    color: #0061DF;
    font-weight: 600;
}

.nav-menu a::after {
    content: '';
    position: absolute;
    bottom: 4px;
    left: 50%;
    transform: translateX(-50%);
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: transparent;
}

.nav-menu li.current-menu-item > a::after,
.nav-menu a.active::after {
    background: #0061DF;
}

/* Legal menu (À propos & CGU) – same style, optional push to end */
.nav-menu-legal {
    margin-inline-start: auto;
}

/* ============================================
   HEADER RIGHT - Actions
   ============================================ */
.header-right {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 12px;
    position: relative;
    z-index: 999999 !important;
    pointer-events: auto !important;
}

/* Language Switcher */
.header-language {
    position: relative;
    z-index: 999999 !important;
    pointer-events: auto !important;
}

.header-language .header-dropdown-toggle {
    display: flex;
    align-items: center;
    padding: 6px 8px;
    background: transparent;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 8px;
    cursor: pointer !important;
    pointer-events: auto !important;
    position: relative;
    z-index: 999999 !important;
}

.header-language .flag-icon {
    display: inline-flex;
    align-items: center;
}

.header-language .header-dropdown-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 180px;
    background: #ffffff;
    border: 1px solid rgba(0, 0, 0, 0.06);
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: all 0.3s ease;
    z-index: 999999 !important;
    padding: 8px 0;
    list-style: none;
    margin: 0;
    pointer-events: none;
}

.header-language .header-dropdown-menu.is-open,
.header-language.is-active .header-dropdown-menu {
    opacity: 1 !important;
    visibility: visible !important;
    transform: translateY(0) !important;
    pointer-events: auto !important;
}

.header-language .dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    font-size: 14px;
    color: #000000;
    text-decoration: none;
    pointer-events: auto !important;
    cursor: pointer !important;
    position: relative;
    z-index: 999999 !important;
}

.header-language .dropdown-item:hover {
    background-color: #f5f5f5;
}

/* Currency Switcher */
.header-currency {
    position: relative;
    z-index: 999999 !important;
    pointer-events: auto !important;
}

.header-currency .header-dropdown-toggle {
    display: flex;
    align-items: center;
    padding: 6px 8px;
    background: transparent;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 8px;
    cursor: pointer !important;
    pointer-events: auto !important;
    position: relative;
    z-index: 999999 !important;
}

.header-currency .currency-display {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 13px;
    color: #333;
}

.header-currency .currency-symbol {
    font-weight: 500;
}

.header-currency .currency-code {
    font-size: 11px;
    opacity: 0.8;
}

.header-currency .header-dropdown-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 140px;
    background: #ffffff;
    border: 1px solid rgba(0, 0, 0, 0.06);
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: all 0.3s ease;
    z-index: 999999 !important;
    padding: 8px 0;
    list-style: none;
    margin: 0;
    pointer-events: none;
}

.header-currency .header-dropdown-menu.is-open,
.header-currency.is-active .header-dropdown-menu {
    opacity: 1 !important;
    visibility: visible !important;
    transform: translateY(0) !important;
    pointer-events: auto !important;
}

.header-currency .dropdown-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 16px;
    font-size: 14px;
    color: #000000;
    text-decoration: none;
    pointer-events: auto !important;
    cursor: pointer !important;
    position: relative;
    z-index: 999999 !important;
}

.header-currency .dropdown-item:hover {
    background-color: #f5f5f5;
}

.header-currency .dropdown-item.active {
    background-color: #f0f0f0;
    font-weight: 500;
}

.header-currency .dropdown-item .currency-symbol {
    font-weight: 500;
    min-width: 24px;
}

.header-currency .dropdown-item .currency-code {
    font-size: 13px;
    color: #666666;
}

/* Account Dropdown */
.header-account {
    position: relative;
    z-index: 999999 !important;
    pointer-events: auto !important;
}

.header-account .header-dropdown-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    background: transparent;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 8px;
    cursor: pointer;
    pointer-events: auto !important;
    position: relative;
    z-index: 999999 !important;
}

/* Premium profile image: Houzez custom picture or Gravatar */
.header-account .header-dropdown-toggle img,
.header-account .header-avatar-img,
.header-user-avatar {
    width: 35px;
    height: 35px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid #f0f0f0;
}

.header-account .header-avatar-placeholder {
    width: 35px;
    height: 35px;
    border-radius: 50%;
    background: #f0f0f0;
    border: 2px solid #f0f0f0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.header-account .header-avatar-placeholder svg {
    width: 20px;
    height: 20px;
    color: #999;
}

.header-account .dropdown-arrow,
.header-language .header-dropdown-toggle .flag-icon {
    color: #333;
}

.header-account .header-dropdown-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 220px;
    background: #ffffff;
    border: 1px solid rgba(0, 0, 0, 0.06);
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: all 0.3s ease;
    z-index: 999999 !important;
    padding: 8px 0;
    list-style: none;
    margin: 0;
    pointer-events: none;
}

.header-account .header-dropdown-menu.is-open,
.header-account.is-active .header-dropdown-menu {
    opacity: 1 !important;
    visibility: visible !important;
    transform: translateY(0) !important;
    pointer-events: auto !important;
}

.header-account .dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    font-size: 14px;
    color: #000000;
    text-decoration: none;
    pointer-events: auto !important;
    cursor: pointer !important;
    position: relative;
    z-index: 999999 !important;
}

.header-account .dropdown-item svg {
    flex-shrink: 0;
    width: 16px;
    height: 16px;
    color: #666666;
}

.header-account .dropdown-item:hover {
    background-color: #f5f5f5;
}

.header-account .dropdown-item.active {
    color: #0061DF;
    font-weight: 600;
    background-color: rgba(0, 97, 223, 0.08);
}

.header-account .dropdown-item.active svg {
    color: #0061DF;
}

/* Dropdown Sections */
.header-account .dropdown-section {
    padding: 0;
}

.header-account .dropdown-section-divider {
    border-top: 1px solid rgba(0, 0, 0, 0.1);
    margin-top: 8px;
    padding-top: 12px;
}

.header-account .dropdown-section-title {
    padding: 8px 16px 6px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #999999;
}

/* Currency Selector Inside Account Dropdown */
.header-account .currency-selector {
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: center;
    gap: 15px;
    padding: 12px 16px 8px;
}

.header-account .currency-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 10px 14px;
    font-size: 13px;
    color: #333;
    text-decoration: none;
    border-radius: 10px;
    border: 1px solid rgba(0, 0, 0, 0.08);
    background: linear-gradient(180deg, #fafafa 0%, #f5f5f5 100%);
    pointer-events: auto !important;
    cursor: pointer !important;
    position: relative;
    z-index: 999999 !important;
    transition: all 0.25s ease;
    min-width: 56px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.header-account .currency-option:hover {
    background: linear-gradient(180deg, #f0f0f0 0%, #e8e8e8 100%);
    border-color: rgba(0, 0, 0, 0.12);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.header-account .currency-option.active {
    background: linear-gradient(180deg, #0061DF 0%, #0052c2 100%);
    border-color: #0061DF;
    color: #ffffff;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(0, 97, 223, 0.35);
}

.header-account .currency-option.active .currency-symbol,
.header-account .currency-option.active .currency-code {
    color: #ffffff;
}

.header-account .currency-option .currency-symbol {
    font-weight: 600;
    font-size: 16px;
    line-height: 1;
    color: #000000;
    transition: color 0.2s ease;
}

.header-account .currency-option.active .currency-symbol {
    color: #ffffff;
}

.header-account .currency-option .currency-code {
    font-size: 11px;
    color: #666666;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    transition: color 0.2s ease;
}

.header-account .currency-option.active .currency-code {
    color: rgba(255, 255, 255, 0.9);
}

/* Login Link */
.header-login {
    display: flex;
    align-items: center;
    padding: 6px 10px;
    border: 1px solid rgba(0, 0, 0, 0.12);
    border-radius: 8px;
    color: #333;
    text-decoration: none;
    pointer-events: auto !important;
    cursor: pointer !important;
    position: relative;
    z-index: 999999 !important;
}

.header-login:hover {
    background-color: rgba(0, 0, 0, 0.04);
}

.header-login svg {
    color: #333;
}

/* Post Ad Button */
.header-post-ad {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: #0061DF;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    color: #ffffff;
    text-decoration: none;
    pointer-events: auto !important;
    cursor: pointer !important;
    position: relative;
    z-index: 999999 !important;
    transition: background 0.2s ease;
}

.header-post-ad:hover {
    background: #0052c2;
}

.header-post-ad svg {
    color: #ffffff;
}

/* Mobile Toggle - Clean minimalist hamburger */
.mobile-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px;
    background: transparent;
    border: 1px solid rgba(0, 0, 0, 0.12);
    border-radius: 8px;
    color: #333;
    cursor: pointer;
    pointer-events: auto !important;
    position: relative;
    z-index: 999999 !important;
}

.mobile-toggle:hover {
    background: rgba(0, 0, 0, 0.04);
}

.mobile-toggle svg {
    width: 20px;
    height: 20px;
}

.mobile-toggle:hover {
    background: rgba(0, 0, 0, 0.04);
}

.mobile-toggle svg {
    width: 20px;
    height: 20px;
}

@media (min-width: 1024px) {
    .mobile-toggle {
        display: none;
    }
}

/* ============================================
   MOBILE DRAWER - Hidden on Desktop
   ============================================ */
.mobile-drawer {
    position: fixed;
    top: 0;
    right: -100%;
    width: 320px;
    max-width: 85vw;
    height: 100vh;
    background: #ffffff;
    z-index: 1;
    transition: right 0.3s ease;
    overflow-y: auto;
    display: none !important;
    pointer-events: none !important;
}

@media (max-width: 1023px) {
    .mobile-drawer {
        display: block !important;
    }
}

.mobile-drawer.is-open {
    right: 0;
    pointer-events: auto !important;
}

.drawer-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    display: none !important;
    pointer-events: none !important;
}

/* Safari/iOS FIX: Overlay must be display:none when inactive to prevent blocking touches */
@media (max-width: 1023px) {
    .drawer-overlay:not(.is-active) {
        display: none !important;
    }
    .drawer-overlay.is-active {
        display: block !important;
    }
}

.drawer-overlay.is-active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto !important;
}

.drawer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

.drawer-close {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 8px;
}

.drawer-nav {
    padding: 20px;
}

.drawer-menu {
    list-style: none;
    margin: 0;
    padding: 0;
}

.drawer-menu li {
    margin-bottom: 12px;
}

.drawer-menu a {
    display: block;
    padding: 12px 0;
    font-size: 16px;
    color: #000000;
    text-decoration: none;
}

.drawer-menu a:hover {
    color: #0061DF;
}

/* ============================================
   RTL SUPPORT
   ============================================ */
[dir="rtl"] .header-container {
    direction: rtl;
}

/* RTL: User menu dropdown aligns to the left (standard RTL) */
[dir="rtl"] .header-language .header-dropdown-menu,
[dir="rtl"] .header-account .header-dropdown-menu {
    right: auto;
    left: 0;
}

/* Arabic: premium font for header nav and button (clear, professional) */
[dir="rtl"] .site-header .nav-menu,
[dir="rtl"] .site-header .header-post-ad,
[dir="rtl"] .site-header .header-account .header-dropdown-menu,
[dir="rtl"] .site-header .header-account .header-dropdown-toggle {
    font-family: var(--font-arabic, 'Cairo', 'IBM Plex Sans Arabic', sans-serif);
}

[dir="rtl"] .mobile-drawer {
    right: auto;
    left: -100%;
}

[dir="rtl"] .mobile-drawer.is-open {
    left: 0;
}

/* ============================================
   RESPONSIVE
   ============================================ */
/* Mobile: Logo centered, compact */
@media (max-width: 767px) {
    .header-container {
        padding: 0 15px;
        gap: 12px;
    }
    
    .header-left {
        flex: 1;
        justify-content: flex-start;
    }
    
    .header-logo-img {
        max-height: 36px;
    }
    
    .header-post-ad span {
        display: none;
    }
}

/* Drawer logo - linked, dark on white */
.drawer-logo-link {
    display: flex;
    align-items: center;
}

.drawer-logo-img {
    max-height: 40px;
    height: auto;
    width: auto;
    object-fit: contain;
}

.drawer-logo .site-title {
    font-size: 18px;
    font-weight: 600;
    color: #222;
    text-decoration: none;
}
