/* Global Header Styles */

/* Verstecke Header initial, bis CSS vollständig geladen ist */
header#globalHeader:not([data-loaded]) {
    visibility: hidden;
    opacity: 0;
    display: block;
    min-height: 112px; /* Reserviert Platz für Header+Promo und reduziert CLS */
}

header#globalHeader[data-loaded] {
    visibility: visible;
    opacity: 1;
    transition: opacity 0.2s ease;
}

/* Stelle sicher, dass Icons initial die richtige Größe haben */
header#globalHeader:not([data-loaded]) .user-icon,
header#globalHeader:not([data-loaded]) .cart-icon,
header#globalHeader:not([data-loaded]) .mobile-menu-toggle {
    width: 0 !important;
    height: 0 !important;
    opacity: 0 !important;
    overflow: hidden !important;
}

header {
    background: white;
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0; /* Header sitzt ganz oben wenn er sticky wird */
    z-index: 1000;
    width: 100%;
    padding: 0; /* KEIN padding - wird vom header-container übernommen */
    margin: 0; /* KEIN margin */
}

/* Promo Banner */
.promo-banner {
    background: linear-gradient(135deg, #DB0080 0%, #B00068 100%); /* Magenta wie User/Warenkorb */
    color: white;
    padding: 0.5rem 0;
    text-align: center;
    width: 100%;
    position: relative;
    z-index: 999;
    display: block;
    box-shadow: 0 2px 4px rgba(219, 0, 128, 0.25);
}

.promo-banner.hidden {
    display: none;
}

.promo-banner-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

.promo-banner-link {
    color: inherit;
    text-decoration: none;
    display: inline-block;
}

.promo-banner-link:hover .promo-banner-text {
    text-decoration: underline;
}

.promo-banner-text {
    font-size: 0.9rem;
    font-weight: 500;
    letter-spacing: 0.02em;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    flex-wrap: wrap;
    justify-content: center;
}

.promo-banner-text strong {
    font-weight: 700;
    text-transform: uppercase;
    font-size: 0.95rem;
    letter-spacing: 0.05em;
}

@media (max-width: 768px) {
    header#globalHeader:not([data-loaded]) {
        min-height: 96px;
    }

    .promo-banner {
        padding: 0.4rem 0;
    }
    
    .promo-banner-content {
        padding: 0 2.5%;
    }
    
    .promo-banner-text {
        font-size: 0.8rem;
        line-height: 1.3;
        gap: 0.3rem;
    }
    
    .promo-banner-text strong {
        font-size: 0.85rem;
    }
}

.header-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 1rem 1.5rem; /* Konsistentes Padding oben/unten */
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    position: relative;
}

@media (max-width: 768px) {
    .header-container {
        max-width: 100%;
        width: 100%;
        padding: 1rem 2.5%; /* Mobile: mehr seitliches Padding */
        box-sizing: border-box;
    }
}

.logo {
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

.logo picture,
.logo img {
    height: auto;
    max-height: 60px;
    width: auto;
    max-width: 225px;
    object-fit: contain;
    display: block;
    transition: var(--transition);
}

@media (max-width: 768px) {
    .logo picture,
    .logo img {
        max-height: 48px; /* 20% kleiner als Desktop (60px * 0.8 = 48px) */
        max-width: 180px; /* 20% kleiner als Desktop (225px * 0.8 = 180px) */
    }
}

.logo:hover picture,
.logo:hover picture,
.logo:hover img {
    opacity: 0.8;
    transform: scale(1.05);
}

/* Main Navigation (Mitte) */
.main-nav {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 1.5rem;
    flex-shrink: 0;
}

.main-nav a {
    color: var(--text-dark);
    text-decoration: none;
    font-weight: 500;
    transition: var(--transition);
    font-size: 0.95rem;
}

.main-nav a:hover {
    color: var(--primary-color);
}

/* Submenü Styles für Desktop */
.main-nav .submenu {
    position: relative;
}

.main-nav .submenu-content {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    background: white;
    border-radius: 8px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
    min-width: 200px;
    z-index: 1001;
    padding: 12px 0;
    margin-top: 8px;
    /* Unsichtbarer Bereich oben, um die Lücke zu überbrücken */
    padding-top: 12px;
    margin-top: -4px;
}

/* Unsichtbarer Bereich oben im Dropdown, der zum Hover-Bereich gehört */
.main-nav .submenu-content::before {
    content: '';
    position: absolute;
    top: -4px;
    left: 0;
    right: 0;
    height: 4px;
    background: transparent;
}

/* Submenü bleibt offen beim Hover über Hauptmenüpunkt ODER Dropdown */
.main-nav .submenu:hover .submenu-content,
.main-nav .submenu-content:hover {
    display: block;
}

.main-nav .submenu-content a {
    display: block;
    padding: 12px 20px;
    color: var(--text-dark) !important;
    text-decoration: none;
    font-weight: 400;
    font-size: 0.9rem;
    transition: all 0.3s;
    border-radius: 0;
}

.main-nav .submenu-content a:hover {
    background: var(--primary-color) !important;
    color: white !important;
}

.main-nav .submenu-content a:first-child {
    border-top-left-radius: 8px;
    border-top-right-radius: 8px;
}

.main-nav .submenu-content a:last-child {
    border-bottom-left-radius: 8px;
    border-bottom-right-radius: 8px;
}

/* Header Right (Toggle, User, Cart) */
.header-right {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-shrink: 0;
    margin-left: auto;
}

/* Sie/Du Toggle Switch */
.sie-du-toggle-wrapper {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--bg-light);
    padding: 4px;
    border-radius: 30px;
    position: relative;
    cursor: pointer;
    user-select: none;
    min-width: 140px;
    height: 40px;
}

.sie-du-toggle-wrapper input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.sie-du-toggle-label {
    flex: 1;
    text-align: center;
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text-light);
    transition: var(--transition);
    z-index: 2;
    position: relative;
    padding: 8px 12px;
}

.sie-du-toggle-slider {
    position: absolute;
    top: 4px;
    left: 4px;
    width: calc(50% - 4px);
    height: calc(100% - 8px);
    background: white;
    border-radius: 26px;
    transition: var(--transition);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    z-index: 1;
}

.sie-du-toggle-wrapper input[type="checkbox"]:checked + .sie-du-toggle-slider {
    transform: translateX(calc(100% + 4px));
}

.sie-du-toggle-wrapper input[type="checkbox"]:checked ~ .sie-du-toggle-label.du {
    color: var(--text-light);
}

.sie-du-toggle-wrapper input[type="checkbox"]:checked ~ .sie-du-toggle-label.sie {
    color: var(--primary-color);
    font-weight: 700;
}

.sie-du-toggle-wrapper input[type="checkbox"]:not(:checked) ~ .sie-du-toggle-label.du {
    color: var(--primary-color);
    font-weight: 700;
}

.sie-du-toggle-wrapper input[type="checkbox"]:not(:checked) ~ .sie-du-toggle-label.sie {
    color: var(--text-light);
}

.sie-du-toggle-wrapper:hover {
    background: #e9ecef;
}

.user-link {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem;
    background: none; /* Kein Hintergrund */
    border-radius: 6px;
    transition: var(--transition);
    color: #DB0080; /* Magenta-Farbe */
    text-decoration: none;
}

.user-link:hover {
    background: rgba(219, 0, 128, 0.1); /* Sehr leichter Hover-Hintergrund */
    color: #DB0080;
}

.user-icon {
    width: 20px;
    height: 20px;
    color: inherit; /* Erbt die Farbe vom parent */
}

.cart-link {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem;
    background: none; /* Kein Hintergrund */
    border-radius: 6px;
    transition: var(--transition);
    color: #DB0080; /* Magenta-Farbe */
    text-decoration: none;
}

.cart-link:hover {
    background: rgba(219, 0, 128, 0.1); /* Sehr leichter Hover-Hintergrund */
    color: #DB0080;
}

.cart-icon {
    width: 20px;
    height: 20px;
}

.cart-badge {
    position: absolute;
    top: -8px;
    right: -8px;
    background: var(--primary-color);
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 600;
}

.mobile-menu-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-dark);
    padding: 0.5rem;
    flex-shrink: 0;
    order: -1; /* Links vom Logo auf Mobile */
}

/* Mobile Menu - Modern & Clean */
.mobile-menu {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 10000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    display: none; /* Versteckt standardmäßig komplett */
}

.mobile-menu.active {
    display: block; /* Nur wenn aktiv, anzeigen */
}

.mobile-menu.active {
    display: block; /* Nur wenn aktiv, anzeigen */
    opacity: 1;
    visibility: visible;
}

.mobile-menu-content {
    position: absolute;
    top: 0;
    left: 0;
    width: 85%;
    max-width: 360px;
    height: 100%;
    background: #ffffff;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}

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

.mobile-menu-header {
    background: linear-gradient(135deg, #a0ce4e 0%, #8dc63f 100%);
    padding: 1.25rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 8px rgba(160, 206, 78, 0.2);
    position: relative;
    z-index: 10;
}

.mobile-menu-header h2 {
    font-size: 1.25rem;
    font-weight: 700;
    margin: 0;
    color: white;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.mobile-menu-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: white;
    transition: all 0.3s ease;
    padding: 0;
}

.mobile-menu-close:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(90deg);
}

.mobile-menu-close svg {
    width: 20px;
    height: 20px;
}

.mobile-menu-nav {
    flex: 1;
    overflow-y: auto;
    padding: 2rem 0;
    display: flex !important;
    flex-direction: column;
    gap: 0.5rem;
    visibility: visible !important;
    opacity: 1 !important;
}

.mobile-menu-nav a {
    display: block !important;
    padding: 1rem 1.5rem;
    color: #2d3748 !important;
    text-decoration: none;
    font-weight: 600;
    font-size: 1.1rem;
    transition: all 0.3s ease;
    position: relative;
    border-left: 3px solid transparent;
    visibility: visible !important;
    opacity: 1 !important;
}

.mobile-menu-nav a::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: #a0ce4e;
    transform: scaleY(0);
    transition: transform 0.3s ease;
}

.mobile-menu-nav a:hover,
.mobile-menu-nav a:active {
    background: rgba(160, 206, 78, 0.08);
    color: #8dc63f;
    padding-left: 2rem;
    border-left-color: #a0ce4e;
}

.mobile-menu-nav a:hover::before,
.mobile-menu-nav a:active::before {
    transform: scaleY(1);
}

/* Mobile Submenü Styles */
.mobile-menu-item-with-submenu {
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.mobile-menu-main-item-wrapper {
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    position: relative;
}

.mobile-menu-main-item {
    font-weight: 600 !important;
    color: #2d3748 !important;
    padding: 1rem 1.5rem !important;
    display: block !important;
    flex: 1;
    border-left: 3px solid transparent;
    position: relative;
    text-decoration: none !important;
}

.mobile-menu-main-item::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: #a0ce4e;
    transform: scaleY(0);
    transition: transform 0.3s ease;
}

.mobile-menu-main-item-wrapper:hover .mobile-menu-main-item::before,
.mobile-menu-main-item-wrapper:active .mobile-menu-main-item::before {
    transform: scaleY(1);
}

.mobile-submenu-toggle {
    background: none;
    border: none;
    padding: 0.5rem 1rem;
    cursor: pointer;
    color: #4a5568;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    margin-right: 0.5rem;
}

.mobile-submenu-toggle:hover {
    color: #a0ce4e;
}

.mobile-submenu-toggle svg {
    transition: transform 0.3s ease;
}

.mobile-submenu.expanded ~ .mobile-menu-main-item-wrapper .mobile-submenu-toggle svg,
.mobile-menu-main-item-wrapper:has(+ .mobile-submenu.expanded) .mobile-submenu-toggle svg {
    transform: rotate(180deg);
}

/* Toggle-Rotation wird über JavaScript gesteuert */

.mobile-submenu {
    max-height: 0;
    overflow: hidden;
    padding: 0;
    background: rgba(160, 206, 78, 0.03);
    border-left: 2px solid rgba(160, 206, 78, 0.2);
    margin-left: 1.5rem;
    transition: max-height 0.3s ease, padding 0.3s ease;
}

.mobile-submenu.expanded {
    max-height: 1000px;
    padding: 0.5rem 0;
}

.mobile-submenu-item {
    display: block !important;
    padding: 0.75rem 1.5rem 0.75rem 2.5rem !important;
    font-size: 0.95em !important;
    color: #4a5568 !important;
    font-weight: 400 !important;
    text-decoration: none !important;
    transition: all 0.3s ease;
    border-left: 2px solid transparent;
    position: relative;
}

.mobile-submenu-item::before {
    content: '→';
    position: absolute;
    left: 1.5rem;
    color: #a0ce4e;
    font-size: 0.85em;
    opacity: 0.6;
    transition: all 0.3s ease;
}

.mobile-submenu-item:hover,
.mobile-submenu-item:active {
    background: rgba(160, 206, 78, 0.1) !important;
    color: #8dc63f !important;
    padding-left: 3rem !important;
    border-left-color: #a0ce4e;
}

.mobile-submenu-item:hover::before,
.mobile-submenu-item:active::before {
    opacity: 1;
    transform: translateX(3px);
}

/* Mobile Menu Toggle Section */
.mobile-menu-toggle-section {
    padding: 1.75rem 1.5rem;
    border-top: 2px solid #e2e8f0;
    background: linear-gradient(180deg, #f8f9fa 0%, #ffffff 100%);
    position: relative;
    z-index: 10;
}

.mobile-menu-toggle-text {
    text-align: center;
    color: #64748b;
    font-size: 0.875rem;
    margin: 0 0 1.25rem 0;
    font-style: italic;
    line-height: 1.5;
}

.mobile-menu-toggle-section .sie-du-toggle-wrapper {
    width: 100%;
    max-width: 240px;
    margin: 0 auto;
    box-shadow: 0 2px 8px rgba(160, 206, 78, 0.15);
    border-radius: 50px;
}

/* Desktop-only Toggle */
.desktop-only {
    display: flex;
}

/* Responsive */
@media (max-width: 768px) {
    .mobile-menu-toggle {
        display: block;
    }
    
    .main-nav {
        display: none;
    }
    
    .header-right {
        gap: 0.5rem;
    }
    
    header {
        width: 100%;
    }
    
    .header-container {
        max-width: 100%;
        width: 100%;
        padding: 0 1rem;
        box-sizing: border-box;
        gap: 0.75rem;
    }
    
    .mobile-menu-toggle {
        display: block;
        order: -1; /* Links vom Logo */
    }
    
    .logo {
        order: 0;
        flex: 1;
        min-width: 0; /* Ermöglicht Shrinking */
    }
    
    .header-right {
        gap: 0.5rem;
        flex-shrink: 0;
    }
    
    /* Toggle auf Mobile ausblenden */
    .desktop-only {
        display: none !important;
    }
    
    .cart-link .cart-text {
        display: none;
    }
    
    .cart-link {
        gap: 0;
        padding: 0.5rem;
        flex-shrink: 0;
    }
    
    /* Sie/Du Toggle kleiner auf Mobile */
    .sie-du-toggle-wrapper {
        min-width: 90px;
        height: 32px;
        padding: 3px;
    }
    
    .sie-du-toggle-label {
        font-size: 0.7rem;
        padding: 4px 6px;
    }
    
    .sie-du-toggle-slider {
        top: 3px;
        left: 3px;
        width: calc(50% - 3px);
        height: calc(100% - 6px);
    }
    
    .sie-du-toggle-wrapper input[type="checkbox"]:checked + .sie-du-toggle-slider {
        transform: translateX(calc(100% + 3px));
    }
    
    .logo {
        flex: 0 0 50%;
        max-width: 50%;
    }
    
    .logo picture,    
    .logo picture,
    .logo img {
        height: 40px;
    }
    
    /* Mobile Menu bleibt versteckt bis .active */
    .mobile-menu.active {
        display: block;
    }
}

