/* =========================================================================
   dimadeev.de — Shared design system
   One source of truth for every dashboard/public page: tokens, type,
   the panel/tile/badge/button/form vocabulary, icons, motion.

   Loaded via <link rel="stylesheet" href="/assets/sidebar.css"> AFTER each
   page's own (legacy, now mostly redundant) inline <style> block — later
   same-specificity rules win the cascade, so this file's tokens and
   components already take over even before a page's local CSS is trimmed.

   Component naming: .panel is canonical. .term / .term-bar / .term-body
   (used by settings.php, login.php, the login popup) are the exact same
   component under an older name — aliased here rather than renamed in
   every file, so nothing breaks by not being touched yet.
   ========================================================================= */

:root {
  /* ---- Palette (dark terminal world — kept, not replaced) ---- */
  --bg: #0a0a0a;
  --bg-elevated: #131313;
  --bg-terminal: #0d0d0d;
  --text: #f5f5f0;
  --muted: #8a8a85;
  --muted-dim: #55554f;
  --accent: #f7931a;
  --accent-dim: #f7931a33;
  --accent-ink: #1a1200; /* text color on top of solid --accent */
  --border: #232323;
  --border-soft: #1a1a1a;
  --good: #4ade80;
  --good-dim: #4ade8022;
  --error: #ff5c5c;
  --error-dim: #ff5c5c1a;
  --info: #6ea8fe;
  --info-dim: #6ea8fe22;
  --plan: #7c9cff;
  --plan-dim: #7c9cff22;

  /* ---- Elevation ---- */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.5);
  --shadow-panel: 0 1px 1px rgba(0, 0, 0, 0.4), 0 12px 28px -14px rgba(0, 0, 0, 0.65);
  --shadow-lift: 0 1px 1px rgba(0, 0, 0, 0.4), 0 20px 44px -16px rgba(0, 0, 0, 0.7);

  /* ---- Motion ---- */
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);
  --dur-fast: 140ms;
  --dur-base: 200ms;

  /* ---- Type ---- */
  --font-ui: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: "SF Mono", ui-monospace, Menlo, Consolas, monospace;

  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 14px;
}

/* ---- Base ---- */
html { color-scheme: dark; }
* { box-sizing: border-box; }
body {
  margin: 0;
  background:
    radial-gradient(circle at 15% 0%, var(--accent-dim), transparent 40%),
    radial-gradient(circle at 85% 100%, #f7931a1a, transparent 45%),
    var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  -webkit-font-smoothing: antialiased;
}
::selection { background: var(--accent); color: var(--accent-ink); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 999px; border: 3px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--muted-dim); }

h1, h2, h3 { letter-spacing: -0.015em; }

/* ---- Live-status line (replaces the old pill/eyebrow above headings —
   craft-floor bans the kicker pattern; the pulse now lives inline in the
   subtitle it used to sit above, so nothing informational is lost). ---- */
.live-dot {
  display: inline-block; width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent); box-shadow: 0 0 0 0 var(--accent-dim);
  animation: livePulse 2s infinite; flex-shrink: 0; margin-right: 0.5em;
  vertical-align: middle;
}
@keyframes livePulse {
  0%   { box-shadow: 0 0 0 0 var(--accent-dim); }
  70%  { box-shadow: 0 0 0 8px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}

/* ---- Icon system (replaces unicode ✓ ⚠ ✗ 🔒 used as status glyphs).
   Single-weight 16x16 stroke icons, currentColor — drop-in via <?= icon('check') ?> */
.i {
  display: inline-block; width: 1em; height: 1em; vertical-align: -0.14em;
  flex-shrink: 0;
}
.i-inline { margin-right: 0.35em; }

/* =========================================================================
   Panels / terminal cards — canonical component. .term* is the same thing.
   ========================================================================= */
.panel, .term {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: 1.2rem;
  box-shadow: var(--shadow-panel);
}
.panel-bar, .term-bar {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.65rem 1rem;
  background: var(--bg-terminal);
  border-bottom: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--muted);
}
.panel-bar .dot, .term-bar .dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.panel-bar .dot.red, .term-bar .dot.red { background: #ff5f56; }
.panel-bar .dot.yellow, .term-bar .dot.yellow { background: #ffbd2e; }
.panel-bar .dot.orange, .term-bar .dot.orange { background: var(--accent); }
.term-bar .title { margin: 0 auto; }
.term-close { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 1rem; line-height: 1; padding: 0 0.2rem; transition: color var(--dur-fast) var(--ease-out); }
.term-close:hover { color: var(--accent); }

.panel-body, .term-body { padding: 1.3rem 1.4rem; }
.term-body { font-family: var(--font-mono); }
.panel-title { color: var(--text); font-weight: 700; margin: 0 0 0.9rem; font-size: 0.95rem; letter-spacing: -0.01em; }
.panel-note { color: var(--muted); font-size: 0.8rem; margin: -0.4rem 0 1rem; font-family: var(--font-mono); }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1.2rem; }
@media (max-width: 720px) { .grid2 { grid-template-columns: 1fr; } }

/* Terminal `$ whoami` preamble lines, reused by login/settings pages */
.line { font-size: 0.85rem; color: var(--muted); margin: 0 0 0.3rem; font-family: var(--font-mono); }
.line .prompt { color: var(--accent); }

/* =========================================================================
   Tiles — labelled stat block (dashboard, security, system)
   ========================================================================= */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.tile {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.2rem;
  position: relative;
  box-shadow: var(--shadow-sm);
  transition: border-color var(--dur-base) var(--ease-out), transform var(--dur-base) var(--ease-out);
}
.tile .label {
  font-size: 0.72rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em;
  font-family: var(--font-mono); margin-bottom: 0.5rem; display: flex; align-items: center;
}
.tile .value { font-size: 2rem; font-weight: 800; font-family: var(--font-mono); line-height: 1.1; }
.tile .value.accent { color: var(--accent); }
.tile .value.error { color: var(--error); }
.tile .value.good { color: var(--good); }
.tile .value.muted { color: var(--muted); }
.tile .sub { font-size: 0.75rem; color: var(--muted); margin-top: 0.35rem; display: flex; align-items: center; gap: 0.3em; }
.tile .sub.good { color: var(--good); }
.tile .sub.error { color: var(--error); }

/* =========================================================================
   Badges — one component, semantic modifiers. Aliases every legacy variant
   name in the codebase (.badge.good, .badge-good, .status-pill.st-fertig,
   .era-badge) so nothing needs to be rewritten to inherit the same look.
   ========================================================================= */
.badge, .status-pill, .era-badge {
  display: inline-flex; align-items: center; gap: 0.35em;
  font-family: var(--font-mono); font-size: 0.72rem; font-weight: 600;
  padding: 0.2rem 0.6rem; border-radius: 999px;
  background: var(--bg-terminal); color: var(--muted); border: 1px solid var(--border);
  white-space: nowrap; letter-spacing: 0.01em;
}
.badge.good, .badge-good, .status-pill.st-fertig, .era-badge.era-new,
.badge.ok { background: var(--good-dim); color: var(--good); border-color: #4ade8055; }
.badge.warn, .badge-warn, .status-pill.st-arbeit,
.badge.plan, .status-pill.st-geplant, .era-badge.era-mixed { background: var(--accent-dim); color: var(--accent); border-color: var(--accent-dim); }
.badge.error, .badge-error { background: var(--error-dim); color: var(--error); border-color: #ff5c5c55; }
.badge.info, .era-badge.era-old { background: var(--info-dim); color: var(--info); border-color: #6ea8fe55; }

/* =========================================================================
   Buttons — one primary shape everywhere (run_now, ./update-password,
   btc-btn, dl-btn all resolve to this).
   ========================================================================= */
.btn, button, .btc-btn, .dl-btn, .run-btn, .p-dl-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.45em;
  font-family: var(--font-ui); font-size: 0.85rem; font-weight: 700;
  border-radius: var(--radius-sm); border: none; cursor: pointer;
  padding: 0.6rem 1rem; text-decoration: none;
  background: var(--accent); color: var(--accent-ink);
  transition: filter var(--dur-fast) var(--ease-out), transform var(--dur-fast) var(--ease-out);
}
.btn:hover, button:hover, .btc-btn:hover, .dl-btn:hover, .run-btn:hover, .p-dl-btn:hover { filter: brightness(1.1); transform: translateY(-1px); }
.btn:active, button:active { transform: translateY(0); }
.btn:disabled, button:disabled { opacity: 0.55; cursor: default; transform: none; filter: none; }
.btn.secondary, .btc-btn.secondary {
  background: transparent; color: var(--accent); border: 1px solid var(--accent-dim);
}

/* =========================================================================
   Forms — `$ label` / `>` caret input row, shared by login + settings.
   ========================================================================= */
.field { margin-bottom: 1.1rem; }
.field label { display: block; font-size: 0.85rem; color: var(--accent); margin-bottom: 0.4rem; font-family: var(--font-mono); }
.field label::before { content: "$ "; color: var(--muted); }
.input-row {
  display: flex; align-items: center;
  background: var(--bg-terminal); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 0.65rem 0.85rem;
  transition: border-color var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out);
}
.input-row:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-dim); }
.input-row .caret { color: var(--accent); margin-right: 0.5rem; font-family: var(--font-mono); }
.input-row input {
  flex: 1; background: transparent; border: none; outline: none;
  color: var(--text); font-size: 0.9rem; font-family: var(--font-mono);
}
.input-row input::placeholder { color: #4a4a47; }
input:-webkit-autofill, input:-webkit-autofill:hover, input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--text);
  -webkit-box-shadow: 0 0 0px 1000px var(--bg-terminal) inset;
  caret-color: var(--text); font-family: var(--font-mono);
  transition: background-color 600000s ease-in-out 0s;
}
.hint { font-size: 0.72rem; color: var(--muted); margin: 0.35rem 0 0; }

.alert, .error, .success {
  display: flex; align-items: center; gap: 0.5em;
  font-size: 0.8rem; padding: 0.6rem 0.8rem; border-radius: var(--radius-sm); margin-bottom: 1.1rem;
}
.error { background: var(--error-dim); border: 1px solid #ff5c5c55; color: var(--error); }
.success { background: var(--good-dim); border: 1px solid #4ade8055; color: var(--good); }
.error:empty, .success:empty { display: none; }

/* =========================================================================
   Tables — dense data, monospace is the correct choice here (real data,
   not a costume): security logs, backup lists, IP/port tables.
   ========================================================================= */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
th {
  text-align: left; font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--muted); font-family: var(--font-mono);
  padding: 0 0.6rem 0.5rem 0; border-bottom: 1px solid var(--border); white-space: nowrap;
}
td { padding: 0.5rem 0.6rem 0.5rem 0; border-bottom: 1px solid var(--border-soft); font-family: var(--font-mono); font-size: 0.82rem; }
tr:last-child td { border-bottom: none; }
td.num { text-align: right; color: var(--accent); font-weight: 700; white-space: nowrap; font-variant-numeric: tabular-nums; }
td.bar-cell { width: 30%; white-space: normal; }
.hbar { background: var(--bg-terminal); border-radius: 4px; height: 7px; overflow: hidden; min-width: 50px; }
.hbar-fill { background: var(--accent); height: 100%; border-radius: 4px; }
.empty, .verw-empty { color: var(--muted); font-size: 0.85rem; font-family: var(--font-mono); }

/* =========================================================================
   Info tooltip (unchanged behaviour, tokenized)
   ========================================================================= */
.info-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--border); color: var(--muted);
  font-size: 0.62rem; font-family: var(--font-ui);
  cursor: help; position: relative; margin-left: 0.3rem; vertical-align: middle;
  transition: background var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
}
.info-icon:hover, .info-icon:focus-visible { background: var(--accent-dim); color: var(--accent); outline: none; }
.info-icon::after, .info-icon::before {
  position: absolute; left: 50%; transform: translateX(-50%) translateY(4px);
  opacity: 0; pointer-events: none; transition: opacity var(--dur-fast) var(--ease-out), transform var(--dur-fast) var(--ease-out);
  z-index: 30;
}
.info-icon::after {
  content: attr(data-tip); bottom: 145%;
  background: var(--bg-terminal); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 0.6rem 0.75rem; font-size: 0.72rem; font-weight: 400; text-transform: none;
  letter-spacing: normal; color: var(--text); white-space: normal; width: 230px;
  box-shadow: var(--shadow-lift);
}
.info-icon::before {
  content: ""; bottom: 132%; width: 8px; height: 8px; background: var(--bg-terminal);
  border-right: 1px solid var(--border); border-bottom: 1px solid var(--border);
  transform: translateX(-50%) rotate(45deg);
}
.info-icon:hover::after, .info-icon:hover::before,
.info-icon:focus-visible::after, .info-icon:focus-visible::before { opacity: 1; transform: translateX(-50%) translateY(0); }
.verw-table th .info-icon::after, .tile .info-icon::after, [data-tip-down] .info-icon::after { bottom: auto; top: 145%; transform: translateX(-50%) translateY(-4px); }
.verw-table th .info-icon::before, .tile .info-icon::before, [data-tip-down] .info-icon::before {
  bottom: auto; top: 132%; border-right: none; border-bottom: none;
  border-left: 1px solid var(--border); border-top: 1px solid var(--border);
}
.verw-table th .info-icon:hover::after, .verw-table th .info-icon:hover::before,
.tile .info-icon:hover::after, .tile .info-icon:hover::before,
[data-tip-down] .info-icon:hover::after, [data-tip-down] .info-icon:hover::before,
.verw-table th .info-icon:focus-visible::after, .verw-table th .info-icon:focus-visible::before,
.tile .info-icon:focus-visible::after, .tile .info-icon:focus-visible::before,
[data-tip-down] .info-icon:focus-visible::after, [data-tip-down] .info-icon:focus-visible::before { transform: translateX(-50%) translateY(0); }

/* =========================================================================
   Chart tooltip (replaces native SVG <title> hover on bar charts — see
   assets/charts.js). Cursor-following, styled like the rest of the app
   instead of the tiny delayed OS tooltip box.
   ========================================================================= */
.chart-tooltip {
  position: fixed; top: 0; left: 0; z-index: 200;
  background: var(--bg-terminal); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 0.45rem 0.7rem; font-family: var(--font-mono); font-size: 0.76rem; color: var(--text);
  box-shadow: var(--shadow-lift); white-space: nowrap; pointer-events: none;
  opacity: 0; transition: opacity var(--dur-fast) var(--ease-out);
}
.chart-tooltip.show { opacity: 1; }

/* =========================================================================
   Sidebar / app shell layout (unchanged structure, tokenized + refined)
   ========================================================================= */
body { display: flex; min-height: 100vh; }

.sidebar {
  width: 196px; flex-shrink: 0;
  background: var(--bg-elevated); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 1.4rem 0;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.sidebar-brand {
  font-family: var(--font-mono); font-weight: 700; font-size: 0.92rem; color: var(--text);
  padding: 0 1.2rem 1.2rem; margin-bottom: 0.6rem; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 0.5rem;
}
.sidebar-brand .accent { color: var(--accent); }
.sidebar-pulse { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 0 var(--accent-dim); animation: livePulse 2s infinite; flex-shrink: 0; }

.sidebar-nav { display: flex; flex-direction: column; gap: 0.15rem; padding: 0 0.65rem; flex: 1; }
.sidebar-group-label {
  font-family: var(--font-mono); font-size: 0.66rem; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--muted-dim); padding: 0.9rem 0.75rem 0.3rem;
}
.sidebar-group-label:first-child { padding-top: 0.1rem; }

.sidebar-link {
  font-family: var(--font-mono); font-size: 0.84rem; color: var(--muted); text-decoration: none;
  padding: 0.55rem 0.75rem; border-radius: var(--radius-sm); border-left: 2px solid transparent;
  transition: background var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out), border-color var(--dur-fast) var(--ease-out);
}
.sidebar-link:hover { color: var(--text); background: var(--bg-terminal); }
.sidebar-link.active { color: var(--accent); background: var(--accent-dim); border-left-color: var(--accent); font-weight: 600; }

.sidebar-footer { padding: 0.65rem; border-top: 1px solid var(--border); margin-top: 0.6rem; }
.sidebar-logout:hover { color: var(--error); }

.main { flex: 1; min-width: 0; padding: 2rem 1.4rem 4rem; }
.wrap { max-width: 980px; }

.sidebar-toggle { display: none; }
.sidebar-overlay { display: none; }

@media (max-width: 860px) {
  body { display: block; }
  .sidebar {
    position: fixed; top: 0; left: 0; height: 100vh; z-index: 50;
    transform: translateX(-100%); transition: transform var(--dur-base) var(--ease-in-out);
    box-shadow: 12px 0 40px rgba(0, 0, 0, 0.5);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-toggle {
    display: flex; align-items: center; justify-content: center;
    position: fixed; top: 1rem; left: 1rem; z-index: 40;
    width: 40px; height: 40px; border-radius: var(--radius-sm);
    background: var(--bg-elevated); border: 1px solid var(--border); color: var(--text); cursor: pointer;
  }
  .sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0, 0, 0, 0.5); z-index: 45; }
  .sidebar-overlay.show { display: block; }
  .main { padding-top: 4.5rem; }
}

/* Reduced motion: keep state-conveying pulses, drop everything decorative */
@media (prefers-reduced-motion: reduce) {
  .sidebar-pulse, .live-dot, .pulse { animation: none; }
  * { transition-duration: 0.001ms !important; }
}

/* Klappbare Hauptgruppen (nav.php, <details>) – 30.09.2026 */
.sidebar-group { border-top: 1px solid var(--border); padding: 0.15rem 0; }
.sidebar-group:first-child { border-top: 0; }
.sidebar-group > summary.sidebar-group-label {
  list-style: none; cursor: pointer; display: flex; justify-content: space-between; align-items: center;
  font-size: 0.74rem; font-weight: 700; color: var(--text); padding: 0.7rem 0.75rem 0.45rem; border-radius: var(--radius-sm);
}
.sidebar-group > summary::-webkit-details-marker { display: none; }
.sidebar-group > summary::after { content: '▸'; color: var(--muted-dim); transition: transform var(--dur-fast) var(--ease-out); }
.sidebar-group[open] > summary::after { transform: rotate(90deg); }
.sidebar-group > summary:hover { background: var(--bg-terminal); }
.sidebar-group .sidebar-link { display: block; }
