/* ═══════════════════════════════════════════════════════════════
   STYLES-HEADER.CSS v2  |  Sovereign Architect Header
   Glassmorphism dark navy header matching the V5 footer aesthetic
   ═══════════════════════════════════════════════════════════════ */

/* ─── Design tokens (scoped) ─────────────────────────────────── */
.header {
    --h-bg:               rgba(6, 18, 38, 0.88);
    --h-bg-solid:         #061226;
    --h-blur:             20px;
    --h-border:           rgba(180, 197, 255, 0.08);
    --h-glass-stroke:     rgba(180, 197, 255, 0.14);
    --h-text:             #d7e2ff;
    --h-text-dim:         #c3c6d7;
    --h-text-bright:      #fff;
    --h-primary:          #b4c5ff;
    --h-accent:           #2563eb;
    --h-cta:              #8083ff;
    --h-cta-hover:        #6568e0;
    --h-surface-high:     #2a354a;
    --h-height:           72px;
    --h-height-mobile:    60px;
    --h-radius:           0.65rem;
    --h-font-headline:    'Manrope', sans-serif;
    --h-font-body:        'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* ═══════════════════════════════════════════════════════════════
   1. BASE HEADER (all viewports)
   ═══════════════════════════════════════════════════════════════ */
.header {
    position: sticky !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    z-index: 1000 !important;
    background: var(--h-bg) !important;
    backdrop-filter: blur(var(--h-blur)) !important;
    -webkit-backdrop-filter: blur(var(--h-blur)) !important;
    border-bottom: 1px solid var(--h-border) !important;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2) !important;
    padding: 0 !important;
    margin: 0 !important;
    font-family: var(--h-font-body) !important;
}

.header .container {
    max-width: 1400px !important;
    margin: 0 auto !important;
    padding: 0 2rem !important;
    position: relative !important;
}

.header-content {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    height: var(--h-height) !important;
    gap: 1rem !important;
}

/* ═══════════════════════════════════════════════════════════════
   2. LOGO
   ═══════════════════════════════════════════════════════════════ */
.header .logo {
    flex: 0 0 auto !important;
    order: 1 !important;
}

.header .logo a {
    display: flex !important;
    align-items: center !important;
    gap: 10px !important;
    text-decoration: none !important;
    color: var(--h-text) !important;
}

.header .logo .logo-icon {
    width: 36px !important;
    height: 36px !important;
    border-radius: 8px !important;
    object-fit: contain !important;
    filter: brightness(1.1) !important;
}

.header .logo a span {
    font-family: var(--h-font-headline) !important;
    font-weight: 800 !important;
    font-size: 1.2rem !important;
    letter-spacing: -0.01em !important;
    color: var(--h-text) !important;
    white-space: nowrap !important;
}

/* ═══════════════════════════════════════════════════════════════
   3. DESKTOP NAVIGATION (≥769px)
   ═══════════════════════════════════════════════════════════════ */
@media (min-width: 769px) {
    .header-content {
        gap: 0.75rem !important;
    }

    .main-navigation {
        flex: 1 1 auto !important;
        display: flex !important;
        justify-content: center !important;
        order: 2 !important;
    }

    .nav-menu {
        display: flex !important;
        flex-wrap: nowrap !important;
        gap: 0 !important;
        margin: 0 !important;
        padding: 0 !important;
        list-style: none !important;
        justify-content: center !important;
        align-items: center !important;
    }

    .nav-menu > li {
        position: relative !important;
        list-style: none !important;
    }

    .nav-menu > li > a {
        display: flex !important;
        align-items: center !important;
        gap: 5px !important;
        padding: 0.5rem 0.55rem !important;
        font-family: var(--h-font-body) !important;
        font-weight: 500 !important;
        font-size: 14px !important;
        color: var(--h-text-dim) !important;
        text-decoration: none !important;
        white-space: nowrap !important;
        transition: color 0.2s ease, background 0.2s ease !important;
        border-radius: var(--h-radius) !important;
        position: relative !important;
    }

    .nav-menu > li > a:hover {
        color: var(--h-text) !important;
        background: rgba(180, 197, 255, 0.06) !important;
    }

    .nav-menu > li > a .menu-icon {
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
        width: 16px !important;
        height: 16px !important;
        flex-shrink: 0 !important;
    }

    .nav-menu > li > a .menu-icon svg {
        width: 16px !important;
        height: 16px !important;
        stroke: currentColor !important;
        stroke-width: 1.6 !important;
        fill: none !important;
        color: inherit !important;
    }

    .nav-menu > li > a .chevron {
        font-size: 14px !important;
        opacity: 0.5 !important;
        color: inherit !important;
    }

    .nav-menu > li > a .dropdown-arrow,
    .nav-menu > li > a .menu-arrow {
        display: none !important;
    }

    /* Hide mobile-only elements */
    .menu-close,
    .mobile-menu-toggle,
    .mobile-menu-head,
    .mobile-menu-foot {
        display: none !important;
        opacity: 0 !important;
        pointer-events: none !important;
    }

    /* ─── Desktop Dropdowns ─────────────────────────────────── */
    .nav-submenu {
        display: none !important;
        position: absolute !important;
        top: 100% !important;
        left: 50% !important;
        transform: translateX(-50%) !important;
        min-width: 260px !important;
        background: var(--h-bg-solid) !important;
        backdrop-filter: blur(24px) !important;
        -webkit-backdrop-filter: blur(24px) !important;
        border: 1px solid var(--h-glass-stroke) !important;
        border-radius: var(--h-radius) !important;
        padding: 0.5rem 0 !important;
        margin: 0 !important;
        list-style: none !important;
        box-shadow: 0 20px 40px rgba(0, 74, 198, 0.08),
                    0 4px 12px rgba(0, 0, 0, 0.3) !important;
        z-index: 1001 !important;
        max-height: none !important;
        overflow: visible !important;
        opacity: 0 !important;
        visibility: hidden !important;
        transition: opacity 0.2s ease, visibility 0.2s ease !important;
    }

    .nav-dropdown:hover > .nav-submenu,
    .nav-dropdown:focus-within > .nav-submenu {
        display: block !important;
        opacity: 1 !important;
        visibility: visible !important;
    }

    .nav-submenu li {
        list-style: none !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    .nav-submenu li a {
        display: block !important;
        padding: 0.55rem 1.25rem !important;
        font-family: var(--h-font-body) !important;
        font-weight: 400 !important;
        font-size: 13.5px !important;
        color: var(--h-text-dim) !important;
        text-decoration: none !important;
        transition: color 0.15s ease, background 0.15s ease !important;
        white-space: nowrap !important;
    }

    .nav-submenu li a:hover {
        color: var(--h-text) !important;
        background: rgba(180, 197, 255, 0.06) !important;
    }

    .nav-submenu li a::after {
        content: none !important;
    }

    /* Nested submenu — position relative to the trigger <li>, not the panel.
       Without this, top:0 is relative to the parent .nav-submenu panel,
       placing all nested menus at the panel top regardless of which item is hovered. */
    .nav-submenu .nav-dropdown {
        position: relative !important;
    }

    .nav-submenu .nav-dropdown > .nav-submenu {
        left: 100% !important;
        top: 0 !important;
        transform: none !important;
    }

    .nav-submenu .nav-dropdown:hover > .nav-submenu,
    .nav-submenu .nav-dropdown.nested-active > .nav-submenu {
        display: block !important;
        opacity: 1 !important;
        visibility: visible !important;
    }

    .nav-submenu .nav-dropdown-toggle .dropdown-arrow {
        font-size: 10px !important;
        color: var(--h-text-dim) !important;
        margin-left: 0.5rem !important;
        transition: transform 0.2s ease !important;
    }

    .nav-submenu .nav-dropdown:hover .dropdown-arrow,
    .nav-submenu .nav-dropdown.nested-active .dropdown-arrow {
        transform: rotate(90deg) !important;
    }

    /* ─── Contact info (desktop) ──────────────────────────── */
    .header .contact-info {
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        gap: 0.25rem !important;
        order: 3 !important;
    }

    .header .contact-info .phone {
        display: none !important;
    }

    .header .contact-info .social-icons {
        display: flex !important;
        flex-direction: row !important;
        align-items: center !important;
        gap: 0.5rem !important;
    }

    .header .contact-info .social-icons .whatsapp,
    .header .contact-info .social-icons .telegram {
        display: inline-flex !important;
    }

    .header .contact-info .social-icons a {
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        width: 36px !important;
        height: 36px !important;
        border-radius: 50% !important;
        background: rgba(15, 19, 31, 0.72) !important;
        border: 1px solid var(--h-glass-stroke) !important;
        transition: background 0.2s ease, transform 0.15s ease !important;
    }

    .header .contact-info .social-icons a:hover {
        background: rgba(37, 99, 235, 0.2) !important;
        transform: scale(1.05) !important;
    }

    .header .contact-info .social-icons svg {
        width: 20px !important;
        height: 20px !important;
    }

    .header .contact-info .phone-number-small {
        display: block !important;
        font-family: var(--h-font-body) !important;
        font-size: 11px !important;
        color: var(--h-text-dim) !important;
        white-space: nowrap !important;
        text-align: center !important;
        line-height: 1.3 !important;
        opacity: 0.8 !important;
    }

    /* ─── CTA Button (desktop) ────────────────────────────── */
    .header .header-cta {
        display: inline-flex !important;
        order: 4 !important;
    }

    .header .header-cta a,
    .header .header-cta button {
        display: inline-flex !important;
        align-items: center !important;
        gap: 0.4rem !important;
        padding: 0.5rem 1.4rem !important;
        font-family: var(--h-font-headline) !important;
        font-weight: 700 !important;
        font-size: 13.5px !important;
        color: #fff !important;
        background: var(--h-cta) !important;
        border: none !important;
        border-radius: 50px !important;
        cursor: pointer !important;
        text-decoration: none !important;
        box-shadow: 0 0 20px rgba(128, 131, 255, 0.2) !important;
        transition: background 0.2s ease, transform 0.15s ease, box-shadow 0.2s ease !important;
        white-space: nowrap !important;
    }

    .header .header-cta a:hover,
    .header .header-cta button:hover {
        background: var(--h-cta-hover) !important;
        box-shadow: 0 0 30px rgba(128, 131, 255, 0.35) !important;
        transform: scale(1.02) !important;
    }

    .header .header-cta a:active,
    .header .header-cta button:active {
        transform: scale(0.97) !important;
    }
}

/* ── Hide mobile-only drawer elements on desktop ── */
.drawer-header,
.drawer-footer-li {
    display: none !important;
}

/* ═══════════════════════════════════════════════════════════════
   4. MOBILE — RIGHT-SIDE DRAWER (≤768px)
   ═══════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
    /* ── Header bar ── */
    .header {
        position: sticky !important;
        top: 0 !important;
        padding: 0 !important;
        background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%) !important;
        backdrop-filter: none !important;
        -webkit-backdrop-filter: none !important;
        border-bottom: none !important;
        box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15) !important;
    }

    body {
        padding-top: 0;
    }

    body.menu-open {
        overflow: hidden;
        position: fixed;
        width: 100%;
    }

    .header .container {
        padding: 0 12px;
    }

    .header-content {
        display: flex;
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        min-height: 50px;
        padding: 0;
        gap: 8px;
    }

    .header .logo {
        z-index: 1 !important;
    }

    .header .logo .logo-icon {
        width: 28px !important;
        height: 28px !important;
        max-width: 28px !important;
        max-height: 28px !important;
    }

    .header .logo a span {
        font-size: 1rem;
    }

    /* Contact info — скрываем в header bar на мобиле (контакты в drawer footer) */
    .header-content .contact-info {
        display: none;
    }

    .header .header-cta {
        display: none;
    }

    /* ── BACKDROP OVERLAY ── */
    .menu-overlay {
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.55);
        backdrop-filter: blur(4px);
        -webkit-backdrop-filter: blur(4px);
        z-index: 9999;
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.3s ease, visibility 0s linear 0.3s;
        cursor: pointer;
        display: block;
    }

    #mobile-menu-toggle:checked ~ .menu-overlay {
        opacity: 1;
        visibility: visible;
        transition: opacity 0.3s ease, visibility 0s linear 0s;
    }

    /* ── NAVIGATION DRAWER (right side) ── */
    .main-navigation {
        position: fixed !important;
        top: 0 !important;
        right: -105% !important;
        width: min(300px, 85vw) !important;
        height: 100dvh !important;
        background: #ffffff !important;
        box-shadow: -10px 0 40px rgba(15, 23, 42, 0.15) !important;
        z-index: 10000 !important;
        display: flex !important;
        flex-direction: column !important;
        transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
        overflow: hidden !important;
    }

    #mobile-menu-toggle:checked ~ .header-content .main-navigation {
        right: 0 !important;
    }

    /* ── HAMBURGER BUTTON ── */
    .mobile-menu-toggle {
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        gap: 5px;
        width: 40px;
        height: 40px;
        background: transparent;
        border: none;
        cursor: pointer;
        padding: 8px;
        border-radius: 6px;
        z-index: 10003;
        position: relative;
        flex-shrink: 0;
        transition: background 0.2s ease;
        order: 2;
    }

    .mobile-menu-toggle span {
        display: block;
        height: 2.5px;
        width: 22px;
        background: rgba(255, 255, 255, 0.95);
        border-radius: 2px;
        transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        transform-origin: center;
    }

    /* Hide hamburger when drawer is open — drawer has its own close button */
    #mobile-menu-toggle:checked ~ .header-content .mobile-menu-toggle {
        visibility: hidden;
        pointer-events: none;
    }

    /* Hamburger → X */
    #mobile-menu-toggle:checked ~ .header-content .mobile-menu-toggle span:nth-child(1) {
        transform: rotate(45deg) translate(5px, 5px);
    }
    #mobile-menu-toggle:checked ~ .header-content .mobile-menu-toggle span:nth-child(2) {
        opacity: 0;
        transform: scaleX(0);
    }
    #mobile-menu-toggle:checked ~ .header-content .mobile-menu-toggle span:nth-child(3) {
        transform: rotate(-45deg) translate(5px, -5px);
    }

    /* ── 5. DRAWER HEADER ── */
    .drawer-header {
        display: flex !important;
        align-items: center;
        justify-content: space-between;
        padding: 0 20px;
        height: 60px;
        background: #f2f3ff;
        flex-shrink: 0;
        border-bottom: 1px solid rgba(195, 198, 211, 0.3);
    }

    .drawer-title {
        font-weight: 700;
        font-size: 17px;
        color: #131b2e;
        letter-spacing: -0.01em;
    }

    .drawer-close {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 36px;
        height: 36px;
        background: transparent;
        border: none;
        cursor: pointer;
        border-radius: 6px;
        font-size: 24px;
        color: #434652;
        line-height: 1;
        transition: background 0.2s ease, color 0.2s ease;
        text-decoration: none;
    }
    .drawer-close:hover { background: #dae2fd; color: #131b2e; }

    .drawer-brand {
        display: flex;
        align-items: center;
        gap: 10px;
        text-decoration: none;
        color: #131b2e;
        font-weight: 700;
        font-size: 15px;
    }

    .drawer-brand-logo {
        width: 28px !important;
        height: 28px !important;
        max-width: 28px !important;
        max-height: 28px !important;
        object-fit: contain;
        border-radius: 4px;
    }

    /* ── NAV MENU (drawer body) ── */
    .nav-menu {
        display: flex;
        flex-direction: column;
        flex: 1;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        padding: 8px 0;
        margin: 0;
        list-style: none;
        /* Reset desktop fixed/absolute from styles-header.css */
        position: static !important;
        inset: auto !important;
        background: transparent !important;
        backdrop-filter: none !important;
        opacity: 1 !important;
        visibility: visible !important;
        pointer-events: auto !important;
        height: auto !important;
        width: auto !important;
        z-index: auto !important;
        animation: none !important;
    }

    .nav-menu > li {
        list-style: none;
        margin: 0;
        padding: 0;
        border-bottom: 1px solid rgba(195, 198, 211, 0.15);
        animation: none !important;
    }

    .nav-menu > li > a,
    .nav-menu > li > .nav-dropdown-toggle {
        display: flex;
        align-items: center;
        gap: 14px;
        padding: 14px 20px;
        font-size: 15px;
        font-weight: 600;
        color: #131b2e;
        text-decoration: none;
        background: transparent;
        transition: background 0.2s ease, transform 0.15s ease, color 0.15s ease;
        cursor: pointer;
        border-radius: 0;
    }

    .nav-menu > li > a:hover,
    .nav-menu > li > .nav-dropdown-toggle:hover {
        background: #f2f3ff;
        transform: translateX(4px);
        color: #00347f;
    }

    .nav-menu > li > a .menu-icon,
    .nav-menu > li > .nav-dropdown-toggle .menu-icon {
        width: 22px;
        min-width: 22px;
        height: 22px;
        display: flex;
        align-items: center;
        justify-content: center;
        color: #00347f;
        flex-shrink: 0;
    }

    .nav-menu > li > a .menu-icon svg,
    .nav-menu > li > .nav-dropdown-toggle .menu-icon svg {
        width: 20px;
        height: 20px;
        stroke: currentColor;
        stroke-width: 1.6;
        fill: none;
    }

    .nav-menu > li > a .label,
    .nav-menu > li > .nav-dropdown-toggle .label {
        flex: 1;
        color: inherit;
        text-align: left;
    }

    .nav-menu > li > a .chevron,
    .nav-menu > li > .nav-dropdown-toggle .chevron {
        font-size: 18px;
        color: #c3c6d3;
        flex-shrink: 0;
        margin-left: auto;
        transition: transform 0.25s ease;
    }

    .nav-dropdown.open > a .chevron,
    .nav-dropdown.open > .nav-dropdown-toggle .chevron {
        transform: rotate(90deg);
        color: #00347f;
    }

    .nav-menu > li > a .dropdown-arrow,
    .nav-menu > li > a .menu-arrow,
    .nav-menu > li > .nav-dropdown-toggle .dropdown-arrow { display: none; }

    /* ── SUBMENUS (accordion) ── */
    .nav-submenu {
        display: none;
        flex-direction: column;
        padding: 2px 0 6px;
        margin: 0;
        list-style: none;
        background: #f8f9ff;
        /* Reset desktop absolute positioning */
        position: static !important;
        top: auto !important;
        left: auto !important;
        transform: none !important;
        min-width: auto !important;
        box-shadow: none !important;
        border: none !important;
        opacity: 1 !important;
        visibility: visible !important;
        max-height: none !important;
        overflow: visible !important;
    }

    .nav-dropdown.open > .nav-submenu { display: flex; }

    .nav-submenu li {
        list-style: none;
        margin: 0;
        padding: 0;
    }

    .nav-submenu > li > a,
    .nav-submenu > .nav-dropdown > .nav-dropdown-toggle {
        display: flex;
        align-items: center;
        padding: 10px 20px 10px 56px;
        font-size: 14px;
        font-weight: 500;
        color: #434652;
        text-decoration: none;
        transition: background 0.2s ease, color 0.15s ease;
        background: transparent;
        gap: 8px;
        cursor: pointer;
    }

    .nav-submenu > li > a:hover,
    .nav-submenu > .nav-dropdown > .nav-dropdown-toggle:hover {
        background: #eaedff;
        color: #00347f;
    }

    .nav-submenu > li > a::after { content: none !important; }

    .nav-submenu .nav-dropdown.open > .nav-submenu {
        display: flex;
        padding-left: 16px;
    }

    .nav-submenu .nav-dropdown.open > .nav-submenu > li > a {
        padding-left: 72px;
        font-size: 13px;
    }

    .nav-dropdown:hover > .nav-submenu { display: none; }
    .nav-dropdown.open > .nav-submenu { display: flex; }

    .nav-dropdown-toggle { cursor: pointer; }

    /* ── DRAWER FOOTER ── */
    .drawer-footer-li {
        display: block !important;
        padding: 0;
        list-style: none;
        flex-shrink: 0;
    }

    .drawer-footer {
        padding: 16px 20px 20px;
        background: #f2f3ff;
        display: flex;
        flex-direction: column;
        gap: 14px;
        border-top: 1px solid rgba(195, 198, 211, 0.25);
    }

    .drawer-cta-btn {
        display: block;
        width: 100%;
        padding: 13px 20px;
        background: linear-gradient(135deg, #00347f, #1e4b9e);
        color: #ffffff;
        font-size: 14px;
        font-weight: 700;
        text-align: center;
        border: none;
        border-radius: 6px;
        cursor: pointer;
        transition: opacity 0.2s ease, transform 0.1s ease;
        letter-spacing: 0.01em;
    }

    .drawer-cta-btn:active { transform: scale(0.98); }

    .drawer-phone-link {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 8px;
        color: #131b2e;
        text-decoration: none;
        font-size: 15px;
        font-weight: 700;
        letter-spacing: -0.01em;
        transition: color 0.2s ease;
    }
    .drawer-phone-link:hover { color: #00347f; }

    .drawer-phone-link svg {
        width: 17px;
        height: 17px;
        fill: currentColor;
        flex-shrink: 0;
    }

    .drawer-social-row {
        display: flex;
        justify-content: center;
        gap: 12px;
    }

    .drawer-social-row a {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 40px;
        height: 40px;
        background: #ffffff;
        border-radius: 50%;
        box-shadow: 0 2px 8px rgba(15, 23, 42, 0.08);
        transition: box-shadow 0.2s ease, transform 0.2s ease;
    }

    .drawer-social-row a:hover {
        box-shadow: 0 4px 16px rgba(15, 23, 42, 0.14);
        transform: translateY(-1px);
    }

    .drawer-social-row svg { width: 22px; height: 22px; }
}

/* ═══════════════════════════════════════════════════════════════
   6. DESKTOP SUBMENU OVERRIDES (nested inside mobile block above
      needs desktop-specific hover styles)
   ═══════════════════════════════════════════════════════════════ */
@media (min-width: 769px) {
    .nav-submenu .nav-submenu-label {
        color: var(--h-text-dim) !important;
        padding: 0.5rem 1.25rem !important;
        font-size: 12px !important;
        text-transform: uppercase !important;
        letter-spacing: 0.1em !important;
        font-family: var(--h-font-body) !important;
        opacity: 0.7 !important;
    }
}
