/**
 * Unified Hamburger Menu — funktioniert auf Desktop, Tablet, Mobile und WebView.
 *
 * Vorher: app-menu war nur in der nativen WebView-App sichtbar.
 * Jetzt: Hamburger-Drawer auf ALLEN Plattformen — einheitliche Nav-UX.
 *
 * @license Kommerzielle Nutzung nur mit gueltiger Lizenz von 4Unit Systems Integration GmbH
 */

/* ============================================================
 * Hamburger-Button im Header (Desktop + Mobile sichtbar)
 * ============================================================ */
.unified-menu-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 8px;
    background: transparent;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 6px;
    cursor: pointer;
    color: currentColor;
    transition: background-color 0.15s ease;
}

.unified-menu-btn:hover {
    background: rgba(0, 0, 0, 0.05);
}

.unified-menu-btn:focus {
    outline: 2px solid var(--theme-primary, #E87722);
    outline-offset: 2px;
}

.unified-menu-btn svg {
    width: 24px;
    height: 24px;
}

/* ============================================================
 * Slide-In-Drawer
 * ============================================================ */
.app-menu-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 10000;
    background: rgba(0, 0, 0, 0.5);
    animation: unified-menu-fade-in 0.2s ease;
}

.app-menu-overlay.open {
    display: block;
}

@keyframes unified-menu-fade-in {
    from { background: rgba(0, 0, 0, 0); }
    to   { background: rgba(0, 0, 0, 0.5); }
}

.app-menu-panel {
    position: absolute;
    top: 0;
    right: 0;
    width: 320px;
    max-width: 90vw;
    height: 100%;
    background: #fff;
    box-shadow: -4px 0 16px rgba(0, 0, 0, 0.15);
    overflow-y: auto;
    animation: unified-menu-slide-in 0.25s ease;
}

@keyframes unified-menu-slide-in {
    from { transform: translateX(100%); }
    to   { transform: translateX(0); }
}

.app-menu-header {
    position: relative;
    background: var(--theme-primary, #E87722);
    color: #fff;
    padding: 24px 20px;
    padding-top: calc(24px + env(safe-area-inset-top));
}

.app-menu-header h3 {
    margin: 0 0 4px;
    font-size: 1.15rem;
    font-weight: 600;
}

.app-menu-header small {
    opacity: 0.85;
    font-size: 0.85rem;
}

.app-menu-close {
    position: absolute;
    top: 14px;
    right: 14px;
    top: calc(14px + env(safe-area-inset-top));
    width: 32px;
    height: 32px;
    border: none;
    background: rgba(255, 255, 255, 0.22);
    color: #fff;
    border-radius: 50%;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.app-menu-close:hover {
    background: rgba(255, 255, 255, 0.35);
}

.app-menu-items {
    padding: 8px 0;
}

.app-menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 20px;
    color: #333;
    text-decoration: none;
    font-size: 0.95rem;
    border-bottom: 1px solid #f5f5f5;
    transition: background-color 0.12s ease;
}

.app-menu-item:hover,
.app-menu-item:active {
    background: #f5f5f5;
    color: #333;
    text-decoration: none;
}

.app-menu-item.active {
    background: rgba(232, 119, 34, 0.08);
    color: var(--theme-primary, #E87722);
    font-weight: 500;
}

.app-menu-item svg {
    width: 20px;
    height: 20px;
    color: #888;
    flex-shrink: 0;
}

.app-menu-item .fi {
    width: 1.4em;
    flex-shrink: 0;
}

.app-menu-divider {
    height: 8px;
    background: #f5f5f5;
}

/* ============================================================
 * Profil-Accordion (natives <details>/<summary>, kein JS)
 * ============================================================ */
.app-menu-profile {
    border-bottom: 1px solid #f5f5f5;
}

/* Summary als regulaeres Menue-Item, ohne Default-Marker */
.app-menu-profile-summary {
    border-bottom: none;
    cursor: pointer;
    list-style: none;
    user-select: none;
    -webkit-user-select: none;
}

/* Default-Disclosure-Dreieck entfernen (WKWebView/Safari + Firefox) */
.app-menu-profile-summary::-webkit-details-marker {
    display: none;
}
.app-menu-profile-summary::marker {
    content: '';
}

/* Chevron rechtsbuendig, dreht beim Aufklappen */
.app-menu-chevron {
    margin-left: auto;
    width: 16px;
    height: 16px;
    color: #888;
    flex-shrink: 0;
    transition: transform 0.2s ease;
}
.app-menu-profile[open] .app-menu-chevron {
    transform: rotate(180deg);
}

/* Untermenue: leicht abgesetzter Hintergrund + eingerueckte Items */
.app-menu-submenu {
    background: #fafafa;
}
.app-menu-submenu .app-menu-subitem {
    padding-left: 52px;
    font-size: 0.9rem;
}
.app-menu-submenu .app-menu-subitem:last-child {
    border-bottom: none;
}
.app-menu-submenu .app-menu-subitem svg {
    width: 18px;
    height: 18px;
}

/* Body-Scroll-Lock waehrend Menu offen ist */
body.menu-open {
    overflow: hidden;
}

/* ============================================================
 * Adress-Dropdown (app-address-dropdown.js, 2026-06-10)
 * Gemeinsam für App-WebView (#appAddressDropdown) und Desktop/Web
 * (#addressDropdown). Hier (statt webview-overrides.css), damit es auch
 * im Desktop-Header geladen wird.
 * ============================================================ */
.app-addr-dd {
    position: absolute;
    top: 100%;
    right: 8px;
    width: min(360px, calc(100vw - 16px));
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
    padding: 12px;
    z-index: 10000;
    max-height: calc(100vh - 70px);
    overflow-y: auto;
    animation: app-addr-dd-in 0.18s ease;
}
.app-addr-dd[hidden] {
    display: none;
}

/* Desktop/Web-Variante: unter dem Adress-Badge verankert */
.address-badge-wrap {
    position: relative;
}
.addr-dd-desktop {
    top: calc(100% + 8px);
    right: 0;
}

/* Phone-Web (≤575px): der Badge sitzt nicht am rechten Rand → das 360px-Panel
   würde links überlaufen. Daher am Viewport verankern (unter dem ~64px hohen
   top-header). Betrifft NUR den Web-Header (.addr-dd-desktop), nicht die App. */
@media (max-width: 575.98px) {
    .addr-dd-desktop {
        position: fixed;
        top: 64px;
        left: 8px;
        right: 8px;
        width: auto;
        max-width: none;
    }
}

@keyframes app-addr-dd-in {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
}

.app-addr-dd-searchrow {
    display: flex;
    gap: 8px;
    align-items: center;
}
.app-addr-dd-input {
    flex: 1;
    min-width: 0;
    border: 1px solid #ddd;
    border-radius: 10px;
    padding: 10px 12px;
    /* 16px: verhindert das automatische iOS-Zoomen beim Fokussieren (< 16px → Zoom
       + Scroll-to-input, was als "Seite wischt" wahrgenommen wird). */
    font-size: 16px;
    color: #333;
    outline: none;
}
.app-addr-dd-input:focus {
    border-color: var(--theme-primary, #E87722);
}
.app-addr-dd-geo {
    flex-shrink: 0;
    width: 42px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--theme-primary, #E87722);
    color: #fff;
    border: none;
    border-radius: 10px;
    cursor: pointer;
}
.app-addr-dd-geo:active {
    opacity: 0.85;
}
.app-addr-dd-geo.loading {
    opacity: 0.6;
    pointer-events: none;
}

.app-addr-dd-autocomplete:not(:empty) {
    margin-top: 8px;
}
.app-addr-dd-recent {
    margin-top: 12px;
}
.app-addr-dd-recent[hidden] {
    display: none;
}
.app-addr-dd-recent-title {
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: #999;
    padding: 4px 4px 6px;
}

.app-addr-dd-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    text-align: left;
    background: transparent;
    border: none;
    padding: 11px 8px;
    border-radius: 8px;
    cursor: pointer;
    color: #333;
    font-size: 0.9rem;
}
.app-addr-dd-item:hover,
.app-addr-dd-item:active {
    background: #f5f5f5;
}
.app-addr-dd-item svg {
    flex-shrink: 0;
    color: var(--theme-primary, #E87722);
}
.app-addr-dd-item-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Recent-Eintrag mit Lösch-Button */
.app-addr-dd-recent-row {
    display: flex;
    align-items: center;
}
.app-addr-dd-recent-row .app-addr-dd-recent-item {
    flex: 1;
    min-width: 0;
}
.app-addr-dd-recent-del {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    color: #bbb;
}
.app-addr-dd-recent-del:hover,
.app-addr-dd-recent-del:active {
    background: #f0f0f0;
    color: #e74c3c;
}

/* "Ändern" ist jetzt ein <span> (kein Link mehr) — Cursor/Look beibehalten */
.change-address-btn {
    cursor: pointer;
}
