/* ==========================================================
   base.css — globale Styles + Hell/Dunkel-Modus
   ==========================================================
   Theme-Variablen kommen aus zwei Quellen:
   1) Brand-Farben (--primary, --accent ...) werden vom Server
      pro Tenant gerendert (siehe View::brandStyles()).
   2) UI-Variablen (--bg, --text, --surface ...) sind hier
      definiert und switchen ueber [data-theme="light"|"dark"]
      auf <html>.
   ========================================================== */

/* ---------- Light theme (default) ---------- */
:root,
:root[data-theme="light"] {
    --bg:           #ffffff;
    --bg-alt:       #f9fafb;
    --surface:      #ffffff;
    --surface-alt:  #f3f4f6;
    --text:         #1d2432;
    --text-muted:   #6b7280;
    --border:       #e5e7eb;
    --border-strong:#d1d5db;
    --shadow:       0 4px 32px rgba(0,0,0,0.08), 0 1px 3px rgba(0,0,0,0.06);
    --shadow-sm:    0 1px 2px rgba(0,0,0,0.04);
    --logo-light-display: block;
    --logo-dark-display:  none;
}

/* ---------- Dark theme ---------- */
:root[data-theme="dark"] {
    --bg:           #0f172a;
    --bg-alt:       #111827;
    --surface:      #1e293b;
    --surface-alt:  #283449;
    --text:         #e5e7eb;
    --text-muted:   #94a3b8;
    --border:       #334155;
    --border-strong:#475569;
    --shadow:       0 4px 32px rgba(0,0,0,0.5), 0 1px 3px rgba(0,0,0,0.3);
    --shadow-sm:    0 1px 2px rgba(0,0,0,0.3);
    --logo-light-display: none;
    --logo-dark-display:  block;
}

/* ---------- Auto via prefers-color-scheme ----------
   Greift wenn KEIN data-theme gesetzt ist, also User noch
   nichts manuell gewaehlt hat. */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme]) {
        --bg:           #0f172a;
        --bg-alt:       #111827;
        --surface:      #1e293b;
        --surface-alt:  #283449;
        --text:         #e5e7eb;
        --text-muted:   #94a3b8;
        --border:       #334155;
        --border-strong:#475569;
        --shadow:       0 4px 32px rgba(0,0,0,0.5), 0 1px 3px rgba(0,0,0,0.3);
        --shadow-sm:    0 1px 2px rgba(0,0,0,0.3);
        --logo-light-display: none;
        --logo-dark-display:  block;
    }
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; margin: 0; padding: 0; }

/* HTML hidden-Attribut muss immer gewinnen */
[hidden] { display: none !important; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
                 "Helvetica Neue", Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    transition: background-color 200ms, color 200ms;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- Logo-Switching ----------
   Im HTML steht <img class="logo-light"> + <img class="logo-dark">.
   CSS zeigt jeweils das passende basierend auf data-theme. */
.logo-light { display: var(--logo-light-display); }
.logo-dark  { display: var(--logo-dark-display);  }

/* ---------- Theme-Toggle-Button ---------- */
.theme-toggle {
    background: var(--surface-alt);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 6px 8px;
    border-radius: 6px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 13px;
    transition: background 120ms;
}
.theme-toggle:hover { background: var(--border); }
.theme-toggle svg { width: 16px; height: 16px; }
/* Sonne im Light-Mode anzeigen, Mond im Dark-Mode */
.theme-toggle .icon-sun  { display: var(--logo-light-display); }
.theme-toggle .icon-moon { display: var(--logo-dark-display); }

/* ---------- Auth-Pages ---------- */
.auth-shell {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 24px;
    background: linear-gradient(180deg,
        var(--bg) 0%,
        color-mix(in srgb, var(--primary) 8%, var(--bg)) 100%);
}

.auth-card {
    width: 100%;
    max-width: 420px;
    background: var(--surface);
    border-radius: 12px;
    padding: 32px;
    box-shadow: var(--shadow);
    position: relative;
}

.auth-theme-toggle {
    position: absolute;
    top: 12px;
    right: 12px;
}

.auth-logo {
    max-width: 220px;
    height: auto;
    margin: 0 auto 28px;
}
.auth-logo-wrap {
    text-align: center;
}

.auth-title {
    text-align: center;
    margin: 0 0 28px;
    color: var(--primary);
}

.auth-form { display: flex; flex-direction: column; gap: 16px; }

.form-row { display: flex; flex-direction: column; gap: 6px; }
.form-row span {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
}
.form-row input {
    padding: 12px 14px;
    border: 1px solid var(--border-strong);
    border-radius: 8px;
    font-size: 16px;
    font-family: inherit;
    background: var(--surface);
    color: var(--text);
    transition: border-color 120ms, box-shadow 120ms;
}
.form-row input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 20%, transparent);
}

.btn {
    border: none;
    cursor: pointer;
    font-family: inherit;
    font-size: 16px;
    font-weight: 600;
    padding: 12px 20px;
    border-radius: 8px;
    transition: background 120ms, transform 60ms;
}
.btn:active { transform: scale(0.98); }
.btn-primary {
    background: var(--primary);
    color: #fff;
}
.btn-primary:hover { background: var(--primary-dark); }

.btn-link {
    background: none;
    border: none;
    color: var(--primary);
    cursor: pointer;
    font: inherit;
    padding: 0;
}
.btn-link:hover { text-decoration: underline; }

.alert {
    padding: 12px 14px;
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: 14px;
}
.alert-error {
    background: color-mix(in srgb, #ef4444 12%, var(--surface));
    color: #b91c1c;
    border: 1px solid color-mix(in srgb, #ef4444 30%, transparent);
}
:root[data-theme="dark"] .alert-error {
    color: #fca5a5;
}

.auth-meta {
    margin-top: 16px;
    text-align: center;
    font-size: 14px;
}

.auth-subtitle {
    text-align: center;
    margin: 0 0 12px;
    color: var(--text);
    font-size: 22px;
    font-weight: 700;
}

.auth-desc {
    text-align: center;
    margin: 0 0 24px;
    color: var(--text-muted);
    font-size: 14px;
    line-height: 1.5;
}

.code-input {
    text-align: center;
    letter-spacing: 8px;
    font-size: 22px !important;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-weight: 700;
}

.auth-footer {
    margin-top: 32px;
    color: var(--text-muted);
    font-size: 13px;
}
.auth-footer a { color: var(--text-muted); }

/* ---------- Legal-Pages ---------- */
.legal-header {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 24px;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
}
.back-link { font-size: 14px; }
.legal-logo { height: 32px; }

.legal-content {
    max-width: 720px;
    margin: 32px auto;
    padding: 0 24px;
    line-height: 1.6;
    color: var(--text);
}
.legal-content h1 { color: var(--primary); }
.legal-content h2 { margin-top: 28px; }
