/* ColdGuard Operations – App-Layout. Farben/Komponenten kommen aus theme.css. */

body { font-size: var(--text-sm); }
h1 { font-size: var(--text-xl); margin: 0; }
h2 { font-size: var(--text-lg); margin: 0 0 var(--space-4); }
h3 { font-size: 1rem; margin: 0 0 var(--space-3); }
[hidden] { display: none !important; }

/* ---------- Shell ---------- */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: var(--space-5);
  padding: var(--space-5) var(--space-4);
  background: var(--color-surface);
  border-right: 1px solid var(--color-border-subtle);
}
.brand { display: flex; align-items: center; gap: var(--space-3); font-size: 1.25rem; font-weight: 500; color: var(--color-heading); text-decoration: none; letter-spacing: -0.02em; }
.brand b { font-weight: 800; }
.sidebar nav { display: grid; gap: 2px; }
.sidebar nav a {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.6rem 0.85rem; border-radius: var(--radius-sm);
  color: var(--color-text); text-decoration: none; font-weight: 550;
}
.sidebar nav a:hover { background: var(--color-surface-sunken); }
.sidebar nav a[aria-current="page"] { background: var(--color-surface-muted); color: var(--color-heading); }
.nav-count { background: var(--color-danger); color: #fff; border-radius: var(--radius-pill); font-size: 0.75rem; padding: 0 0.5rem; font-weight: 700; }
:root[data-theme="dark"] .nav-count { color: #3b1219; }
.sidebar-foot { margin-top: auto; display: grid; gap: var(--space-3); }
.sidebar-actions { display: flex; gap: var(--space-2); align-items: center; }
.provider-chip { font-size: var(--text-xs); padding: 0.5rem 0.75rem; border-radius: var(--radius-sm); background: var(--color-warning-bg); color: var(--color-warning); font-weight: 600; }

.view { padding: var(--space-6) clamp(1rem, 3vw, 2.5rem) var(--space-8); max-width: 1400px; width: 100%; outline: none; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: var(--space-4); margin-bottom: var(--space-5); }
.page-head .crumbs { font-size: var(--text-xs); color: var(--color-text-muted); margin-bottom: var(--space-1); }
.page-head .crumbs a { color: inherit; }
.actions { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: var(--space-3) var(--space-4); }
  .sidebar nav { display: flex; overflow-x: auto; order: 3; width: 100%; }
  .sidebar nav a { white-space: nowrap; }
  .sidebar-foot { margin: 0 0 0 auto; display: flex; }
  .provider-chip { display: none; }
}

/* ---------- Bausteine ---------- */
.card { padding: var(--space-5); border-radius: var(--radius-md); }
.card + .card, .grid + .card, .card + .grid { margin-top: var(--space-5); }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: var(--space-3); margin-bottom: var(--space-4); }
.card-head h2 { margin: 0; }
.grid { display: grid; gap: var(--space-5); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); align-items: start; }
.grid > .card { margin-top: 0; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: var(--space-4); margin-bottom: var(--space-5); }
.kpi { padding: var(--space-4) var(--space-5); }
.kpi .label { color: var(--color-text-muted); font-size: var(--text-xs); font-weight: 600; }
.kpi .value { font-size: 1.9rem; font-weight: 750; color: var(--color-heading); line-height: 1.2; font-variant-numeric: tabular-nums; }
.kpi .sub { font-size: var(--text-xs); color: var(--color-text-muted); }
.kpi.is-danger .value { color: var(--color-danger); }
.kpi.is-warning .value { color: var(--color-warning); }

.muted { color: var(--color-text-muted); }
.small { font-size: var(--text-xs); }
.mono { font-family: var(--font-mono); font-size: 0.85em; }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.empty { padding: var(--space-6); text-align: center; color: var(--color-text-muted); }

.table-wrap { overflow-x: auto; margin: 0 calc(-1 * var(--space-5)); padding: 0 var(--space-5); }
.table th, .table td { padding: 0.6rem 0.75rem; vertical-align: middle; }
.table th { font-size: var(--text-xs); text-transform: uppercase; letter-spacing: 0.04em; color: var(--color-text-muted); white-space: nowrap; }
.table tbody tr:hover { background: var(--color-surface-sunken); }
.table td a { font-weight: 600; text-decoration: none; }
.table td a:hover { text-decoration: underline; }
.table td.actions { display: table-cell; text-align: right; white-space: nowrap; }
.table td.actions .btn + .btn { margin-left: var(--space-2); }
.table tr.is-alarm td:first-child { box-shadow: inset 3px 0 0 var(--color-danger); }

.badge { white-space: nowrap; }
.badge-muted { background: var(--color-surface-sunken); color: var(--color-text-muted); }
.temp { font-weight: 700; font-variant-numeric: tabular-nums; }
.temp.is-bad { color: var(--color-danger); }

.btn { min-height: 38px; padding: 0.45rem 1rem; }
.btn-sm { min-height: 32px; padding: 0.3rem 0.75rem; font-size: var(--text-xs); }
.btn-danger { background: var(--color-danger-bg); color: var(--color-danger); }
.btn-danger:hover { border-color: var(--color-danger); }
.icon-btn { width: 38px; height: 38px; }

dl.facts { display: grid; grid-template-columns: minmax(120px, auto) 1fr; gap: 0.45rem 1.25rem; margin: 0; }
dl.facts dt { color: var(--color-text-muted); }
dl.facts dd { margin: 0; font-weight: 550; overflow-wrap: anywhere; }

pre.code {
  margin: 0; padding: var(--space-4); border-radius: var(--radius-sm);
  background: var(--color-surface-sunken); border: 1px solid var(--color-border-subtle);
  font-family: var(--font-mono); font-size: 0.8rem; overflow-x: auto; white-space: pre;
}
.secret { padding: var(--space-3) var(--space-4); border-radius: var(--radius-sm); background: var(--color-warning-bg); color: var(--color-warning); font-family: var(--font-mono); font-weight: 700; font-size: 1rem; user-select: all; overflow-wrap: anywhere; }

.timeline { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--space-2); }
.timeline li { display: grid; grid-template-columns: 110px 1fr auto; gap: var(--space-3); align-items: center; padding: var(--space-2) 0; border-bottom: 1px solid var(--color-border-subtle); }
.timeline li:last-child { border-bottom: 0; }

/* ---------- Formulare / Dialog ---------- */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-4); }
.form-grid .full { grid-column: 1 / -1; }
.input, .select, .textarea { min-height: 40px; padding: 0.5rem 0.75rem; font-size: var(--text-sm); }
.textarea { min-height: 80px; }
.field label { font-size: var(--text-xs); }
.checks { display: flex; flex-wrap: wrap; gap: var(--space-4); }
.form-error { color: var(--color-danger); font-weight: 600; min-height: 1.2em; margin: 0; }
@media (max-width: 600px) { .form-grid { grid-template-columns: 1fr; } }

.dialog {
  width: min(640px, calc(100vw - 2rem)); max-height: calc(100vh - 2rem);
  padding: 0; border: 1px solid var(--color-border-subtle); border-radius: var(--radius-lg);
  background: var(--color-surface); color: var(--color-text); box-shadow: var(--shadow-lg);
}
.dialog::backdrop { background: rgb(11 20 36 / 0.55); }
.dialog form, .dialog .dialog-body { padding: var(--space-6); display: grid; gap: var(--space-4); }
.dialog h2 { margin: 0; }
.dialog-actions { display: flex; justify-content: flex-end; gap: var(--space-2); margin-top: var(--space-2); }

.login { min-height: 100vh; display: grid; place-items: center; padding: var(--space-4); }
.login-card { width: min(400px, 100%); display: grid; gap: var(--space-4); padding: var(--space-6); }
.login-card h1 { font-size: var(--text-lg); color: var(--color-text-muted); font-weight: 600; }

.toast {
  position: fixed; bottom: var(--space-5); left: 50%; transform: translateX(-50%) translateY(150%);
  background: var(--brand-navy); color: #fff; padding: 0.75rem 1.25rem; border-radius: var(--radius-pill);
  font-weight: 600; box-shadow: var(--shadow-lg); transition: transform var(--transition), opacity var(--transition); z-index: 50; max-width: calc(100vw - 2rem);
  opacity: 0; visibility: hidden;
}
.toast.is-visible { transform: translateX(-50%) translateY(0); opacity: 1; visibility: visible; }
.toast.is-error { background: var(--color-danger); }
:root[data-theme="dark"] .toast.is-error { color: #3b1219; }

/* ---------- Diagramm ---------- */
.chart { width: 100%; height: auto; display: block; }
.chart .grid-line { stroke: var(--color-border-subtle); stroke-width: 1; }
.chart .axis { fill: var(--color-text-muted); font-size: 11px; font-family: var(--font-sans); }
.chart .limit { stroke: var(--color-danger); stroke-dasharray: 4 4; stroke-width: 1.25; opacity: 0.7; }
.chart .series { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .s1 { stroke: var(--color-primary); }
.chart .s2 { stroke: light-dark(#c2410c, #fdba74); }
.chart .s3 { stroke: light-dark(#7c3aed, #c4b5fd); }
.chart .dot1 { fill: var(--color-primary); }
.chart .dot2 { fill: light-dark(#c2410c, #fdba74); }
.chart .dot3 { fill: light-dark(#7c3aed, #c4b5fd); }
.legend { display: flex; gap: var(--space-4); flex-wrap: wrap; font-size: var(--text-xs); color: var(--color-text-muted); }
.legend span::before { content: ""; display: inline-block; width: 14px; height: 3px; border-radius: 2px; margin-right: 6px; vertical-align: middle; background: currentColor; }
.legend .l1 { color: var(--color-primary); }
.legend .l2 { color: light-dark(#c2410c, #fdba74); }
.legend .l3 { color: light-dark(#7c3aed, #c4b5fd); }
.legend .ll { color: var(--color-danger); }
.seg { display: inline-flex; border: 1px solid var(--color-border); border-radius: var(--radius-pill); overflow: hidden; }
.seg button { border: 0; background: transparent; color: var(--color-text); padding: 0.3rem 0.75rem; font: inherit; font-size: var(--text-xs); cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--color-surface-muted); color: var(--color-heading); font-weight: 700; }

details.raw { border-bottom: 1px solid var(--color-border-subtle); padding: var(--space-2) 0; }
details.raw summary { cursor: pointer; font-size: var(--text-xs); color: var(--color-text-muted); }
details.raw pre { margin-top: var(--space-2); }
