/* Capita Connect Dashboard
 * Zwei Welten, ein Tool:
 *  - Verwaltung (Liste/Editor) im ruhigen, hellen Capita-Hausstil
 *    (analog Holiday Manager: Schweizer Rot als sparsamer Akzent).
 *  - Board-Ansicht dunkel, fuer Wallboards/TVs im Callcenter optimiert:
 *    grosse Tabular-Ziffern, Threshold-Farben tragen die Information.
 */

:root {
  --bg: #f2f4f6;
  --surface: #ffffff;
  --ink: #17202d;
  --muted: #5d6a7a;
  --border: #dfe4ea;
  --accent: #d2232a;       /* Schweizer Rot, sparsam */
  --accent-dark: #a81b21;
  --mono: ui-monospace, 'SF Mono', 'Cascadia Code', Consolas, monospace;

  /* Board (dunkel) */
  --board-bg: #10151d;
  --board-surface: #1a212c;
  --board-border: #28303d;
  --board-ink: #e8edf4;
  --board-muted: #7c8898;

  /* Threshold-Farben (Board) */
  --th-green: #2eb872;
  --th-yellow: #e8b220;
  --th-red: #e8453c;
  --th-blue: #3d8bfd;
  --th-grey: #6b7686;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.45;
}

.hidden { display: none !important; }
.mono { font-family: var(--mono); }
.num { text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; }
.error { color: var(--accent); }
.hint { color: var(--muted); margin: 4px 0 12px; }
.clickable { cursor: pointer; }

/* ---------- Login ---------- */

.centered { min-height: 100vh; display: flex; align-items: center; justify-content: center; }

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 3px solid var(--accent);
  border-radius: 6px;
  padding: 40px 48px;
  text-align: center;
  max-width: 440px;
}
.login-card p { color: var(--muted); margin: 12px 0 24px; }

/* ---------- Header ---------- */

.brand { font-size: 17px; font-weight: 700; letter-spacing: -0.01em; }
.brand span { font-weight: 400; color: var(--muted); }

#app-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.header-right { display: flex; align-items: center; gap: 12px; }
.user-name { color: var(--muted); }

.data-age {
  font-family: var(--mono);
  font-size: 12px;
  padding: 3px 8px;
  border-radius: 4px;
  background: #e6f4ec;
  color: #1c7a4b;
}
.data-age.stale { background: #fdeaea; color: var(--accent-dark); font-weight: 600; }

/* ---------- Buttons ---------- */

.btn {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 5px;
  padding: 7px 14px;
  font-size: 13px;
  cursor: pointer;
  color: var(--ink);
}
.btn:hover { border-color: var(--muted); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn-primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
.btn-danger { color: var(--accent-dark); border-color: var(--accent-dark); }
.btn-ghost { background: transparent; }
.btn-mini { padding: 2px 8px; font-size: 12px; }
.btn-small { padding: 4px 10px; font-size: 12px; }

/* ---------- Main / Panels ---------- */

main { max-width: 1400px; margin: 0 auto; padding: 24px; }
h1 { font-size: 20px; margin-bottom: 4px; }
h2 { font-size: 15px; margin-bottom: 4px; }

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 18px;
  margin-bottom: 16px;
}

.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.form-field { display: flex; flex-direction: column; gap: 4px; }
.form-field.span-2 { grid-column: span 2; }
.form-field label { font-size: 12px; font-weight: 600; color: var(--muted); }
.form-field input, .form-field select, .form-field textarea {
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 7px 10px;
  font-size: 13px;
  font-family: inherit;
  background: var(--surface);
}
.form-actions { display: flex; align-items: center; gap: 10px; margin-top: 12px; }
.status-text { color: var(--muted); }

.checkbox-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 2px 12px;
  max-height: 180px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 8px;
}
.cb { display: flex; align-items: center; gap: 6px; font-size: 13px; padding: 2px 0; cursor: pointer; }

.queue-filter {
  font-weight: 400; font-size: 12px; margin-left: 8px;
  border: 1px solid var(--border); border-radius: 4px; padding: 2px 6px;
}

/* ---------- Editor: Widgets ---------- */

.ed-widget {
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 5px;
  padding: 12px;
  margin-bottom: 12px;
}
.ed-widget-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }

.th-block { border-top: 1px dashed var(--border); padding-top: 6px; margin-top: 6px; }
.th-metric { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.th-rule { display: flex; gap: 6px; align-items: center; margin-bottom: 4px; }
.th-rule input { width: 90px; }
.th-rule select, .th-rule input {
  border: 1px solid var(--border); border-radius: 4px; padding: 3px 6px; font-size: 12px;
}

/* ---------- Dashboard-Liste ---------- */

.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }

.dash-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 16px;
  cursor: pointer;
  transition: border-color 0.1s;
}
.dash-card:hover { border-color: var(--accent); }
.dash-abteilung {
  display: inline-block;
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--accent-dark);
  margin-bottom: 6px;
}
.dash-name { font-size: 15px; font-weight: 600; margin-bottom: 8px; }
.dash-meta { font-size: 11px; color: var(--muted); }

/* ---------- Board (dunkel) ---------- */

body.board-mode { background: var(--board-bg); }
body.board-mode #app-header { background: var(--board-surface); border-color: var(--board-border); }
body.board-mode .brand, body.board-mode h1 { color: var(--board-ink); }
body.board-mode .btn-ghost { color: var(--board-ink); border-color: var(--board-border); }
body.board-mode .user-name { color: var(--board-muted); }

.board-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 16px; }

.board-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}

.widget {
  background: var(--board-surface);
  border: 1px solid var(--board-border);
  border-radius: 8px;
  padding: 14px 16px;
  color: var(--board-ink);
  min-height: 100px;
}
.w-1 { grid-column: span 1; }
.w-2 { grid-column: span 2; }
.w-3 { grid-column: span 3; }
@media (max-width: 900px) { .w-1, .w-2, .w-3 { grid-column: span 3; } }

.widget-title {
  font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--board-muted);
  margin-bottom: 8px;
}
.widget .hint { color: var(--board-muted); }

/* Kachel */
.tile { text-align: center; padding: 8px 0 4px; }
.tile-value {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: 56px;
  font-weight: 700;
  line-height: 1.1;
}
.tile-label { color: var(--board-muted); font-size: 13px; margin-top: 4px; }

.tile.th-green .tile-value { color: var(--th-green); }
.tile.th-yellow .tile-value { color: var(--th-yellow); }
.tile.th-red .tile-value { color: var(--th-red); }
.tile.th-blue .tile-value { color: var(--th-blue); }
.tile.th-grey .tile-value { color: var(--th-grey); }
.tile.th-red { animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.75; } }
@media (prefers-reduced-motion: reduce) { .tile.th-red { animation: none; } }

/* Tabellen */
.metric-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.metric-table th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--board-muted);
  padding: 4px 10px;
  border-bottom: 1px solid var(--board-border);
}
.metric-table th:not(:first-child) { text-align: right; }
.metric-table td { padding: 6px 10px; border-bottom: 1px solid var(--board-border); }
.metric-table tr:last-child td { border-bottom: none; }
.queue-name { font-weight: 600; }

td.th-green { color: var(--th-green); font-weight: 700; }
td.th-yellow { color: var(--th-yellow); font-weight: 700; }
td.th-red { color: var(--th-red); font-weight: 700; }
td.th-blue { color: var(--th-blue); font-weight: 700; }
td.th-grey { color: var(--th-grey); }

/* ---------- TV-Modus (Vollbild auf Screens) ---------- */

body.tv #app-header .user-name,
body.tv #app-header .btn:not(#btn-tv),
body.tv .board-head .board-actions { display: none; }
body.tv main { max-width: none; padding: 16px; }
body.tv .tile-value { font-size: 84px; }
body.tv .metric-table { font-size: 18px; }
body.tv .widget-title { font-size: 14px; }

/* ---------- Fokus / Zugaenglichkeit ---------- */

.btn:focus-visible, input:focus-visible, select:focus-visible, .cb:focus-within {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
