/* shop-main-nav.css */
/* ================== MAIN NAVIGATION ================== */
.main-nav {
    display: flex;            
    gap: 20px;                
    padding: 15px 30px;
    background: white;
    border-bottom: 1px solid #eee;
    position: relative;
    z-index: 1000;
    font-family: sans-serif;
    white-space: nowrap;
}

/* ================== NAV ITEM ================== */
.nav-item {
    position: relative;       /* für absolute Dropdowns */
}

.nav-link {
    cursor: pointer;
    font-weight: 500;
    padding: 8px 12px;
    display: block;
    transition: color 0.2s;
}

.nav-link:hover {
    color: #e60023;
}

/* ================== DROPDOWN ================== */
.nav-dropdown {
    display: none;
    position: absolute;
    top: 100%;               
    left: 0;
    background: white;
    min-width: 220px;
    border-radius: 10px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.1);
    padding: 5px 0;
    z-index: 2000;            /* über der main-nav */
}

.nav-item.active > .nav-dropdown {
    display: block;
}

/* ================== DROPDOWN ITEMS ================== */
.dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 15px;
    cursor: pointer;
    transition: background 0.2s;
    position: relative;
}

.dropdown-item:hover {
    background: #fff0f3;
}

.icon {
    font-size: 18px;
}

/* ================== SUB-DROPDOWNS ================== */
.dropdown-item .nav-dropdown {
    top: 0;
    left: 100%;               /* rechts vom Parent */
    display: none;
    z-index: 2000;
}

.dropdown-item.active > .nav-dropdown {
    display: block;
}

/* Pfeil für Items mit Children */
.dropdown-item[data-has-children="true"]::after {
    content: '▶';
    margin-left: auto;
    font-size: 12px;
    color: #888;
}

/* ================== MOBILE ================== */
@media (max-width: 768px) {

    .main-nav {
        flex-wrap: nowrap;
        padding: 10px;
        overflow-x: auto;      /* scrollbar nur auf mobile */
    }

    .nav-dropdown {
        position: static;
        box-shadow: none;
        border-radius: 0;
        min-width: unset;
        display: none;         /* wird JS toggeln */
    }

    .nav-item.active > .nav-dropdown {
        display: block;
    }

    .dropdown-item .nav-dropdown {
        left: 0;
        top: 0;
    }

    .dropdown-item[data-has-children="true"]::after {
        content: '▼';
    }
}

/* =========================================================
   Mobile Sortiment-Schublade
   ========================================================= */

/*
 * Desktop:
 * Mobile Kategorie-Elemente ausblenden.
 */
.mobile-category-backdrop,
.mobile-category-panel {
    display: none;
}

@media (max-width: 768px) {

    /*
     * Die klassische Kategorie-Leiste wird auf Mobile durch "Sortiment" ersetzt.
     */
    .main-nav {
        display: none;
    }

    .mobile-category-backdrop {
        display: none;
        position: fixed;
        inset: 0;
        z-index: 8999;
        background: rgba(0, 0, 0, 0.35);
    }

    .mobile-category-backdrop.is-open {
        display: block;
    }

    .mobile-category-panel {
        display: flex;
        flex-direction: column;

        position: fixed;
        top: 0;
        left: 0;

        width: min(88vw, 360px);
        height: 100dvh;

        z-index: 9000;

        background: #ffffff;

        transform: translateX(-100%);
        transition: transform 0.2s ease;

        box-shadow: 20px 0 40px rgba(0, 0, 0, 0.18);
    }

    .mobile-category-panel.is-open {
        transform: translateX(0);
    }

    .mobile-category-panel-head {
        min-height: 64px;
        padding: 14px 16px;

        display: flex;
        align-items: center;
        justify-content: space-between;

        border-bottom: 1px solid #eeeeee;
    }

    .mobile-category-panel-head strong {
        display: block;
        font-size: 18px;
        font-weight: 900;
    }

    .mobile-category-panel-head span {
        display: block;
        margin-top: 2px;
        font-size: 12px;
        color: #777777;
    }

    .mobile-category-close {
        width: 38px;
        height: 38px;

        border: none;
        border-radius: 999px;

        background: #f3f4f6;
        color: #111111;

        font-size: 26px;
        line-height: 1;

        cursor: pointer;
    }

    .mobile-category-list {
        overflow-y: auto;
        padding: 8px;
    }

    .mobile-category-row {
        width: 100%;

        border: none;
        background: #ffffff;

        display: flex;
        align-items: center;
        justify-content: space-between;

        padding: 14px 12px;

        border-radius: 12px;

        color: #111111;
        text-decoration: none;

        font-size: 15px;
        font-weight: 700;

        cursor: pointer;
    }

    .mobile-category-row:hover {
        background: #f6f6f6;
    }

    .mobile-category-back {
        color: #555555;
        font-weight: 800;
    }

    .mobile-category-show-all {
        background: #111111;
        color: #ffffff;
        margin-bottom: 8px;
    }

    body.mobile-category-open {
        overflow: hidden;
    }
}

/* =========================================================
   Mobile Sortiment wie App-Shop
   ========================================================= */

/*
 * Desktop:
 * Mobile Sortiment-Panel ist aus.
 */
.mobile-sortiment-panel {
    display: none;
}

@media (max-width: 768px) {

    /*
     * Die normale Desktop-Kategorie-Leiste wird auf Mobile ersetzt
     * durch den Header-Button "Sortiment".
     */
    .main-nav {
        display: none;
    }

    /*
     * Mobile Sortiment-Panel.
     *
     * Es liegt unter dem mobilen Header und über dem Seiteninhalt.
     */
    .mobile-sortiment-panel {
        display: block;

        position: fixed;
        top: 56px;
        left: 0;
        right: 0;
        bottom: 0;

        z-index: 8500;

        background: #f1f1f1;

        overflow-y: auto;

        opacity: 0;
        pointer-events: none;
        transform: translateY(-8px);

        transition:
            opacity 0.18s ease,
            transform 0.18s ease;
    }

    .mobile-sortiment-panel.is-open {
        opacity: 1;
        pointer-events: auto;
        transform: translateY(0);
    }

    /*
     * Kopf im Sortiment-Panel.
     *
     * Root-Ebene:
     * - Titel "Sortiment"
     *
     * Unterebene:
     * - Zurück links
     * - Kategorie-Titel mittig
     */
    .mobile-sortiment-head {
        position: sticky;
        top: 0;

        z-index: 2;

        min-height: 54px;

        display: grid;
        grid-template-columns: 1fr auto 1fr;
        align-items: center;

        padding: 0 12px;

        background: #f1f1f1;
        border-bottom: 1px solid #e5e5e5;
    }

    .mobile-sortiment-title {
        grid-column: 2;

        color: #111111;

        font-size: 18px;
        font-weight: 900;

        text-align: center;
        white-space: nowrap;
    }

    .mobile-sortiment-back {
        grid-column: 1;

        justify-self: start;

        display: inline-flex;
        align-items: center;
        gap: 4px;

        border: none;
        background: transparent;

        color: #111111;

        font-size: 16px;
        font-weight: 700;

        cursor: pointer;
        padding: 8px 0;
    }

    .mobile-sortiment-back[hidden] {
        display: none;
    }

    .mobile-sortiment-head-spacer {
        grid-column: 3;
    }

    /*
     * Root-Ansicht:
     * Hauptkategorien als Karten/Grid.
     */
    .mobile-sortiment-grid {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 10px;

        padding: 14px;
    }

    .mobile-sortiment-card {
        min-height: 74px;

        display: flex;
        align-items: center;
        justify-content: flex-start;

        padding: 16px 14px;

        border: none;
        border-radius: 12px;

        background: #ffffff;
        color: #111111;

        font-size: 17px;
        font-weight: 900;
        text-align: left;

        cursor: pointer;
    }

    .mobile-sortiment-card:active {
        transform: scale(0.99);
    }

    /*
     * Unterkategorie-Ansicht:
     * Liste wie im Screenshot, ohne Bilder.
     */
    .mobile-sortiment-list {
        display: flex;
        flex-direction: column;

        background: #ffffff;
    }

    .mobile-sortiment-row {
        width: 100%;
        min-height: 58px;

        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 12px;

        padding: 0 16px;

        border: none;
        border-bottom: 1px solid #eeeeee;

        background: #ffffff;
        color: #111111;

        font-size: 17px;
        font-weight: 700;
        text-align: left;
        text-decoration: none;

        cursor: pointer;
    }

    .mobile-sortiment-row i {
        color: #111111;
        font-size: 18px;
        flex: 0 0 auto;
    }

    .mobile-sortiment-show-all {
        font-weight: 900;
        background: #fafafa;
    }

    /*
     * Wenn Sortiment offen ist, soll die Seite darunter nicht scrollen.
     */
    body.sortiment-open {
        overflow: hidden;
    }
}