/* ============================================================
   XRechnungen – Navigation: Topbar, Nav-Auth, Profile Dropdown,
                             Lang-Picker, Theme-Toggle, Font-Size-Ctrl
   ============================================================ */

/* ── Skip-Link (WCAG 2.4.1) ─────────────────────────────── */
/* Visually hidden until keyboard focus, then shown above the topbar. */
.skip-link {
    position: absolute;
    top: -100px;
    left: 8px;
    z-index: 300;
    padding: 8px 14px;
    border-radius: var(--radius);
    /* Solid fill → --btn-bg/--btn-fg (WCAG AA in allen Themes, siehe variables.css) */
    background: var(--btn-bg);
    color: var(--btn-fg);
    font-weight: 600;
    text-decoration: none;
    transition: top .15s ease;
}
.skip-link:focus {
    top: 8px;
    box-shadow: var(--focus-ring);
}

/* ── Topbar ─────────────────────────────────────────────── */
.topbar {
    display: flex;
    align-items: center;
    gap: 18px;
    padding: 12px 24px;
    background: var(--topbar-bg);
    color: var(--topbar-fg);
    box-shadow: var(--shadow);
    flex-wrap: wrap;
    /* Sticky: bleibt beim Scrollen sichtbar; ermöglicht position:sticky der Dashboard-Sidebar */
    position: sticky;
    top: 0;
    z-index: 200;
}
.topbar .brand {
    display: flex; align-items: center; gap: 10px;
    text-decoration: none; color: #f1f5f9; font-weight: 700; font-size: 1.05em;
}
.topbar .logo {
    display: inline-flex; align-items: center; justify-content: center;
    width: 30px; height: 30px; border-radius: 8px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: #fff; font-weight: 800;
}
.topbar img.logo {
    background: none; object-fit: contain; flex-shrink: 0;
}
.topbar .nav { display: flex; gap: 4px; margin-left: 16px; flex: 1 1 auto; flex-wrap: wrap; }
.topbar .nav-link {
    text-decoration: none; color: #cbd5e1; padding: 6px 12px;
    border-radius: 6px; font-size: 0.92em;
    transition: background .15s, color .15s;
}
.topbar .nav-link:hover { background: rgba(255,255,255,0.08); color: #fff; }
.topbar .nav-link.active { background: color-mix(in srgb, var(--primary) 28%, transparent); color: #fff; }
.topbar .tag { color: #94a3b8; font-size: 0.78em; flex-shrink: 0; }

.topbar-controls {
    display: flex; align-items: center; gap: 8px; flex-shrink: 0;
}

/* ── Nav-Auth (Login / Register in header) ───────────────── */
.nav-auth {
    display: flex; align-items: center; gap: 6px; flex-shrink: 0; margin-left: 8px;
}
.nav-auth .nav-link { color: #cbd5e1; }
.nav-auth .nav-link:hover { color: #fff; }
/* Nav-auth button uses --btn-bg for solid contrast in all schemes */
.nav-auth .btn {
    background: var(--btn-bg); color: var(--btn-fg) !important;
    border: none; font-size: .85rem; padding: 5px 14px;
    border-radius: 6px; text-decoration: none; font-weight: 600;
}
.nav-auth .btn:hover { background: var(--btn-bg-hover); color: var(--btn-fg) !important; }

/* ── Hamburger (mobile only) ─────────────────────────────── */
.nav-hamburger {
    display: none;
    background: none;
    border: 1px solid rgba(255,255,255,.2);
    border-radius: 6px;
    color: var(--topbar-fg, #e2e8f0);
    font-size: 1.25rem;
    line-height: 1;
    cursor: pointer;
    padding: 5px 10px;
    margin-left: auto;
    flex-shrink: 0;
    transition: background .15s;
}
.nav-hamburger:hover { background: rgba(255,255,255,.1); }

/* ── Profile Dropdown ────────────────────────────────────── */
.prof-wrap { position: relative; }
.prof-trigger {
    width: 32px; height: 32px; border-radius: 50%; border: 2px solid rgba(255,255,255,.25);
    background: var(--btn-bg); color: var(--btn-fg); font-weight: 700; font-size: .95rem;
    cursor: pointer; display: grid; place-items: center; transition: border-color .15s;
    padding: 0; line-height: 1;
}
.prof-trigger:hover, .prof-trigger[aria-expanded="true"] {
    border-color: rgba(255,255,255,.7);
}
.prof-avatar { pointer-events: none; }
.prof-dropdown {
    position: absolute; right: 0; top: calc(100% + 8px); z-index: 200;
    width: 260px; background: var(--surface); border: 1px solid var(--border);
    border-radius: 12px; box-shadow: 0 12px 32px rgba(0,0,0,.2);
    display: none; flex-direction: column; overflow: hidden;
    animation: prof-in .12s ease;
}
@keyframes prof-in {
    from { opacity:0; transform:translateY(-6px) scale(.97); }
    to   { opacity:1; transform:none; }
}
.prof-dropdown.open { display: flex; }
.prof-header {
    display: flex; align-items: flex-start; gap: 12px; padding: 16px;
    background: color-mix(in srgb, var(--primary) 6%, var(--surface));
}
.prof-avatar-lg {
    width: 40px; height: 40px; border-radius: 50%; background: var(--btn-bg);
    color: var(--btn-fg); font-weight: 700; font-size: 1.1rem;
    display: grid; place-items: center; flex-shrink: 0;
}
.prof-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.prof-info strong { font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.prof-email { font-size: .75rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.prof-plan-badge {
    margin-top: 4px; display: inline-block; font-size: .68rem; font-weight: 700;
    padding: 2px 8px; border-radius: 999px; background: var(--surface-alt);
    border: 1px solid var(--border); color: var(--primary); white-space: nowrap;
}
.prof-sep { height: 1px; background: var(--border); margin: 2px 0; }
.prof-item {
    display: flex; align-items: center; gap: 8px;
    padding: 9px 16px; font-size: .86rem; color: var(--fg);
    text-decoration: none; transition: background .1s;
}
.prof-item-icon { width: 18px; text-align: center; flex-shrink: 0; font-style: normal; }
.prof-item:hover { background: var(--surface-alt); }
.prof-item-upgrade { font-weight: 600; }
.prof-footer { display: flex; justify-content: space-between; align-items: center; padding: 10px 16px 12px; }
.prof-logout {
    font-size: .82rem; color: var(--error); text-decoration: none; font-weight: 600;
    padding: 4px 10px; border-radius: 6px; border: 1px solid transparent;
    transition: border-color .12s;
}
.prof-logout:hover { border-color: var(--error); background: color-mix(in srgb,var(--error) 6%,transparent); }

/* ── Lang-Picker & Scheme-Picker ─────────────────────────── */
.lang-picker { margin: 0; display: flex; }
.lang-picker select,
.scheme-picker {
    background: rgba(255,255,255,0.10); color: #e2e8f0;
    border: 1px solid rgba(255,255,255,0.18);
    border-radius: 6px; padding: 5px 8px; font-size: 0.85em;
    cursor: pointer; min-width: 90px;
    transition: background .15s, border-color .15s;
}
.lang-picker select:hover,
.scheme-picker:hover {
    background: rgba(255,255,255,0.20);
    border-color: rgba(255,255,255,0.40);
    color: #fff;
}
/* Prevent light text on light bg in browser-native dropdowns */
.lang-picker select option,
.scheme-picker option {
    background: #1e293b;
    color: #e2e8f0;
}
html[data-theme="dark"] .lang-picker select option,
html[data-theme="dark"] .scheme-picker option {
    background: #0f172a;
    color: #e2e8f0;
}
.lang-picker select:focus,
.scheme-picker:focus,
.theme-toggle:focus {
    outline: 2px solid var(--primary); outline-offset: 1px;
}

/* ── Theme Toggle ────────────────────────────────────────── */
.theme-toggle {
    background: rgba(255,255,255,0.10); color: #e2e8f0;
    border: 1px solid rgba(255,255,255,0.18);
    border-radius: 6px; padding: 5px 10px; cursor: pointer;
    font-size: 0.95em;
    display: inline-flex; align-items: center; gap: 4px;
}
.theme-toggle:hover { background: rgba(255,255,255,0.18); }
.theme-toggle .ico-moon { display: none; }
html[data-theme="dark"] .theme-toggle .ico-sun  { display: none; }
html[data-theme="dark"] .theme-toggle .ico-moon { display: inline; }

/* ── Font-Size Controls ──────────────────────────────────── */
.font-sz-ctrl {
    display: flex; align-items: center; gap: 2px;
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.18);
    border-radius: 6px; padding: 1px 3px;
}
.font-sz-btn {
    background: none; border: none; cursor: pointer;
    color: #e2e8f0; font-weight: 700;
    padding: 3px 7px; border-radius: 4px; line-height: 1.4;
    transition: background .15s; font-size: .78rem;
}
.font-sz-btn:hover { background: rgba(255,255,255,0.18); }
.font-sz-btn.fsz-active { background: rgba(255,255,255,0.28); color:#fff; }
.font-sz-btn sup { font-size: .5rem; vertical-align: super; }

/* ── Mobile-only settings row inside profile dropdown ────────── */
.prof-mob-settings {
    padding: 8px 12px 4px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.prof-mob-row {
    display: flex;
    align-items: center;
    gap: 10px;
}
.prof-mob-lbl {
    font-size: 1rem;
    width: 22px;
    text-align: center;
    flex-shrink: 0;
}
.prof-mob-sel {
    flex: 1;
    padding: 7px 10px;
    font-size: .85rem;
    font-family: inherit;
    background: var(--surface-alt);
    border: 1px solid var(--border);
    border-radius: 7px;
    color: var(--fg);
    cursor: pointer;
    min-height: 38px;
}
.prof-mob-theme {
    flex: 1;
    padding: 7px 10px;
    font-size: .85rem;
    font-family: inherit;
    background: var(--surface-alt);
    border: 1px solid var(--border);
    border-radius: 7px;
    color: var(--fg);
    cursor: pointer;
    text-align: left;
    min-height: 38px;
}
.prof-mob-theme:hover { background: var(--border); }
/* Show mobile settings row only at ≤768px */
@media (max-width: 768px) {
    .prof-mob-only,
    .prof-mob-settings { display: flex !important; }
}

/* ── Mobile drag handle (visible only on ≤768px) ─────────── */
.prof-drag-handle {
    display: none;              /* hidden on desktop */
    width: 36px; height: 4px;
    background: var(--border);
    border-radius: 2px;
    margin: 10px auto 2px;
    flex-shrink: 0;
}
@media (max-width: 768px) {
    .prof-drag-handle { display: block; }
}

/* ── Mobile bottom-sheet overlay ────────────────────────── */
.prof-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .45);
    z-index: 199;          /* below dropdown (z-index: 200) */
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    animation: overlay-in .2s ease;
}
.prof-overlay.visible { display: block; }
@keyframes overlay-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}
/* Only on mobile — desktop dropdown doesn't need overlay */
@media (min-width: 769px) {
    .prof-overlay { display: none !important; }
}
