/**
 * Black Demons - Verschachtelte Menü-System CSS
 * Version: 2.0
 * Robusteres Dropdown-System mit besserer Mobile-Unterstützung
 */

/* ===== Hauptnavigation ===== */
.nav-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

@media (min-width: 901px) {
    .nav-list {
        display: flex;
        flex-wrap: wrap;
    }
}

.nav-item {
    position: relative;
    margin: 0 5px;
}

.nav-link {
    display: block;
    padding: 10px 15px;
    color: #fff;
    text-decoration: none;
    transition: background 0.3s ease;
}

.nav-link:hover {
    background: rgba(255, 102, 0, 0.2);
    color: #ff6600;
}

.nav-link[data-dropdown]::after {
    content: '▼';
    font-size: 0.8em;
    margin-left: 5px;
}

.nav-item.active > .nav-link[data-dropdown]::after {
    content: '▼';
    display: inline;
    height: auto;
    background: none;
    margin-top: 0;
    border-radius: 0;
}

/* ===== Dropdown-System ===== */
.dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    background: #1a1a1a;
    min-width: 200px;
    display: none;
    z-index: 1000;
    border: 1px solid #333;
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    max-height: 400px;
    overflow-y: auto;
}

.nav-item:hover > .dropdown {
    display: block;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-5px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ===== Verschachtelte Dropdowns ===== */
.nav-item .dropdown li {
    position: relative;
}

.nav-item .dropdown .dropdown {
    top: 0;
    left: 100%;
    margin-left: 0;
    display: none;
}

.nav-item .dropdown li:hover > .dropdown {
    display: block;
    animation: slideIn 0.2s ease;
}

@keyframes slideIn {
    from { opacity: 0; transform: translateX(-5px); }
    to { opacity: 1; transform: translateX(0); }
}

/* ===== Level-spezifische Anpassungen ===== */
.dropdown.level-1 {
    top: 100%;
    left: 0;
}

.dropdown.level-2 {
    top: 0;
    left: 100%;
    margin-left: 0;
}

/* ===== Dropdown-Links ===== */
.dropdown a {
    display: block;
    padding: 10px 15px;
    color: #ccc;
    text-decoration: none;
    border-bottom: 1px solid #333;
    white-space: nowrap;
    transition: all 0.2s ease;
}

.dropdown a:hover {
    background: #333;
    color: #fff;
    padding-left: 20px;
}

.dropdown a:last-child {
    border-bottom: none;
}

/* ===== Scrollbar Styling ===== */
.dropdown::-webkit-scrollbar {
    width: 8px;
}

.dropdown::-webkit-scrollbar-track {
    background: #1a1a1a;
}

.dropdown::-webkit-scrollbar-thumb {
    background: #ff6600;
    border-radius: 4px;
}

.dropdown::-webkit-scrollbar-thumb:hover {
    background: #e05500;
}

/* ===== Mobile Anpassungen ===== */
@media (min-width: 901px) {
    .nav-list {
        display: flex;
        flex-wrap: wrap;
    }
}

@media (max-width: 900px) {
    .nav-container {
        position: relative;
    }
    html.nav-open,
    body.nav-open {
        overflow: hidden;
    }

    .nav-overlay {
        display: none !important;
    }

    .nav-wrapper.nav-open {
        position: fixed;
        inset: 0;
        z-index: 3000;
        overflow: hidden;
        background: #000;
        border-top: none;
        border-bottom: none;
        box-shadow: none;
    }

    .nav-wrapper.nav-open .nav-container {
        position: static;
        width: 100%;
        max-width: none;
        margin: 0;
        gap: 0;
        height: auto;
    }

    .nav-wrapper.nav-open .search-results {
        display: none !important;
    }

    .nav-wrapper.nav-open .toolbar {
        display: none;
    }

    .nav-wrapper.nav-open .mobile-toggle {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        width: 100%;
        height: auto;
        margin: 0;
        z-index: 3002;
        background: #111;
        border-bottom: 2px solid #333;
        padding: 15px;
        padding-top: max(15px, env(safe-area-inset-top, 0px));
        box-sizing: border-box;
    }

    .nav-wrapper.nav-open .mobile-toggle,
    .nav-wrapper.nav-open .mobile-toggle.is-open {
        transform: none !important;
        color: #fff;
        background: #1a1a1a;
    }

    .nav-list {
        display: none;
        flex-direction: column;
        flex-wrap: nowrap;
        width: 100%;
    }

    .nav-list.active {
        display: block !important;
        position: fixed;
        top: var(--mobile-nav-bar-height, 56px);
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        margin: 0;
        padding: 0 0 max(24px, env(safe-area-inset-bottom, 0px));
        background: #000;
        overflow-x: hidden;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
        touch-action: pan-y;
        z-index: 3001;
        animation: none !important;
        box-sizing: border-box;
        max-height: calc(100dvh - var(--mobile-nav-bar-height, 56px));
        max-height: calc(100vh - var(--mobile-nav-bar-height, 56px));
    }

    @keyframes mobileNavIn {
        from { opacity: 0; transform: translateY(-12px); }
        to { opacity: 1; transform: translateY(0); }
    }

    .nav-list::-webkit-scrollbar {
        width: 8px;
    }

    .nav-list::-webkit-scrollbar-track {
        background: #111;
    }

    .nav-list::-webkit-scrollbar-thumb {
        background: #ff6600;
        border-radius: 4px;
    }
    
    .nav-item {
        margin: 0;
        width: 100%;
        display: block;
        float: none;
        clear: both;
    }

    .nav-item:hover > .dropdown {
        display: none;
    }
    
    .nav-link {
        padding: 15px 20px;
        border-bottom: 1px solid #333;
        display: flex;
        align-items: center;
        justify-content: space-between;
    }

    .nav-link[data-dropdown]::after {
        flex-shrink: 0;
        margin-left: 12px;
        transition: transform 0.2s ease;
    }

    .nav-item.mobile-open > .nav-link[data-dropdown]::after {
        transform: rotate(180deg);
    }
    
    .dropdown {
        position: static;
        display: none;
        width: 100%;
        border: none;
        background: #111;
        max-height: none;
        overflow: visible;
        box-shadow: none;
        border-radius: 0;
    }
    
    .nav-item.mobile-open > .dropdown {
        display: block;
        animation: none;
    }
    
    .nav-item .dropdown .dropdown {
        margin-left: 0;
        background: #0a0a0a;
        position: static;
        display: none;
        border-left: 3px solid #ff6600;
    }
    
    .nav-item .dropdown .nav-item.mobile-open > .dropdown {
        display: block;
    }
    
    .dropdown a {
        padding: 14px 20px 14px 28px;
        font-size: 1rem;
        white-space: normal;
    }
    
    .dropdown a:hover {
        padding-left: 28px;
    }
}

/* ===== Barrierefreiheit ===== */
.nav-link:focus {
    outline: 2px solid #ff6600;
    outline-offset: 2px;
}

.dropdown a:focus {
    outline: 2px solid #ff6600;
    outline-offset: -2px;
}

/* ===== Active State ===== */
.nav-item.active .nav-link {
    color: #ff6600;
    font-weight: bold;
}

/* ===== Loading State ===== */
.nav-loading {
    color: #ff6600;
    padding: 10px;
    text-align: center;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}
