/* =========================================================
   UI-Core Shop Header
   =========================================================
   Zweck:
   - Globaler Standard-Header für Shops
   - Kein app-spezifisches Chat-Design
   - Unterstützt Warenkorb, Merkliste, Account-Menü, Mobile-Menü
   - App-spezifische Erweiterungen, z. B. Billardshop-Nachrichten-Badge,
     können zusätzliche Klassen verwenden, ohne den Core zu verändern
   ========================================================= */


/* =========================================================
   HEADER BASE
   ========================================================= */

.header {
    display: flex;
    align-items: center;
    justify-content: space-between;

    padding: 12px 20px;

    background: #ffffff;
    border-bottom: 1px solid #eeeeee;

    /*
     * Wichtig:
     * Dropdowns und mobile Menüs werden relativ zum Header positioniert.
     */
    position: relative;
    z-index: 5000;
}

.logo a {
    font-size: 20px;
    font-weight: 700;
    text-decoration: none;
    color: #111111;
}


/* =========================================================
   SEARCH BAR
   ========================================================= */

.search-bar {
    display: flex;
    flex: 1;

    max-width: 520px;
    margin: 0 20px;

    position: relative;
}

.search-bar input {
    flex: 1;

    padding: 11px 14px;

    border: 1px solid #dddddd;
    border-radius: 12px 0 0 12px;

    font-size: 14px;
}

.search-bar input:focus {
    outline: none;
    border-color: #111111;
}

.search-bar button {
    padding: 0 16px;

    border: none;
    border-radius: 0 12px 12px 0;

    background: #111111;
    color: #ffffff;

    cursor: pointer;
}


/* =========================================================
   DESKTOP NAVIGATION
   ========================================================= */

.nav {
    display: flex;
    align-items: center;
    gap: 12px;
}

/*
 * Gemeinsame Icon-Buttons im Header:
 * - Service
 * - Merkliste
 * - Warenkorb
 * - Account
 */
.header-icon-link,
.account-trigger {
    width: 42px;
    height: 42px;

    border-radius: 50%;

    display: inline-flex;
    align-items: center;
    justify-content: center;

    color: #111111;
    text-decoration: none;

    background: transparent;
    border: none;

    cursor: pointer;

    font-size: 20px;

    transition:
        background 0.2s ease,
        transform 0.2s ease;
}

.header-icon-link:hover,
.account-trigger:hover {
    background: #f5f5f5;
    transform: translateY(-1px);
}


/* =========================================================
   ACCOUNT DROPDOWN
   ========================================================= */

.account-menu-wrapper {
    position: relative;
    z-index: 6000;
}

.account-dropdown {
    position: absolute;
    top: calc(100% + 14px);
    right: 0;

    width: 340px;
    max-width: calc(100vw - 32px);

    padding: 22px;

    background: #ffffff;
    border: 1px solid #e9e9e9;
    border-radius: 20px;

    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.12);

    display: none;
    z-index: 99999;

    animation: fadeInDropdown 0.15s ease;
}

/*
 * Wird per shop-header.js gesetzt.
 */
.account-dropdown.open {
    display: block;
}

/*
 * Kleines Dreieck am Dropdown.
 */
.account-dropdown::before {
    content: "";

    position: absolute;
    top: -8px;
    right: 20px;

    width: 16px;
    height: 16px;

    background: #ffffff;

    border-top: 1px solid #e9e9e9;
    border-left: 1px solid #e9e9e9;

    transform: rotate(45deg);
}


/* =========================================================
   ACCOUNT CONTENT
   ========================================================= */

.account-section-title {
    margin-bottom: 18px;

    font-size: 20px;
    font-weight: 700;
}

.account-user-mail {
    margin-bottom: 14px;

    color: #777777;
    font-size: 14px;

    word-break: break-word;
}

.account-links {
    display: flex;
    flex-direction: column;
    gap: 8px;

    margin-bottom: 20px;
}

.account-links a {
    padding: 12px 14px;

    border-radius: 12px;

    color: #111111;
    text-decoration: none;

    font-size: 16px;

    transition: background 0.2s ease;
}

.account-links a:hover {
    background: #f6f6f6;
}

.account-primary-btn {
    display: block;

    width: 100%;
    padding: 15px 16px;
    margin-bottom: 14px;

    border: none;
    border-radius: 18px;

    background: #111111;
    color: #ffffff !important;

    text-align: center;
    text-decoration: none;

    font-weight: 700;

    cursor: pointer;

    transition: background 0.2s ease;
}

.account-primary-btn:hover {
    background: #333333;
}

.account-secondary-link {
    display: block;

    color: #111111;
    text-align: center;
    text-decoration: underline;

    font-size: 15px;
}

.logout-form {
    margin: 0;
}


/* =========================================================
   SEARCH SUGGESTIONS
   ========================================================= */

.suggestions-list {
    position: absolute;

    width: 100%;

    margin: 0;
    padding: 0;

    list-style: none;

    background: #ffffff;
    border: 1px solid #dddddd;
    border-radius: 12px;

    overflow: hidden;

    z-index: 99999;
}

.suggestions-list li {
    padding: 10px;
    cursor: pointer;
}

.suggestions-list li:hover {
    background: #f2f2f2;
}


/* =========================================================
   CART BADGE
   ========================================================= */

/*
 * Warenkorb-Link braucht position: relative,
 * damit das Badge am Icon sitzt.
 */
.cart-link {
    position: relative;
}

.cart-badge {
    position: absolute;
    top: 8px;
    right: 2px;

    min-width: 16px;
    height: 16px;
    padding: 0 5px;

    border-radius: 999px;

    background: #b2243f;
    color: #ffffff;

    font-size: 11px;
    font-weight: 700;
    line-height: 1;

    display: flex;
    align-items: center;
    justify-content: center;
}


/* =========================================================
   GENERIC HEADER BADGES
   =========================================================
   Diese Klassen sind absichtlich generisch.
   UI-Core kann sie für Merkliste/Warenkorb nutzen.
   Apps wie Billardshop können sie für Nachrichten-Badges verwenden.
   ========================================================= */

.wishlist-link,
.account-trigger-with-badge,
.menu-toggle-with-badge {
    position: relative;
}

/*
 * Kleine Badges direkt an Header-Icons.
 *
 * Beispiele:
 * - Merkliste am Herz
 * - Nachrichten am Account-Icon
 * - Nachrichten am Burger-Menü
 */
.header-counter-badge,
.account-header-badge,
.burger-menu-badge {
    position: absolute;
    top: -7px;
    right: -8px;

    min-width: 18px;
    height: 18px;
    padding: 0 5px;

    border-radius: 999px;

    background: #111111;
    color: #ffffff;

    font-size: 11px;
    font-weight: 800;
    line-height: 18px;
    text-align: center;

    box-shadow: 0 0 0 2px #ffffff;
}

/*
 * Menüzeilen mit Badge.
 *
 * Beispiele:
 * - Merkzettel 2
 * - Nachrichten 1
 * - Warenkorb 3
 */
.mobile-nav-link-with-badge,
.account-link-with-badge {
    display: flex !important;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.mobile-nav-badge,
.account-menu-badge {
    min-width: 22px;
    height: 22px;
    padding: 0 7px;

    border-radius: 999px;

    background: #111111;
    color: #ffffff;

    font-size: 12px;
    font-weight: 800;
    line-height: 22px;
    text-align: center;

    display: inline-flex;
    align-items: center;
    justify-content: center;
}


/* =========================================================
   MOBILE BURGER MENU
   ========================================================= */

.menu-toggle {
    /*
     * Desktop: ausgeblendet.
     * Mobile: wird im Media Query eingeblendet.
     */
    display: none;

    padding: 8px;

    border: none;
    background: transparent;

    color: #111111;

    font-size: 24px;
    line-height: 1;

    cursor: pointer;
}

/*
 * Mobile Menü ist standardmäßig versteckt.
 */
.mobile-nav {
    display: none;
}

/*
 * Links im Mobile-Menü.
 */
.mobile-nav a {
    padding: 10px 0;

    color: #111111;
    text-decoration: none;

    font-weight: 600;
}


/* =========================================================
   RESPONSIVE
   ========================================================= */

@media (max-width: 768px) {

    /*
     * Auf Mobile wird die Desktop-Suche ausgeblendet.
     * Es gibt eine eigene Suche im Burger-Menü.
     */
    .search-bar {
        display: none;
    }

    /*
     * Desktop-Navigation auf Mobile ausblenden.
     */
    .nav {
        display: none;
    }

    /*
     * Burger-Button anzeigen.
     */
    .menu-toggle {
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    /*
     * Wird von shop-header.js gesetzt:
     * mobileMenu.classList.toggle('active')
     /* Mobile-Menü direkt im normalen Dokumentfluss unter dem Header anzeigen */
.mobile-nav.active {
    display: flex !important;
    flex-direction: column;
    gap: 12px;

    position: relative;
    z-index: 99999;

    padding: 16px;

    background: #ffffff;
    border-top: 1px solid #eeeeee;
    border-bottom: 1px solid #eeeeee;

    box-shadow: 0 14px 35px rgba(0, 0, 0, 0.12);
}
}


/* =========================================================
   ANIMATION
   ========================================================= */

@keyframes fadeInDropdown {
    from {
        opacity: 0;
        transform: translateY(-6px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* =========================================================
   Billardshop Mobile Menü: Account-Bereich
   ========================================================= */

/*
 * Mobile Suchformular im Burger-Menü.
 */
.mobile-search-form {
    width: 100%;
    margin: 0 0 12px;
}

.mobile-search-input {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid #dddddd;
    border-radius: 12px;
    font-size: 16px;
}

/*
 * Gruppen im mobilen Menü.
 */
.mobile-nav-section,
.mobile-account-section {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/*
 * Titel "Mein Konto" im mobilen Menü.
 */
.mobile-nav-section-title {
    margin-top: 6px;
    margin-bottom: 4px;
    font-size: 15px;
    font-weight: 800;
    color: #111111;
}

/*
 * Anzeige des eingeloggten Users.
 */
.mobile-account-user {
    font-size: 13px;
    color: #777777;
    word-break: break-word;
    margin-bottom: 4px;
}

/*
 * Trennlinie zwischen Hauptnavigation und Account-Bereich.
 */
.mobile-nav-divider {
    height: 1px;
    background: #eeeeee;
    margin: 12px 0;
}

/*
 * Allgemeine Links im mobilen Menü.
 */
.mobile-nav a {
    color: #111111;
    text-decoration: none;
    font-weight: 600;
    padding: 10px 0;
}

/*
 * Login-Button für Gäste und Logout-Button für eingeloggte User.
 */
.mobile-auth-primary,
.mobile-logout-btn {
    width: 100%;
    min-height: 44px;

    border: none;
    border-radius: 14px;

    background: #111111;
    color: #ffffff !important;

    font-weight: 800;
    text-align: center;
    text-decoration: none;

    cursor: pointer;

    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/*
 * Registrieren-Link für Gäste.
 */
.mobile-auth-secondary {
    text-align: center;
    text-decoration: underline !important;
    font-weight: 600;
}

/*
 * Logout-Form im mobilen Menü.
 */
.mobile-logout-form {
    margin: 12px 0 0;
}

/* =========================================================
   Mobile Suche unter dem Header
   ========================================================= */

/*
 * Desktop: mobile Suchzeile verstecken.
 */
.mobile-search-row {
    display: none;

    background: #ffffff;
    border-bottom: 1px solid #eeeeee;

    padding: 10px 16px;
}

/*
 * Mobile Suchformular.
 */
.mobile-search-bar {
    display: flex;
    width: 100%;
}

/*
 * Mobile Suchfeld.
 */
.mobile-search-bar input {
    flex: 1;

    padding: 12px 14px;

    border: 1px solid #dddddd;
    border-right: none;
    border-radius: 12px 0 0 12px;

    font-size: 16px;
}

/*
 * Mobile Suchbutton.
 */
.mobile-search-bar button {
    padding: 0 16px;

    border: none;
    border-radius: 0 12px 12px 0;

    background: #111111;
    color: #ffffff;

    cursor: pointer;
}

/*
 * Mobile:
 * - Desktop-Suche im Header ausblenden
 * - Mobile-Suche unter dem Header anzeigen
 */
@media (max-width: 768px) {
    .search-bar {
        display: none;
    }

    .mobile-search-row {
        display: block;
    }
}

/* =========================================================
   Mobile Header wie App-Shop:
   Sortiment links, Logo, Icons rechts, Suche darunter
   ========================================================= */

/*
 * Desktop:
 * Sortiment-Button ist ausgeblendet.
 */
.mobile-sortiment-trigger {
    display: none;
}

/*
 * Mobile Suche ist auf Desktop versteckt.
 */
.mobile-search-row {
    display: none;
    background: #ffffff;
    border-bottom: 1px solid #eeeeee;
    padding: 8px 12px;
}

.mobile-search-bar {
    display: flex;
    width: 100%;
}

.mobile-search-bar input {
    flex: 1;
    padding: 11px 13px;
    border: 1px solid #dddddd;
    border-right: none;
    border-radius: 10px 0 0 10px;
    font-size: 15px;
}

.mobile-search-bar button {
    padding: 0 14px;
    border: none;
    border-radius: 0 10px 10px 0;
    background: #111111;
    color: #ffffff;
    cursor: pointer;
}

@media (max-width: 768px) {

    /*
     * Header wird mobile kompakt.
     */
    .header {
        padding: 6px 10px;
        gap: 8px;
        min-height: 54px;
    }

    /*
     * Alter Burger-Button wird nicht mehr verwendet.
     */
    .menu-toggle {
        display: none !important;
    }

    /*
     * Neuer Sortiment-Button.
     */
    .mobile-sortiment-trigger {
        display: inline-flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 1px;

        border: none;
        background: transparent;
        color: #111111;

        font-size: 20px;
        line-height: 1;

        cursor: pointer;
        padding: 2px 4px;
        min-width: 48px;
    }

    .mobile-sortiment-trigger span {
        font-size: 10px;
        font-weight: 600;
        line-height: 1.1;
    }

    /*
     * Logo mobile kompakter.
     */
    .logo a {
        font-size: 20px;
        font-weight: 800;
        white-space: nowrap;
    }

    /*
     * Desktop-Suche im Header ausblenden.
     * Mobile Suche darunter anzeigen.
     */
    .search-bar {
        display: none !important;
    }

    .mobile-search-row {
        display: block;
    }

    /*
     * Desktop-Navigation wird mobile als Icon-Leiste rechts genutzt.
     */
    .nav {
        display: flex !important;
        align-items: center;
        justify-content: flex-end;
        gap: 8px;
        margin-left: auto;
    }

    /*
     * Verkäufer-Button im Billardshop auf Mobile nicht in die Icon-Leiste quetschen.
     * Er bleibt in MyAccount/Seller-Onboarding erreichbar.
     */
    .header-sell-btn {
        display: none !important;
    }

    /*
     * Header-Icons mobile mit kleinem Text darunter.
     */
    .header-icon-link,
    .account-trigger {
        width: auto;
        height: auto;
        min-width: 34px;

        border-radius: 0;

        display: inline-flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;

        gap: 1px;

        font-size: 18px;
        padding: 2px 3px;

        background: transparent;
    }

    .header-icon-link::after,
    .account-trigger::after {
        content: attr(aria-label);
        font-size: 9px;
        font-weight: 500;
        line-height: 1.1;
        color: #111111;
        white-space: nowrap;
    }

    /*
     * Account-Dropdown auf Mobile als kleines Panel rechts.
     */
    .account-dropdown {
        position: fixed;
        top: 56px;
        right: 8px;
        width: min(340px, calc(100vw - 16px));
        max-width: calc(100vw - 16px);
        z-index: 99999;
    }
}

/* =========================================================
   Mobile Header: Sortiment statt Burger-Menü
   ========================================================= */

.mobile-sortiment-trigger {
    display: none;
}

@media (max-width: 768px) {

    /*
     * Der alte Burger-Button wird nicht mehr genutzt.
     */
    .menu-toggle {
        display: none !important;
    }

    /*
     * Neuer Sortiment-Button links.
     */
    .mobile-sortiment-trigger {
        display: inline-flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 2px;

        min-width: 52px;
        padding: 2px 4px;

        border: none;
        background: transparent;
        color: #111111;

        cursor: pointer;
    }

    .mobile-sortiment-trigger i {
        font-size: 22px;
        line-height: 1;
    }

    .mobile-sortiment-trigger span {
        font-size: 10px;
        font-weight: 600;
        line-height: 1.1;
    }

    .mobile-sortiment-trigger.is-open i {
        font-size: 20px;
    }
}