/* ==========================================
   MOBILE HEADER - DEDICATED CSS
   Single source for mobile header styling
   Optimized for ALL iOS & Android devices
   ========================================== */

/* CSS Variables */
:root {
    --mh-height: 56px;
    --mh-logo-height: 24px;
    --mh-primary: #0078d4;
    --mh-primary-dark: #005a9e;
    --mh-text: #1e293b;
    --mh-text-light: #64748b;
    --mh-bg: #ffffff;
    --mh-border: #e2e8f0;
    --mh-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    --mh-shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.15);
}

/* Dark Theme Variables */
[data-theme="dark"] {
    --mh-text: #f1f5f9;
    --mh-text-light: #cbd5e1;
    --mh-bg: #1e293b;
    --mh-border: #334155;
    --mh-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    --mh-shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.5);
}

/* ==========================================
   HEADER CONTAINER
   ========================================== */
.modern-mobile-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--mh-height);
    background: var(--mh-bg);
    box-shadow: var(--mh-shadow);
    z-index: 1000;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.modern-mobile-header.scrolled {
    box-shadow: var(--mh-shadow-lg);
}

.modern-mobile-header.hidden {
    transform: translateY(-100%);
}

/* Header Inner Container */
.mobile-header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 100%;
    padding: 0 1rem;
    max-width: 100%;
}

/* ==========================================
   LOGO - LEFT SIDE
   ========================================== */
.mobile-header-logo {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    text-decoration: none;
    z-index: 1001;
    margin-right: auto;
}

.mobile-header-logo img {
    height: var(--mh-logo-height) !important;
    width: auto !important;
    max-width: none !important;
    min-width: auto !important;
    transition: transform 0.3s ease;
}

.mobile-header-logo:active img {
    transform: scale(0.95);
}

/* ==========================================
   HEADER ACTIONS - RIGHT SIDE
   ========================================== */
.mobile-header-actions {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    z-index: 1001;
    margin-left: auto;
}

/* Icon Buttons (Theme + Menu) */
.mobile-header-icon-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: transparent;
    border: none;
    border-radius: 10px;
    color: var(--mh-text);
    font-size: 1.15rem;
    cursor: pointer;
    transition: all 0.3s ease;
    -webkit-tap-highlight-color: transparent;
}

.mobile-header-icon-btn:active {
    background: var(--mh-border);
    transform: scale(0.95);
}

.mobile-header-icon-btn i {
    pointer-events: none;
}

/* ==========================================
   HAMBURGER MENU ICON
   ========================================== */
.mobile-menu-toggle {
    position: relative;
    width: 40px;
    height: 40px;
    background: transparent;
    border: none;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.mobile-menu-toggle-icon {
    position: relative;
    width: 22px;
    height: 2px;
    background: var(--mh-text);
    display: block;
    margin: 0 auto;
    transition: all 0.3s ease;
}

.mobile-menu-toggle-icon::before,
.mobile-menu-toggle-icon::after {
    content: '';
    position: absolute;
    width: 22px;
    height: 2px;
    background: var(--mh-text);
    transition: all 0.3s ease;
}

.mobile-menu-toggle-icon::before {
    top: -7px;
}

.mobile-menu-toggle-icon::after {
    bottom: -7px;
}

.mobile-menu-toggle.active .mobile-menu-toggle-icon {
    background: transparent;
}

.mobile-menu-toggle.active .mobile-menu-toggle-icon::before {
    top: 0;
    transform: rotate(45deg);
}

.mobile-menu-toggle.active .mobile-menu-toggle-icon::after {
    bottom: 0;
    transform: rotate(-45deg);
}

/* ==========================================
   MOBILE MENU
   ========================================== */
.modern-mobile-menu {
    position: fixed;
    top: var(--mh-height);
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--mh-bg);
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    z-index: 999;
}

.modern-mobile-menu.active {
    transform: translateX(0);
}

/* Menu Overlay */
.mobile-menu-overlay {
    position: fixed;
    top: var(--mh-height);
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    z-index: 998;
    backdrop-filter: blur(4px);
}

.mobile-menu-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* Menu List */
.mobile-menu-list {
    list-style: none;
    padding: 1rem 0;
    margin: 0;
}

.mobile-menu-item {
    border-bottom: 1px solid var(--mh-border);
}

/* Menu Links */
.mobile-menu-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    color: var(--mh-text);
    text-decoration: none;
    font-size: 1rem;
    font-weight: 500;
    transition: all 0.3s ease;
    -webkit-tap-highlight-color: transparent;
}

.mobile-menu-link:active {
    background: var(--mh-border);
}

.mobile-menu-link.active {
    color: var(--mh-primary);
    background: rgba(0, 120, 212, 0.05);
}

.mobile-menu-link i {
    margin-right: 0.75rem;
    font-size: 1.1rem;
    width: 24px;
    text-align: center;
}

/* Submenu Arrow */
.mobile-submenu-arrow {
    font-size: 0.875rem;
    transition: transform 0.3s ease;
    color: var(--mh-text-light);
}

.mobile-submenu-arrow.rotated {
    transform: rotate(180deg);
}

/* Submenu */
.mobile-submenu {
    max-height: 0;
    overflow: hidden;
    background: rgba(0, 120, 212, 0.02);
    transition: max-height 0.3s ease;
}

.mobile-submenu.active {
    max-height: 1000px;
}

.mobile-submenu-item {
    border-top: 1px solid var(--mh-border);
}

.mobile-submenu-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.875rem 1.25rem 0.875rem 3.5rem;
    color: var(--mh-text);
    text-decoration: none;
    font-size: 0.95rem;
    font-weight: 500;
    transition: all 0.3s ease;
    -webkit-tap-highlight-color: transparent;
}

.mobile-submenu-link:active {
    background: var(--mh-border);
}

/* Nested Submenu */
.mobile-nested-submenu {
    max-height: 0;
    overflow: hidden;
    background: rgba(0, 120, 212, 0.03);
    transition: max-height 0.3s ease;
}

.mobile-nested-submenu.active {
    max-height: 500px;
}

.mobile-nested-submenu-link {
    padding-left: 5rem;
    font-size: 0.9rem;
}

/* Language Selector */
.mobile-lang-list {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.mobile-lang-link {
    padding: 0.75rem 1.25rem 0.75rem 3.5rem;
}

/* Theme Toggle */
.mobile-theme-toggle {
    display: flex;
    align-items: center;
    padding: 1rem 1.25rem;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.mobile-theme-toggle:active {
    background: var(--mh-border);
}

.mobile-theme-icon {
    margin-right: 0.75rem;
    width: 24px;
    text-align: center;
}

.theme-icon-dark {
    display: block;
}

.theme-icon-light {
    display: none;
}

[data-theme="dark"] .theme-icon-dark {
    display: none;
}

[data-theme="dark"] .theme-icon-light {
    display: block;
}

/* Desktop Link */
.mobile-desktop-link {
    background: linear-gradient(135deg, var(--mh-primary), var(--mh-primary-dark));
    color: white !important;
    font-weight: 600;
    margin: 1rem 1.25rem;
    padding: 1rem 1.25rem !important;
    border-radius: 12px;
    text-align: center;
    box-shadow: 0 4px 12px rgba(0, 120, 212, 0.3);
}

.mobile-desktop-link:active {
    background: var(--mh-primary-dark);
    transform: scale(0.98);
}

/* Content Spacer */
.mobile-content-spacer {
    height: var(--mh-height);
}

/* ==========================================
   RESPONSIVE BREAKPOINTS
   ========================================== */

/* Extra Small Phones (iPhone SE, etc.) */
@media (max-width: 374px) {
    :root {
        --mh-height: 52px;
        --mh-logo-height: 22px;
    }
    
    .mobile-header-icon-btn,
    .mobile-menu-toggle {
        width: 38px;
        height: 38px;
    }
    
    .mobile-menu-toggle-icon,
    .mobile-menu-toggle-icon::before,
    .mobile-menu-toggle-icon::after {
        width: 20px;
    }
}

/* Standard Phones (iPhone 13, 14, most Android) */
@media (min-width: 375px) and (max-width: 767px) {
    /* Default sizes work well here */
}

/* Tablets (iPad, Android tablets) */
@media (min-width: 768px) and (max-width: 1024px) {
    :root {
        --mh-height: 60px;
        --mh-logo-height: 26px;
    }
    
    .mobile-header-inner {
        padding: 0 2rem;
    }
    
    .mobile-header-icon-btn,
    .mobile-menu-toggle {
        width: 44px;
        height: 44px;
    }
}

/* Large Tablets (iPad Pro) */
@media (min-width: 1025px) {
    :root {
        --mh-height: 64px;
        --mh-logo-height: 28px;
    }
}

/* Landscape Orientation */
@media (orientation: landscape) and (max-height: 500px) {
    :root {
        --mh-height: 50px;
        --mh-logo-height: 22px;
    }
    
    .mobile-header-icon-btn,
    .mobile-menu-toggle {
        width: 36px;
        height: 36px;
    }
}

/* Safe Area Support (Notched Devices) */
@supports (padding: max(0px)) {
    .mobile-header-inner {
        padding-left: max(1rem, env(safe-area-inset-left));
        padding-right: max(1rem, env(safe-area-inset-right));
    }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ==========================================
   RTL SUPPORT FOR ARABIC
   ========================================== */

[dir="rtl"] .modern-mobile-header {
    direction: rtl;
    width: 100%;
    max-width: 100vw;
    left: 0;
    right: 0;
    overflow: hidden;
}

[dir="rtl"] .mobile-header-inner {
    flex-direction: row-reverse;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

[dir="rtl"] .mobile-header-logo {
    margin-right: 0;
    margin-left: auto;
}

[dir="rtl"] .mobile-header-actions {
    margin-left: 0;
    margin-right: auto;
    flex-direction: row-reverse;
}

[dir="rtl"] .modern-mobile-menu {
    left: 0;
    right: 0;
    transform: translateX(-100%);
}

[dir="rtl"] .modern-mobile-menu.active {
    transform: translateX(0);
}

[dir="rtl"] .mobile-menu-link {
    flex-direction: row-reverse;
    text-align: right;
}

[dir="rtl"] .mobile-menu-link i {
    margin-right: 0;
    margin-left: 0.75rem;
}

[dir="rtl"] .mobile-submenu-arrow {
    margin-left: 0;
    margin-right: auto;
}

[dir="rtl"] .mobile-submenu-link {
    padding: 0.875rem 3.5rem 0.875rem 1.25rem;
    flex-direction: row-reverse;
    text-align: right;
}

[dir="rtl"] .mobile-nested-submenu-link {
    padding-right: 5rem;
    padding-left: 1.25rem;
}

[dir="rtl"] .mobile-lang-link {
    padding: 0.75rem 3.5rem 0.75rem 1.25rem;
    text-align: right;
}

[dir="rtl"] .mobile-theme-icon {
    margin-right: 0;
    margin-left: 0.75rem;
}

