/* =============================================================================
 * Rauchcheck – assets/css/styles.css
 * Mobile-first, kein Framework. Beide Themes (hell/dunkel) über [data-theme].
 * Cache-Buster: ?v=<RC_VERSION> (wird von index.php injected).
 * ============================================================================= */

/* ---------- Design-Token ---------- */
:root {
    --rc-bg:            #f5f6f7;
    --rc-surface:       #ffffff;
    --rc-text:          #1c1e21;
    --rc-text-muted:    #5c636c;
    --rc-primary:       #0f766e;
    --rc-primary-ink:   #ffffff;
    --rc-accent:        #ea580c;
    --rc-border:        #d5d9de;
    --rc-focus:         #1d4ed8;
    --rc-ok:            #15803d;   /* AA: 5.02:1 on surface light */
    --rc-warn:          #b45309;   /* AA: 5.02:1 */
    --rc-err:           #b42318;   /* AA: 6.57:1 */
    --rc-info:          #0369a1;   /* AA: 5.93:1 */
    --rc-notice-bg:     #eff6ff;
    --rc-notice-border: #93c5fd;
    --rc-radius:        12px;
    --rc-cta-h:         3.25rem;
}

[data-theme="dark"] {
    --rc-bg:            #111418;
    --rc-surface:       #1b2026;
    --rc-text:          #e7e9ec;
    --rc-text-muted:    #a3abb5;
    --rc-primary:       #2dd4bf;
    --rc-primary-ink:   #062824;
    --rc-accent:        #fb923c;
    --rc-border:        #2c343d;
    --rc-focus:         #93c5fd;
    --rc-ok:            #4ade80;   /* AA: 9.4:1 on surface dark */
    --rc-warn:          #fbbf24;   /* AA: 9.8:1 */
    --rc-err:           #fca5a5;   /* AA: 8.6:1 */
    --rc-info:          #7dd3fc;   /* AA: 9.8:1 */
    --rc-notice-bg:     #17233b;
    --rc-notice-border: #2b4a7e;
}

/* ---------- Basis ---------- */
*, *::before, *::after { box-sizing: border-box; }

html {
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    background: var(--rc-bg);
    color: var(--rc-text);
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 1rem;
    line-height: 1.55;
}

/* Sichtbarer Fokusring für Tastatur-Nutzer */
:focus-visible {
    outline: 3px solid var(--rc-focus);
    outline-offset: 2px;
    border-radius: 4px;
}

/* Skip-Link für Screenreader/Tastatur */
.skip-link {
    position: absolute;
    left: -9999px;
    top: 0;
    z-index: 100;
    background: var(--rc-primary);
    color: var(--rc-primary-ink);
    padding: 0.5rem 1rem;
    border-radius: 0 0 var(--rc-radius) 0;
    text-decoration: none;
}
.skip-link:focus {
    left: 0;
}

/* ---------- Kopfzeile ---------- */
.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.75rem 1rem calc(0.75rem + env(safe-area-inset-top, 0px));
    border-bottom: 1px solid var(--rc-border);
    background: var(--rc-surface);
}

.app-header__brand {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    min-width: 0;
}

.app-header__logo {
    flex: 0 0 auto;
    width: 2.5rem;
    height: 2.5rem;
}

.app-header__name {
    font-weight: 700;
    font-size: 1.15rem;
    letter-spacing: 0.01em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Theme-Umschalter (Sun/Moon) */
.theme-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 3rem;
    height: 3rem;
    border: 1px solid var(--rc-border);
    border-radius: 50%;
    background: var(--rc-surface);
    color: var(--rc-text);
    font-size: 1.25rem;
    cursor: pointer;
    padding: 0;
}
.theme-toggle:active { transform: scale(0.96); }
.theme-toggle__icon { pointer-events: none; }
[data-theme="light"] .theme-toggle__icon--dark { display: none; }
[data-theme="dark"]  .theme-toggle__icon--light { display: none; }

/* ---------- Hauptbereich ---------- */
.app-main {
    flex: 1 0 auto;
    width: 100%;
    max-width: 42rem;
    margin: 0 auto;
    padding: 1.25rem 1rem 2.5rem;
}

.home__lead {
    font-size: 1.1rem;
    margin-top: 0.25rem;
}

.home__status {
    color: var(--rc-text-muted);
}

/* Zentrale Information (Pflichttext) */
.notice {
    margin: 1.5rem 0;
    padding: 1rem 1.1rem;
    background: var(--rc-notice-bg);
    border: 1px solid var(--rc-notice-border);
    border-radius: var(--rc-radius);
}
.notice h2 {
    margin: 0 0 0.35rem;
    font-size: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--rc-text-muted);
}
.notice__text {
    margin: 0;
    font-size: 1.02rem;
}

/* Nacht-Fenster-Untzeile in der Info-Karte (rein neutrale Farben). */
.notice__window { display:flex; gap:0.5rem; align-items:baseline; margin:0.35rem 0 0 0; font-size:0.9rem; color:var(--rc-text-muted); }
.notice__window-state { font-weight:600; color:var(--rc-text); }
.notice__window-times { color:var(--rc-text-muted); }
.notice-card { margin:0; background:var(--rc-notice-bg); border:1px solid var(--rc-notice-border); border-radius:var(--rc-radius); padding:0.9rem 1rem; margin-bottom:1rem; }
.notice-card--settings { margin-bottom:0; }
.notice-card .notice-heading { margin:0 0 0.3rem; font-size:1rem; text-transform:uppercase; letter-spacing:0.04em; color:var(--rc-text-muted); }
.notice-card .notice__text { margin:0; }

.ios-hint {
    margin: 1.5rem 0 0;
    padding: 0.9rem 1.1rem;
    border: 1px dashed var(--rc-border);
    border-radius: var(--rc-radius);
    color: var(--rc-text-muted);
}
.ios-hint h2 {
    margin: 0 0 0.3rem;
    font-size: 0.95rem;
    color: var(--rc-text);
}
.ios-hint p { margin: 0; }

/* ---------- Fußzeile ---------- */
.app-footer {
    flex-shrink: 0;
    margin-top: auto;
    padding: 1rem 1rem calc(1rem + env(safe-area-inset-bottom, 0px));
    border-top: 1px solid var(--rc-border);
    background: var(--rc-surface);
    font-size: 0.9rem;
    color: var(--rc-text-muted);
    text-align: center;
}
.app-footer a {
    color: var(--rc-primary);
    text-decoration: underline;
}
.app-footer__build {
    margin: 0.25rem 0 0;
    font-size: 0.8rem;
}

/* ---------- Reduzierte Bewegung ---------- */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
    }
}

/* =============================================================================
 * Stage 5 – App (app.php): riesige Rauch-Status-Tasten, mobile-first
 * Farben: Vorwarnung=Orange, Aktiv=Rot, Beendet=Grün, HeuteNicht=Blau-Grau
 * ============================================================================= */
.smoke-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  margin: 18px 0;
}
@media (min-width: 560px) {
  .smoke-grid { grid-template-columns: 1fr 1fr; }
}

.smoke-btn {
  display: block;
  width: 100%;
  min-height: 112px;
  padding: 20px 16px;
  font-size: 1.45rem;
  font-weight: 700;
  line-height: 1.25;
  text-align: center;
  color: #fff;
  border: none;
  border-radius: 18px;
  cursor: pointer;
  box-shadow: 0 3px 0 rgba(0,0,0,.25);
  transition: transform .06s ease, filter .15s ease;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.smoke-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(0,0,0,.25); }
.smoke-btn:disabled { filter: grayscale(.4) opacity(.6); cursor: wait; }
.smoke-btn--warn   { background: #c2410c; } /* Stage 9: dunkleres Orange (AA) */ /* Vorwarnung: Orange  */
.smoke-btn--active { background: #dc2626; } /* Aktiv:       Rot     */
.smoke-btn--done   { background: #15803d; } /* Stage 9: dunkleres Gruen (AA) */ /* Beendet:     Grün   */
.smoke-btn--noday  { background: #64748b; } /* Heute nicht: Blau-Grau */
@media (prefers-contrast: more) {
  .smoke-btn { outline: 2px solid rgba(0,0,0,.5); }
}

/* ---------- App-Schale (app.php) ---------- */
.app-main { max-width: 560px; margin: 0 auto; padding: 16px 14px 40px; }
.card {
  background: var(--rc-surface);
  border: 1px solid var(--rc-border);
  border-radius: var(--rc-radius);
  padding: 22px 20px;
  margin: 14px 0;
}
.hint { color: var(--rc-text-muted); font-size: .95rem; }
.note-label { display: block; margin-top: 10px; font-weight: 600; }
.note-input {
  display: block; width: 100%; box-sizing: border-box;
  margin-top: 6px; padding: 12px 14px;
  font-size: 1rem; font-family: inherit;
  border: 1px solid var(--rc-border); border-radius: 10px;
  background: var(--rc-bg); color: var(--rc-text);
}
.smoke-result {
  margin-top: 16px; padding: 14px; border-radius: 10px;
  font-size: 1.05rem; font-weight: 600; text-align: center;
  border: 2px solid transparent;
}
.smoke-result:empty { display: none; }
.smoke-result--ok    { background: #dcfce7; color: #14532d; border-color: #16a34a; }
.smoke-result--err   { background: #fee2e2; color: #7f1d1d; border-color: #dc2626; }
.smoke-result--busy  { background: #e0f2fe; color: #0c4a6e; border-color: #0284c7; }

.event-list { list-style: none; margin: 12px 0 0; padding: 0; }
.event-list li {
  padding: 12px 10px; margin-bottom: 8px;
  border: 1px solid var(--rc-border); border-radius: 10px;
  font-size: .98rem; line-height: 1.4;
}
.event-list .ev-type { font-weight: 700; }
.event-list .ev-meta { color: var(--rc-text-muted); font-size: .85rem; }
.more-btn {
  display: block; width: 100%; margin-top: 10px;
  padding: 12px; font-size: 1rem; font-weight: 600;
  background: var(--rc-primary); color: var(--rc-primary-ink);
  border: none; border-radius: 10px; cursor: pointer;
}
.app-header__tag {
  margin-left: 8px; font-size: .75rem; font-weight: 600;
  background: var(--rc-primary); color: var(--rc-primary-ink);
  border-radius: 6px; padding: 2px 8px;
}
.app-header__user { display: flex; align-items: center; gap: 10px; font-size: .9rem; }
#appLogout {
  background: none; border: 1px solid var(--rc-border); border-radius: 8px;
  padding: 6px 10px; font-size: .85rem; cursor: pointer; color: var(--rc-text);
}

/* ---------- Phase 6: Push-Verwaltung ---------- */
.push-btns { display: flex; flex-direction: column; gap: 12px; margin: 16px 0; }
.push-btn {
  min-height: 64px; font-size: 1.15rem; font-weight: 700; border-radius: 14px;
  border: none; cursor: pointer; color: #fff; transition: transform .06s ease;
}
.push-btn:active { transform: scale(.98); }
.push-btn--on  { background: linear-gradient(135deg, #16a34a, #15803d); }
.push-btn--off { background: linear-gradient(135deg, #475569, #334155); }
.push-status { min-height: 1.4em; font-size: 1rem; font-weight: 600; margin-top: 8px; }
.push-status--ok     { color: var(--rc-ok); }
.push-status--warn   { color: var(--rc-warn); }
.push-status--off    { color: var(--rc-text-muted); }
.push-status--busy   { color: var(--rc-info); }
.push-ios {
  background: #f1f5f9; border: 1px solid #cbd5e1; border-radius: 12px;
  padding: 14px 16px; margin: 12px 0; font-size: .98rem; line-height: 1.5;
  color: #0f172a;
}
[data-theme="dark"] .push-ios { background: #1e293b; border-color: #334155; color: #e2e8f0; }

/* =============================================================================
 * Stage 9 – Öffentliche Auth-Seiten (login/register/forgot-password/verify/reset)
 * Mobile-first, >=48px Touch-Ziele, >=16px Text. Nur zentrale Token (kein
 * Inline), dunkles Theme über [data-theme="dark"] auf <html>.
 * ============================================================================= */
.auth-wrap {
  max-width: 28rem;
  margin: 0 auto;
  padding: 2.5rem 1.25rem 3rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}
.auth-card__title { font-size: 1.6rem; margin: 0 0 0.25rem; }
.auth-card {
  background: var(--rc-surface);
  border: 1px solid var(--rc-border);
  border-radius: var(--rc-radius);
  padding: 1.5rem 1.25rem;
}
.auth-note { color: var(--rc-text-muted); margin: 0 0 1rem; }
.auth-links { text-align: center; font-size: 0.95rem; color: var(--rc-text-muted); margin: 0; }
.auth-links a { color: var(--rc-primary); }

.field { margin: 0 0 1.1rem; }
.field label {
  display: block;
  font-weight: 600;
  font-size: 1rem;
  margin: 0 0 0.35rem;
}
.field input[type="email"],
.field input[type="password"],
.field input[type="text"] {
  display: block;
  width: 100%;
  box-sizing: border-box;
  min-height: 48px;
  padding: 12px 14px;
  font-size: 1.05rem;
  font-family: inherit;
  color: var(--rc-text);
  background: var(--rc-bg);
  border: 1px solid var(--rc-border);
  border-radius: 10px;
}
.field--check {
  border: 1px solid var(--rc-border);
  border-radius: 10px;
  padding: 0.75rem 1rem;
  margin: 0 0 1.1rem;
}
.field--check legend { font-weight: 600; padding: 0 0.35rem; }
.role-check {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-height: 48px;
  font-size: 1rem;
  cursor: pointer;
}
.role-check input { width: 1.35rem; height: 1.35rem; accent-color: var(--rc-primary); }

.btn-primary,
.btn-secondary {
  display: block;
  box-sizing: border-box;
  width: 100%;
  min-height: 52px;
  padding: 13px 18px;
  font-size: 1.05rem;
  font-weight: 600;
  text-align: center;
  text-decoration: none;
  border-radius: 12px;
  cursor: pointer;
  border: 1px solid transparent;
}
.btn-primary { background: var(--rc-primary); color: var(--rc-primary-ink); }
.btn-primary:active { transform: scale(0.99); }
.btn-secondary { background: var(--rc-surface); color: var(--rc-primary); border-color: var(--rc-primary); }
.btn-primary:disabled, .btn-secondary:disabled { opacity: 0.55; cursor: not-allowed; }

.auth-error {
  color: var(--rc-err);
  font-weight: 600;
  margin: 0.75rem 0 0;
  min-height: 1.2em;
}
.auth-status { color: var(--rc-info); margin: 0.5rem 0 0; min-height: 1.2em; }
.auth-status--ok { color: var(--rc-ok); }
.auth-continue { margin-top: 1rem; display: block; }

/* ---------- Startseiten-CTAs ---------- */
.home__ctas {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  margin: 1.6rem 0;
}
.home__cta-row { display: flex; gap: 0.9rem; }
.home__cta-row .btn-secondary { flex: 1; }

/* ---------- App-Tab-Leiste (sticky, mobile-first, >=48px) ---------- */
.tab-bar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  gap: 0.25rem;
  padding: 0.5rem 0.75rem;
  padding-bottom: calc(0.5rem + env(safe-area-inset-bottom, 0px));
  background: var(--rc-surface);
  border-bottom: 1px solid var(--rc-border);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.tab {
  flex: 1 0 auto;
  min-height: 48px;
  padding: 0 0.9rem;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--rc-text-muted);
  background: none;
  border: 1px solid transparent;
  border-radius: 10px;
  cursor: pointer;
  white-space: nowrap;
}
.tab[aria-current="page"] {
  color: var(--rc-primary-ink);
  background: var(--rc-primary);
}
.tab:disabled { opacity: 0.45; cursor: not-allowed; }

/* ---------- Inbox (Empfänger) ---------- */
.emp-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.9rem 0.25rem;
}
.emp-row__main { min-width: 0; flex: 1 1 auto; }
.emp-row__name { font-weight: 700; display: block; }
.emp-row__hint { font-size: 0.85rem; color: var(--rc-text-muted); display: block; }
.emp-row__actions { display: flex; flex-wrap: wrap; gap: 0.5rem; justify-content: flex-end; flex: 0 1 auto; }

/* ---------- Verbindungen (Tab-View) ---------- */
.conn-section { margin: 0 0 1.5rem; }
.conn-section h2 { font-size: 1.15rem; margin: 0 0 0.5rem; }
.conn-search { display: flex; gap: 0.5rem; margin-bottom: 0.75rem; }
.conn-search input { flex: 1 1 auto; min-height: 48px; padding: 12px 14px; font-size: 1rem; font-family: inherit; color: var(--rc-text); background: var(--rc-bg); border: 1px solid var(--rc-border); border-radius: 10px; }
.conn-search button { flex: 0 0 auto; min-width: 96px; min-height: 48px; font-size: 1rem; font-weight: 600; background: var(--rc-primary); color: var(--rc-primary-ink); border: none; border-radius: 10px; cursor: pointer; }
.conn-list { list-style: none; margin: 0; padding: 0; }
.conn-list li { border: 1px solid var(--rc-border); border-radius: 10px; padding: 0.9rem 0.75rem; margin-bottom: 0.6rem; background: var(--rc-surface); }
.conn-row__name { font-weight: 700; }
.conn-row__meta { color: var(--rc-text-muted); font-size: 0.9rem; margin: 2px 0 0.4rem; }
.conn-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.5rem; }
.btn-mini {
  min-height: 48px; min-width: 72px; padding: 10px 14px;
  font-size: 0.95rem; font-weight: 600; cursor: pointer;
  border-radius: 10px; border: 1px solid var(--rc-border);
  background: var(--rc-surface); color: var(--rc-text);
}
.btn-mini:active { transform: scale(0.98); }
.btn-mini--danger { border-color: var(--rc-err); color: var(--rc-err); }
.btn-mini--ok { border-color: var(--rc-ok); color: var(--rc-ok); }
.status-chip {
  display: inline-block; font-size: 0.8rem; font-weight: 700;
  padding: 2px 10px; border-radius: 999px;
  background: var(--rc-bg); border: 1px solid var(--rc-border);
  color: var(--rc-text-muted);
}

/* ---------- Einstellungen (Tab-View) ---------- */
.settings-block { margin: 0 0 1.5rem; }
.settings-block h2 { font-size: 1.15rem; margin: 0 0 0.35rem; }
.settings-block .hint { margin: 0 0 0.75rem; }
.form-row { margin: 0 0 0.9rem; }
.form-row label { display: block; font-weight: 600; margin-bottom: 0.3rem; }
.form-row input {
  display: block; width: 100%; box-sizing: border-box;
  min-height: 48px; padding: 12px 14px; font-size: 1.05rem; font-family: inherit;
  color: var(--rc-text); background: var(--rc-bg);
  border: 1px solid var(--rc-border); border-radius: 10px;
}
.settings-msg { min-height: 1.3em; margin: 0.4rem 0 0; font-weight: 600; }
.settings-msg--ok { color: var(--rc-ok); }
.settings-msg--err { color: var(--rc-err); }
.danger-zone { border-top: 2px solid var(--rc-err); padding-top: 1rem; }

/* ---------- Rollen-Hinweis (Rollen-Prompt) ---------- */
.role-prompt {
  background: var(--rc-notice-bg);
  border: 1px solid var(--rc-notice-border);
  border-radius: var(--rc-radius);
  padding: 1rem 1.1rem;
  margin: 0.75rem 0;
}
.role-prompt h2 { font-size: 1.05rem; margin: 0 0 0.4rem; }
.role-prompt p { margin: 0; color: var(--rc-text-muted); }

/* ---------- Barrierefreiheit: Screenreader-Nur-Element ---------- */
.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- Inbox: Ruhezeit-Reihe ---------- */
.emp-quiet {
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
}
.emp-quiet .note-input {
  display: inline-block;
  width: auto;
  margin-top: 0;
  min-height: 48px;
}
.emp-quiet label {
  font-weight: 600;
  margin-left: 0.5rem;
}

/* ---------- Ansicht-Container ---------- */
.view { display: flex; flex-direction: column; }

/* ---------- Nacht-Info-Karte in den Einstellungen ---------- */
#setNightHint { margin-top: 0.5rem; margin-bottom: 0.5rem; }
/* Suche in Verbindungen: Barrierefreiheit */
#ctcSearch { min-height: 48px; }

/* ---------- Robust Hide-Regel: [hidden] darf nie ueberschrieben werden
 * (z. B. durch .view/.smoke-grid/.emp-quiet mit explizitem display). */
[hidden] { display: none !important; }

/* ---------- Touch-Target-Minimalgruesse (spec: >=48px) ---------- */
.theme-toggle { width: 3rem; height: 3rem; }
#appLogout { min-height: 48px; padding: 12px 16px; font-size: 0.95rem; }
