/* ===========================================
   liVexo-STYLE HEADER
   Moderner, cleaner Header im liVexo-Design
   =========================================== */

.livexo-header {
    background: var(--white);
    border-bottom: 1px solid var(--border-light);
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: var(--shadow-sm);
    /* PWA Safe Area Support */
    padding-top: constant(safe-area-inset-top); /* iOS 11.0-11.2 */
    padding-top: env(safe-area-inset-top); /* iOS 11.2+ */
}

.header-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 80px;
    gap: 2rem;
    padding: 0;
}

/* Logo */
.header-logo {
    flex-shrink: 0;
    margin-left: 0;
    min-width: 120px;
}

.logo-link {
    display: flex;
    align-items: center;
    text-decoration: none;
}

.livexo-logo {
    height: 60px;
    width: auto;
    max-width: 120px;
    object-fit: contain;
    display: block;
    color: transparent; /* Alt-Text unsichtbar während Bild lädt */
}

/* Theme-basiertes Logo: Dark-Logo verstecken im Light Mode */
.livexo-logo-dark {
    display: none;
}

/* Im Dark Mode: Light verstecken, Dark zeigen */
[data-theme="dark"] .livexo-logo-light {
    display: none;
}
[data-theme="dark"] .livexo-logo-dark {
    display: block;
}


/* Navigation */
.header-nav {
    display: flex;
    align-items: center;
    gap: 0;
    flex: 1;
    height: 80px;
}

.header-nav .nav-link {
    position: relative;
    padding: 8px 16px;
    color: var(--text-dark);
    text-decoration: none;
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    font-weight: 400;
    transition: all 0.2s ease;
    white-space: nowrap;
    border: none;
    background: transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    border-radius: 8px;
    margin: 0 4px;
}

.header-nav .nav-link:hover {
    background: var(--gray-100);
}

.header-nav .nav-link.active {
    color: var(--black);
    text-shadow: 0.4px 0 0 currentColor, -0.4px 0 0 currentColor; /* Fett-Optik OHNE Breiten-Sprung: font-weight:700 wuerde die Navi beim Umschalten verschieben */
}

.header-nav .nav-link.active::after {
    content: '';
    position: absolute;
    bottom: -21px;
    left: 50%;
    transform: translateX(-50%);
    width: calc(100% - 8px);
    height: 3px;
    background: var(--primary-color);
}

/* Navigation Links mit Badge */
.header-nav .nav-link.nav-link-with-badge {
    gap: 6px;
}

/* Desktop Navigation Badge */
.nav-badge-desktop {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    background: var(--error-color);
    color: var(--text-on-color);
    font-size: 11px;
    font-weight: 600;
    border-radius: 9px;
    line-height: 1; font-variant-numeric: tabular-nums; /* Inter setzt Ziffern proportional: die "1" sitzt in ihrer Laufweite nicht mittig und wirkte im Kreis seitlich verschoben. Tabellenziffern zentrieren sie. */
}

.nav-badge-desktop.large {
    min-width: 22px;
    padding: 0 6px;
}

/* Dropdown Navigation */
.nav-dropdown {
    position: relative;
}

.nav-dropdown .dropdown-toggle {
    display: flex;
    align-items: center;
    gap: 4px;
    background: transparent;
    border-radius: 8px;
    margin: 0 4px;
}

/* Entferne den Bootstrap-generierten Pfeil */
.nav-dropdown .dropdown-toggle::after {
    display: none !important;
}

.nav-dropdown .dropdown-toggle:hover {
    background: var(--gray-100);
}

.dropdown-arrow {
    font-size: 10px;
    transition: transform 0.2s ease;
}

.nav-dropdown.active .dropdown-arrow {
    transform: rotate(180deg);
}

.nav-dropdown .dropdown-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 250px;
    width: auto;
    background: var(--white);
    border: 1px solid var(--border-light);
    border-radius: 8px;
    box-shadow: var(--shadow-md);
    padding: 8px 0;
    display: none;
    z-index: 1001;
}

.nav-dropdown.active .dropdown-menu {
    display: block;
}

/* Lange Header-Dropdowns bei niedrigem Viewport intern scrollbar machen, damit
   die untersten Eintraege ("Weiteres") erreichbar bleiben. Nur Desktop – auf
   Mobile liegt das Dropdown inline im ohnehin scrollbaren Menue-Overlay
   (position: static), dort wuerde ein max-height es faelschlich abschneiden. */
@media (min-width: 769px) {
    .nav-dropdown .dropdown-menu {
        max-height: calc(100vh - 96px);
        max-height: calc(100dvh - 96px);
        overflow-y: auto;
        overscroll-behavior: contain;
    }
}

.dropdown-item {
    display: block;
    width: 100%;
    padding: 10px 20px;
    color: var(--text-dark);
    text-decoration: none;
    font-size: 14px;
    font-weight: 400;
    transition: background-color 0.2s ease, color 0.2s ease;
    white-space: nowrap;
    box-sizing: border-box;
    text-align: left;
}

.dropdown-item:hover, .dropdown-item.active { /* .active: zeigt im zugeklappten Menue, auf welcher Seite man steht */
    background: var(--gray-100);
    color: var(--black);
}

/* Header Actions */
.header-actions {
    display: flex;
    align-items: center;
    gap: 0;
    flex-shrink: 0;
}


.user-name {
    color: var(--text-color);
    font-size: 14px;
    font-weight: 500;
}

.user-dropdown-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 220px;
    background: var(--white);
    border: 1px solid var(--border-light);
    border-radius: 8px;
    box-shadow: var(--shadow-md);
    padding: 8px 0;
    display: none;
    z-index: 1001;
}


.dropdown-header {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-light);
}

.dropdown-header strong {
    display: block;
    color: var(--gray-900);
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 2px;
}

.dropdown-header small {
    color: var(--gray-500);
    font-size: 12px;
}

.dropdown-divider {
    height: 1px;
    background: var(--border-light);
    margin: 4px 0;
}

/* Responsive */
@media (max-width: 1024px) {
    .header-inner {
        gap: 1rem;
    }
    
    .header-nav {
        gap: 0;
    }
    
    .header-nav .nav-link {
        padding: 0 12px;
        font-size: 13px;
    }
    
    .user-name {
        display: none;
    }
}

/* Mobile Menu Toggle - ab 768px und kleiner */
.mobile-menu-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    z-index: 1002;
    position: relative;
}

.hamburger-icon {
    display: flex;
    flex-direction: column;
    gap: 4px;
    width: 24px;
    height: 18px;
}

.hamburger-icon span {
    display: block;
    width: 100%;
    height: 2px;
    background: var(--text-dark);
    transition: all 0.3s ease;
    border-radius: 2px;
}

/* Hamburger Animation wenn aktiv */
.mobile-menu-toggle.active .hamburger-icon span:nth-child(1) {
    transform: translateY(6px) rotate(45deg);
}

.mobile-menu-toggle.active .hamburger-icon span:nth-child(2) {
    opacity: 0;
}

.mobile-menu-toggle.active .hamburger-icon span:nth-child(3) {
    transform: translateY(-6px) rotate(-45deg);
}

@media (max-width: 768px) {
    /* Header anpassen */
    .header-inner {
        height: 64px;
        gap: 0;
        position: relative;
    }
    
    .header-logo {
        display: none;
    }
    
    /* Mobile Toggle anzeigen - ganz links */
    .mobile-menu-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
        order: -2;
        margin-right: 0;
        margin-left: 0;
    }
    
    /* Navigation als Mobile Overlay */
    .header-nav {
        position: fixed;
        top: calc(64px + env(safe-area-inset-top, 0px));
        left: 0;
        width: 100%;
        height: calc(100vh - 64px - env(safe-area-inset-top, 0px));
        /* dvh = sichtbare Höhe (ohne Bereich hinter der Safari-Leiste) → Menü
           scrollt intern statt die Seite dahinter; alt-iOS nutzt die vh-Zeile. */
        height: calc(100dvh - 64px - env(safe-area-inset-top, 0px));
        background: var(--white);
        display: flex !important;
        flex-direction: column;
        align-items: stretch;
        padding: 0;
        overflow-y: scroll;
        overflow-x: hidden;
        /* Scroll bleibt im Menü: kein Durchreichen, kein Pull-to-Refresh (iOS 16+). */
        overscroll-behavior: contain;
        -webkit-overflow-scrolling: touch;
        transform: translateX(-100%);
        opacity: 0;
        visibility: hidden;
        transition: transform 0.3s ease, opacity 0.3s ease, visibility 0.3s ease;
        box-shadow: var(--shadow-md);
        z-index: 999;
    }
    
    .header-nav.mobile-active {
        transform: translateX(0);
        opacity: 1;
        visibility: visible;
    }
    
    /* Seite einfrieren solange das Menü offen ist. overflow:hidden allein reicht
       auf iOS Safari NICHT (Seite scrollt weiter, Pull-to-Refresh feuert) →
       position:fixed; --scroll-lock-top (per JS) merkt die Scroll-Position. */
    body.mobile-menu-open:not(.capacitor-native) {
        position: fixed;
        top: var(--scroll-lock-top, 0);
        left: 0;
        right: 0;
        width: 100%;
        overflow: hidden;
    }

    /* Capacitor: Fenster scrollt nicht (.main ist der Scroller) → .main einfrieren. */
    body.capacitor-native.mobile-menu-open .main {
        overflow: hidden !important;
    }

    body.mobile-menu-open:not(.capacitor-native) .livexo-header {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
    }
    
    /* Nav Links im Mobile-Menü */
    .header-nav .nav-link {
        padding: 18px 20px;
        font-size: 16px;
        margin: 0;
        border-radius: 0;
        border-bottom: 1px solid var(--gray-100);
        flex-shrink: 0;
    }
    
    .header-nav::after {
        content: '';
        display: block;
        height: 60px;
        flex-shrink: 0;
    }
    
    .header-nav .nav-link.active::after {
        display: none;
    }
    
    .header-nav .nav-link.active {
        background: var(--light-gray);
        color: var(--primary-color);
    }
    
    /* Dropdown im Mobile-Menü */
    .nav-dropdown {
        width: 100%;
        display: block;
    }
    
    .nav-dropdown .dropdown-toggle {
        width: 100%;
        display: flex;
        justify-content: space-between;
        padding: 16px 20px;
        margin: 0;
        border-bottom: 1px solid var(--gray-100);
        border-radius: 0;
    }
    
    .nav-dropdown .dropdown-menu {
        position: static;
        box-shadow: none;
        border: none;
        border-radius: 0;
        margin-top: 0;
        padding: 0;
        padding-left: 16px;
        background: var(--gray-50);
    }
    
    .nav-dropdown.active .dropdown-menu {
        display: block;
    }
    
    .dropdown-item {
        padding: 12px 16px;
        font-size: 15px;
        border-bottom: 1px solid var(--gray-100);
    }
    
    .dropdown-item:last-child {
        border-bottom: none;
    }
    
    /* Header Actions bleiben sichtbar */
    .header-actions {
        gap: 2px;
    }
    
    /* User Menu Dropdown Anpassung */
    .user-dropdown-menu {
        right: 0;
        left: auto;
        min-width: 200px;
    }
    
    
    
    
    
    
    
    
}

@media (max-width: 480px) {
    .header-container {
        padding: 0 12px;
    }
    
    .header-inner {
        height: 56px;
    }
    
    .header-nav {
        top: calc(56px + env(safe-area-inset-top, 0px));
        height: calc(100vh - 56px - env(safe-area-inset-top, 0px));
        /* Diese Höhe greift auf echten iPhones (Hochformat <=480px). */
        height: calc(100dvh - 56px - env(safe-area-inset-top, 0px));
        padding: 16px;
    }
    
    .header-nav .nav-link {
        padding: 14px 10px;
        font-size: 15px;
    }
    
    .nav-dropdown .dropdown-toggle {
        padding: 14px 10px;
    }
}

/* ===========================================
   INERTIA-LADEBALKEN (nprogress) UNTER DEM HEADER
   Standardmaessig sitzt der Balken ganz oben (top:0) — am Desktop direkt an der
   Header-Oberkante, auf Mobile unter dem Notch. Deshalb ueberall an die Unterkante
   des Headers legen, damit klar sichtbar ist, dass etwas laedt (Strich unter der Navi).
   Header-Hoehe: 80px (Desktop), 64px (<=768px), 56px (<=480px) + Safe-Area (Notch).
   =========================================== */
#nprogress .bar {
    top: calc(80px + env(safe-area-inset-top, 0px)) !important;
}

@media (max-width: 768px) {
    #nprogress .bar {
        top: calc(64px + env(safe-area-inset-top, 0px)) !important;
    }
}

@media (max-width: 480px) {
    #nprogress .bar {
        top: calc(56px + env(safe-area-inset-top, 0px)) !important;
    }
}

/* Chat-Icon oben ausblenden, wo die Bottom-Navigation (mit Chat) sichtbar ist:
   auf Mobile (<=768px) und im Standalone-Modus (App/PWA). Spart Platz oben. */
@media (max-width: 768px) {
    .header-actions .header-chat-btn {
        display: none !important;
    }
}

@media all and (display-mode: standalone) {
    .header-actions .header-chat-btn {
        display: none !important;
    }
}


