/* Theme controller and palette. Product CSS keeps its original light fallbacks. */
:root { color-scheme: light; }
:root[data-theme="dark"] {
    color-scheme: dark;
    --theme-background: #10151f;
    --theme-surface: #1b2331;
    --theme-surface-muted: #242e3e;
    --theme-surface-active: #303e53;
    --theme-text: #edf2f8;
    --theme-muted: #b1bfd1;
    --theme-border: #465670;
    --theme-border-strong: #73849c;
    --theme-accent-text: #d4b4ff;
    --theme-accent-surface: #342746;
    --theme-accent-border: #8e70b2;
    --theme-success-text: #8fe0b5;
    --theme-success-surface: #19392c;
    --theme-success-border: #4f9975;
    --theme-danger-text: #ffadb8;
    --theme-danger-surface: #40242d;
    --theme-danger-border: #b06b78;
    --theme-warning-text: #f6cf86;
    --theme-warning-surface: #3e321e;
    --theme-warning-border: #a98a50;
    --theme-info-text: #a6d2ff;
    --theme-info-surface: #1c344e;
    --theme-info-border: #608fbf;
    --theme-on-color: #ffffff;
}
.theme-menu[hidden] { display: none !important; }
.theme-menu { position: relative; flex: 0 0 auto; width: auto; margin-left: auto; text-align: left; }
.theme-menu > summary {
    display: inline-flex; align-items: center; justify-content: center;
    box-sizing: border-box; width: 44px; height: 44px; padding: 0;
    cursor: pointer; list-style: none;
}
.theme-menu > summary::-webkit-details-marker { display: none; }
.theme-menu > summary:focus-visible { outline: 2px solid var(--app-on-chrome); outline-offset: 2px; }
.theme-menu > summary svg { width: 22px; height: 22px; flex: none; fill: currentColor; }
.theme-menu .theme-options {
    position: absolute; top: calc(100% + 8px); right: 0; z-index: 150;
    box-sizing: border-box; width: 220px; padding: 14px; border: 1px solid #64748b;
    border-radius: 10px; color: var(--theme-text, #25222a); background: var(--theme-surface, #fff);
    box-shadow: 0 8px 28px rgba(0,0,0,.25);
}
.theme-menu .theme-options { display: grid; gap: 4px; padding: 8px; }
.theme-menu .theme-option {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    box-sizing: border-box; width: 100%; min-width: 0; min-height: 44px; margin: 0; padding: 10px 12px;
    border: 1px solid transparent; border-radius: 6px; text-align: left;
    color: var(--theme-text, #25222a); background: transparent; font: inherit; font-size: 14px; cursor: pointer;
}
.theme-menu .theme-option:hover,
.theme-menu .theme-option[aria-pressed="true"] {
    color: var(--theme-accent-text, var(--app-accent-dark, #5c2d91));
    background: var(--theme-accent-surface, var(--app-accent-soft, #eee7f4));
}
.theme-menu .theme-option[aria-pressed="true"]::after { content: "✓"; font-weight: 800; }
.theme-menu .theme-option:focus-visible { outline: 3px solid #b18be4; outline-offset: -2px; }
.app-header-inner:has(.theme-menu) { align-items: center; }
.app-header-inner:has(.theme-menu) .app-page-title { flex: 1; min-width: 0; }
@media (max-width: 760px) {
    .theme-menu > summary > span { display: none; }
    .header-row:has(.theme-menu) { gap: 8px; }
    .header-row:has(.theme-menu) .header-user-controls { max-width: 27%; }
    .header-row:has(.theme-menu) .header-user-controls .user-name { display: none; }
    .app-header-inner:has(.theme-menu) { gap: 10px; }
    .app-header-inner:has(.theme-menu) .app-brand { font-size: 24px; }
    .app-header-inner:has(.theme-menu) .app-page-title { font-size: 13px; overflow-wrap: anywhere; }
}

@media (max-width: 600px) {
    .app-header-inner:has(.theme-menu:not([hidden])) {
        display: grid;
        grid-template-columns: 44px minmax(0, 1fr) 44px;
        gap: 4px 8px;
        justify-items: center;
        text-align: center;
    }
    .app-header-inner:has(.theme-menu:not([hidden])) > :is(.app-brand, .app-page-title) {
        grid-column: 2;
    }
    .app-header-inner > .theme-menu:not([hidden]) {
        grid-column: 3;
        grid-row: 1 / 3;
        justify-self: end;
    }
}

:root[data-theme="dark"] {
    --theme-accent-text: #ffb47e; --theme-accent-surface: #402d23; --theme-accent-border: #b8825d;
    --app-ink: var(--theme-text); --app-muted: var(--theme-muted);
    --app-surface: var(--theme-surface); --app-surface-muted: var(--theme-surface-muted);
    --app-background: var(--theme-background); --app-border: var(--theme-border);
    --app-accent-soft: var(--theme-accent-surface); --app-row-hover: var(--theme-surface-active);
    --app-danger-soft: var(--theme-danger-surface);
    --app-shadow: 0 8px 24px rgba(0,0,0,.28);
}
:root[data-theme="dark"] .booking-months .booking-month[aria-current="page"],
:root[data-theme="dark"] .buchungen-form .booking-primary { color: #fff; }
:root[data-theme="dark"] .booking-months .booking-month[aria-current="page"]:hover,
:root[data-theme="dark"] .buchungen-form .booking-primary:hover { background: #74401f; color: #fff; }
