/* Themes: dark (Standard) / light via [data-theme="light"].
   Alle Kontraste geprüft: Text >= 4,5:1, UI-Komponenten >= 3:1 (WCAG 2.1 AA).
   Genau 3 Schriftgrößen: --fs-base, --fs-small, --fs-xl. */

:root {
  color-scheme: dark;
  --bg: #0c0f12;
  --bg-card: #14181d;
  --border: #262c33;          /* dekorativ (Karten, Tabellenlinien) */
  --border-strong: #6a7480;   /* interaktive Komponenten (>= 3:1) */
  --fg: #d6dde4;
  --muted: #7a8590;
  --accent: #3fd07a;
  --warn: #e0a93e;
  --danger: #ef5b58;
  --on-fill: #0c0f12;         /* Text auf gefüllten Buttons */

  --fs-base: 0.875rem;
  --fs-small: 0.75rem;
  --fs-xl: clamp(2.5rem, 10vw, 4.5rem);
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f4f5f6;
  --bg-card: #ffffff;
  --border: #d0d5da;
  --border-strong: #6b7580;
  --fg: #1c232a;
  --muted: #5b6672;
  --accent: #157a45;
  --warn: #8a6100;
  --danger: #b3261e;
  --on-fill: #ffffff;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
button, input, select { font: inherit; }

body {
  font-family: 'IBM Plex Mono', ui-monospace, monospace;
  font-size: var(--fs-base);
  background: var(--bg);
  color: var(--fg);
  line-height: 1.5;
  min-height: 100vh;
}

.hidden { display: none !important; }
.muted { color: var(--muted); }
.error { color: var(--danger); margin-top: 0.75rem; }

h1 { font-size: var(--fs-base); font-weight: 700; letter-spacing: 0.05em; }
h2, h3 {
  font-size: var(--fs-small);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  margin-bottom: 0.75rem;
}
h3 { margin: 1.25rem 0 0.5rem; }

/* Sichtbarer Fokus für Tastaturnutzung (2.4.7) */
button:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---------- Login ---------- */
.login-wrap { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 1rem; position: relative; }
.corner-toggles { position: absolute; top: 1rem; right: 1rem; display: flex; gap: 0.5rem; }
.login-card { width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 0.5rem; }
.login-card h1 { color: var(--accent); }
.login-card .tagline { font-size: var(--fs-small); margin-bottom: 1rem; }
.login-card label { font-size: var(--fs-small); color: var(--muted); margin-top: 0.5rem; }
.login-card button[type="submit"] { margin-top: 1rem; }

/* ---------- Layout ---------- */
header {
  display: flex; align-items: center; gap: 1.5rem; flex-wrap: wrap;
  padding: 0.75rem 1.25rem;
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; background: var(--bg); z-index: 5;
}
.logo { color: var(--accent); font-weight: 700; }
nav { display: flex; gap: 0.25rem; }
.header-right { margin-left: auto; display: flex; align-items: center; gap: 0.75rem; }
#me-name { color: var(--muted); font-size: var(--fs-small); }

main { max-width: 1100px; margin: 0 auto; padding: 1.25rem; display: flex; flex-direction: column; gap: 1rem; }
section { display: flex; flex-direction: column; gap: 1rem; }

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px; /* M3 shape: medium */
  padding: 1.25rem;
}

/* ---------- Buttons & Inputs ---------- */
/* M3 outlined button: Pillenform, Hover/Press als State-Layer (8–12 %) */
.btn {
  font-family: inherit; font-size: var(--fs-base);
  min-height: 2.5rem;
  padding: 0.45rem 1.25rem;
  background: transparent;
  color: var(--fg);
  border: 1px solid var(--border-strong);
  border-radius: 999px; /* M3 shape: full */
  cursor: pointer;
}
.btn:hover:not(:disabled) { background: color-mix(in srgb, currentColor 8%, transparent); }
.btn:active:not(:disabled) { background: color-mix(in srgb, currentColor 12%, transparent); }
.btn:disabled { opacity: 0.38; cursor: not-allowed; } /* M3 disabled */
.btn-primary { border-color: var(--accent); color: var(--accent); }
.btn-warn { border-color: var(--warn); color: var(--warn); }
.btn-danger { border-color: var(--danger); color: var(--danger); }
.btn-ghost { color: var(--muted); }
.btn-ghost:hover:not(:disabled) { color: var(--fg); }

/* M3 outlined icon button (rund) */
.theme-toggle {
  min-height: 2.5rem; min-width: 2.5rem;
  display: inline-flex; align-items: center; justify-content: center;
  background: none; border: 1px solid var(--border-strong); border-radius: 999px;
  color: var(--muted); cursor: pointer; padding: 0.45rem;
}
.theme-toggle:hover { color: var(--fg); background: color-mix(in srgb, currentColor 8%, transparent); }
.theme-toggle svg { width: 20px; height: 20px; }

/* Sprachumschalter (DE/EN) im Stil des Theme-Toggles */
.lang-toggle {
  min-height: 2.5rem; min-width: 2.5rem;
  display: inline-flex; align-items: center; justify-content: center;
  background: none; border: 1px solid var(--border-strong); border-radius: 999px;
  color: var(--muted); cursor: pointer; padding: 0.45rem;
  font-family: inherit; font-size: var(--fs-small); font-weight: 700; letter-spacing: 0.05em;
}
.lang-toggle:hover { color: var(--fg); background: color-mix(in srgb, currentColor 8%, transparent); }

/* M3 primary tabs: Underline-Indikator, Hover-State-Layer */
.tab {
  font-family: inherit; font-size: var(--fs-base);
  min-height: 2.5rem;
  background: none; border: none; color: var(--muted);
  padding: 0.4rem 0.75rem; cursor: pointer;
  border-bottom: 2px solid transparent;
  border-radius: 8px 8px 0 0;
}
.tab:hover { color: var(--fg); background: color-mix(in srgb, currentColor 8%, transparent); }
.tab.active { color: var(--fg); border-bottom-color: var(--accent); }

input, select {
  font-family: inherit; font-size: var(--fs-base);
  min-height: 2.5rem;
  background: var(--bg);
  color: var(--fg);
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  padding: 0.45rem 0.7rem;
}
input:focus, select:focus { border-color: var(--accent); }
input::placeholder { color: var(--muted); opacity: 1; }
:root[data-theme="light"] input, :root[data-theme="light"] select { background: var(--bg-card); }

/* ---------- Passwort-Sichtbarkeit ---------- */
.pw-wrap { position: relative; display: flex; }
.pw-wrap input { flex: 1; width: 100%; padding-right: 2.6rem; }
.pw-eye {
  position: absolute; right: 0.2rem; top: 50%; transform: translateY(-50%);
  min-width: 2rem; min-height: 2rem; border-radius: 999px;
  background: none; border: none; color: var(--muted); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.pw-eye:hover { color: var(--fg); background: color-mix(in srgb, currentColor 8%, transparent); }
.pw-eye svg { width: 20px; height: 20px; }
.rename-cell .pw-wrap { flex: 1; min-width: 140px; }

/* ---------- Stempeluhr ---------- */
.clock-card { text-align: center; }
.status-line { display: flex; justify-content: center; align-items: baseline; gap: 0.75rem; }
.badge {
  font-size: var(--fs-small);
  padding: 0.15rem 0.7rem; border-radius: 999px;
  border: 1px solid var(--border-strong); color: var(--muted);
}
.badge.working { border-color: var(--accent); color: var(--accent); }
.badge.break { border-color: var(--warn); color: var(--warn); }
.status-line .muted { font-size: var(--fs-small); }
.clock-display {
  font-size: var(--fs-xl);
  font-weight: 700;
  letter-spacing: 0.02em;
  margin: 0.75rem 0 0.25rem;
  font-variant-numeric: tabular-nums;
}
.clock-sub { font-size: var(--fs-small); }
.punch-buttons { display: flex; justify-content: center; gap: 0.75rem; margin: 1.5rem 0 1rem; flex-wrap: wrap; }
.comment-row { display: flex; gap: 0.5rem; max-width: 560px; margin: 0 auto; }
.comment-row input { flex: 1; }

.warnings { list-style: none; display: flex; flex-direction: column; gap: 0.4rem; }
.warnings li { padding-left: 1.2rem; position: relative; }
.warnings li::before { content: '!'; position: absolute; left: 0; font-weight: 700; }
.warnings li.violation { color: var(--danger); }
.warnings li.warn { color: var(--warn); }
.warnings li.info { color: var(--muted); }

.legal { font-size: var(--fs-small); line-height: 1.6; padding: 0 0.25rem; }

/* ---------- Kommentar-Inline-Bearbeitung ----------
   Editor und Anzeige haben identische Höhe (1,75rem), die Kommentar-Spalte
   eine feste Breite – Umschalten verursacht keinen Layout-Sprung. */
.btn-inline {
  background: none; border: none; color: var(--muted); cursor: pointer;
  min-width: 1.75rem; height: 1.75rem; border-radius: 999px;
  display: inline-flex; align-items: center; justify-content: center;
  vertical-align: middle; padding: 0;
}
.btn-inline:hover { color: var(--fg); background: color-mix(in srgb, currentColor 10%, transparent); }
.btn-seg-save { color: var(--accent); }
.col-comment { width: 38%; }
.seg-view, .seg-edit { display: flex; gap: 0.25rem; align-items: center; min-height: 1.75rem; }
.seg-view { flex-wrap: wrap; }
.seg-edit input {
  flex: 1; min-width: 0; width: 100%;
  height: 1.75rem; min-height: 1.75rem; padding: 0 0.4rem;
  border: none; border-bottom: 1px solid var(--border-strong); border-radius: 0;
  background: transparent;
}
.seg-edit input:focus { border-bottom-color: var(--accent); }
.seg-line { margin-bottom: 0.2rem; }
.seg-line:last-child { margin-bottom: 0; }

/* ---------- Tabellen ---------- */
.table-scroll { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: var(--fs-base); }
.table th {
  text-align: left; color: var(--muted); font-weight: 500;
  padding: 0.4rem 0.75rem 0.4rem 0;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.table td { padding: 0.45rem 0.75rem 0.45rem 0; border-bottom: 1px solid var(--border); vertical-align: top; }
.table td.warn-cell { color: var(--danger); font-size: var(--fs-small); }
.table td.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.table .running { color: var(--accent); }

/* ---------- Einstellungen & Admin ---------- */
.settings-form { display: flex; flex-direction: column; gap: 0.5rem; max-width: 360px; }
.settings-form label { font-size: var(--fs-small); color: var(--muted); margin-top: 0.5rem; }
.settings-form button[type="submit"] { margin-top: 1rem; align-self: flex-start; }

.rename-cell { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; }
.rename-cell input { flex: 1; min-width: 140px; }

.filter-row { display: flex; gap: 0.75rem; align-items: end; flex-wrap: wrap; margin-bottom: 0.5rem; }
.filter-row label { display: flex; flex-direction: column; gap: 0.25rem; font-size: var(--fs-small); color: var(--muted); }

.toast {
  position: fixed; bottom: 1.25rem; left: 50%; transform: translateX(-50%);
  background: var(--bg-card); border: 1px solid var(--danger); color: var(--danger);
  padding: 0.6rem 1.2rem; border-radius: 4px; z-index: 10;
  max-width: 90vw;
}
.toast.ok { border-color: var(--accent); color: var(--accent); }
.toast.warn { border-color: var(--warn); color: var(--warn); }

/* ---------- Responsive ---------- */
@media (max-width: 720px) {
  header { gap: 0.5rem; padding: 0.6rem 0.9rem; }
  #me-name { display: none; }
  main { padding: 0.9rem; }
  .card { padding: 0.9rem; }
  .punch-buttons { flex-direction: column; }
  .punch-buttons .btn { width: 100%; }
  .comment-row { flex-direction: column; }
  .filter-row { flex-direction: column; align-items: stretch; }
}
