/* ============================================================
   ServerStats — Shared Design System
============================================================ */

:root {
  --bg:            #f0f2f5;
  --surface:       #ffffff;
  --border:        #e2e8f0;
  --text:          #1e293b;
  --muted:         #64748b;
  --primary:       #3b82f6;
  --primary-dark:  #2563eb;

  --good:          #15803d;
  --good-bg:       #dcfce7;
  --good-border:   #86efac;
  --warn:          #b45309;
  --warn-bg:       #fef3c7;
  --warn-border:   #fcd34d;
  --bad:           #b91c1c;
  --bad-bg:        #fee2e2;
  --bad-border:    #fca5a5;
  --offline:       #475569;
  --offline-bg:    #f1f5f9;
  --offline-border:#cbd5e1;

  --hdr-bg:    #0f172a;
  --hdr-fg:    #f1f5f9;
  --radius:    8px;
  --shadow:    0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,.1), 0 4px 6px -2px rgba(0,0,0,.05);
}

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

body {
  font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
}

/* ---- Header -------------------------------------------- */
.site-header {
  background: var(--hdr-bg);
  color: var(--hdr-fg);
  padding: 0 2rem;
  height: 52px;
  display: flex;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 200;
  box-shadow: 0 2px 8px rgba(0,0,0,.3);
}
.site-logo {
  font-size: .9rem;
  font-weight: 700;
  letter-spacing: .04em;
  color: #f8fafc;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: .5rem;
}
.site-logo .logo-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px; height: 28px;
  background: var(--primary);
  border-radius: 6px;
  font-size: .9rem;
}
.header-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 1.25rem;
}
.header-right a {
  color: #94a3b8;
  text-decoration: none;
  font-size: .8rem;
  transition: color .15s;
}
.header-right a:hover { color: #f1f5f9; }
.refresh-info {
  font-size: .75rem;
  color: #64748b;
  font-variant-numeric: tabular-nums;
}
.btn-notif {
  background: none;
  border: 1px solid rgba(255,255,255,.25);
  color: #94a3b8;
  border-radius: 6px;
  padding: .25rem .55rem;
  cursor: pointer;
  font-size: .8rem;
  line-height: 1.4;
  transition: color .15s, border-color .15s;
}
.btn-notif:hover { color: #f1f5f9; border-color: rgba(255,255,255,.55); }

/* ---- Alert-Banner -------------------------------------- */
.alert-banner {
  position: fixed;
  top: 52px; left: 0; right: 0;
  z-index: 300;
  background: var(--bad);
  color: #fff;
  padding: .7rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 600;
  font-size: .88rem;
  box-shadow: 0 3px 10px rgba(0,0,0,.25);
  animation: bannerSlide .25s ease;
}
.alert-banner.warn { background: var(--warn); }
.alert-banner-close {
  background: none;
  border: none;
  color: rgba(255,255,255,.85);
  cursor: pointer;
  font-size: 1.1rem;
  padding: 0 .25rem;
  line-height: 1;
  margin-left: 1rem;
}
.alert-banner-close:hover { color: #fff; }
@keyframes bannerSlide {
  from { transform: translateY(-100%); opacity: 0; }
  to   { transform: translateY(0);     opacity: 1; }
}

/* ---- Main layout --------------------------------------- */
.main { max-width: 1600px; margin: 0 auto; padding: 1.75rem 2rem; }

.page-header {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}
.page-header h1 {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
}
.page-header .meta {
  font-size: .78rem;
  color: var(--muted);
}

/* ---- Card ---------------------------------------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

/* ---- Data Table ---------------------------------------- */
.data-table { width: 100%; border-collapse: collapse; }

.data-table thead th {
  background: #f8fafc;
  border-bottom: 2px solid var(--border);
  padding: .55rem 1rem;
  text-align: left;
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
  white-space: nowrap;
}
.data-table thead th.sortable {
  cursor: pointer;
  user-select: none;
}
.data-table thead th.sortable:hover { background: #eef0f3; }
.sort-icon { margin-left: .3rem; font-size: .7rem; color: #cbd5e1; }
th.sorted .sort-icon { color: var(--primary); }

.data-table tbody tr {
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background .1s;
  border-left: 3px solid transparent;
}
.data-table tbody tr:last-child { border-bottom: none; }
.data-table tbody tr:hover { background: #f8fafc; }

.data-table tbody tr.row-good    { border-left-color: var(--good); }
.data-table tbody tr.row-warn    { border-left-color: var(--warn); }
.data-table tbody tr.row-bad     { border-left-color: var(--bad); }
.data-table tbody tr.row-offline { border-left-color: var(--offline-border); background: #fafafa; }
.data-table tbody tr.row-offline td { opacity: .75; }

.data-table td { padding: .6rem 1rem; vertical-align: middle; }

/* ---- Badge --------------------------------------------- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: .18rem .6rem;
  border-radius: 999px;
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .04em;
  white-space: nowrap;
  border: 1px solid transparent;
}
.badge.good    { background: var(--good-bg);    color: var(--good);    border-color: var(--good-border); }
.badge.warn    { background: var(--warn-bg);    color: var(--warn);    border-color: var(--warn-border); }
.badge.bad     { background: var(--bad-bg);     color: var(--bad);     border-color: var(--bad-border); }
.badge.offline { background: var(--offline-bg); color: var(--offline); border-color: var(--offline-border); }

/* ---- Chip (inline tag) --------------------------------- */
.chip {
  display: inline-flex;
  align-items: center;
  gap: .2rem;
  padding: .1rem .4rem;
  border-radius: 4px;
  font-size: .68rem;
  font-weight: 600;
  margin-left: .35rem;
  white-space: nowrap;
  vertical-align: middle;
  border: 1px solid transparent;
}
.chip-update { background: #fef3c7; color: #92400e; border-color: #fcd34d; }
.chip-reboot { background: #ede9fe; color: #5b21b6; border-color: #c4b5fd; }

/* ---- Progress bar -------------------------------------- */
.progress {
  height: 4px;
  background: #e2e8f0;
  border-radius: 999px;
  overflow: hidden;
  margin-top: 4px;
  min-width: 64px;
}
.progress-fill { height: 100%; border-radius: 999px; }
.progress-fill.good    { background: var(--good); }
.progress-fill.warn    { background: var(--warn); }
.progress-fill.bad     { background: var(--bad); }
.progress-fill.offline { background: var(--offline-border); }

/* ---- Typography helpers -------------------------------- */
.mono  { font-family: 'SF Mono', 'Cascadia Code', 'Fira Code', ui-monospace, monospace; }
.muted { color: var(--muted); }
.sm    { font-size: .8rem; }
.bold  { font-weight: 600; }
.text-bad  { color: var(--bad); }
.text-warn { color: var(--warn); }
.text-good { color: var(--good); }

/* ---- Tooltip ------------------------------------------- */
.has-tip { position: relative; cursor: help; }
.has-tip:hover::after {
  content: attr(data-tip);
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  background: #1e293b;
  color: #f8fafc;
  padding: .4rem .65rem;
  border-radius: 5px;
  font-size: .75rem;
  white-space: pre;
  z-index: 500;
  max-width: 360px;
  box-shadow: var(--shadow-lg);
  pointer-events: none;
  line-height: 1.6;
}

/* ---- History icon link --------------------------------- */
a.history-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px; height: 22px;
  border-radius: 5px;
  text-decoration: none;
  font-size: .8rem;
  color: var(--muted);
  transition: background .15s, color .15s;
  vertical-align: middle;
  margin-left: .3rem;
}
a.history-icon:hover { background: #e2e8f0; color: var(--text); }

/* ---- Back link ----------------------------------------- */
a.back-link {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  color: var(--muted);
  text-decoration: none;
  font-size: .83rem;
  margin-bottom: 1.25rem;
  transition: color .15s;
}
a.back-link:hover { color: var(--text); }
a.back-link::before { content: '←'; }

/* ---- Detail Grid --------------------------------------- */
.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 1rem;
}
.detail-grid .full-width { grid-column: 1 / -1; }

.detail-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.detail-card-title {
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
  padding: .55rem 1rem;
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: .4rem;
}
.detail-card-title .icon { font-size: .85rem; }

.kv-table { width: 100%; border-collapse: collapse; }
.kv-table tr { border-bottom: 1px solid var(--border); }
.kv-table tr:last-child { border-bottom: none; }
.kv-table th {
  padding: .45rem 1rem;
  font-size: .8rem;
  font-weight: 500;
  color: var(--muted);
  text-align: left;
  white-space: nowrap;
  width: 160px;
  background: transparent;
}
.kv-table td { padding: .45rem 1rem; font-size: .85rem; }

/* Disk mini table inside detail card */
.disk-row { display: flex; align-items: center; gap: .6rem; padding: .45rem 1rem; border-bottom: 1px solid var(--border); }
.disk-row:last-child { border-bottom: none; }
.disk-label { font-family: 'SF Mono', ui-monospace, monospace; font-size: .75rem; color: var(--muted); min-width: 140px; flex-shrink: 0; }
.disk-pct   { font-size: .82rem; font-weight: 600; min-width: 46px; }
.disk-bar   { flex: 1; height: 5px; background: #e2e8f0; border-radius: 999px; overflow: hidden; }
.disk-bar-fill { height: 100%; border-radius: 999px; }
.disk-bar-fill.good { background: var(--good); }
.disk-bar-fill.warn { background: var(--warn); }
.disk-bar-fill.bad  { background: var(--bad); }
.disk-free  { font-size: .75rem; color: var(--muted); min-width: 70px; text-align: right; }

/* Docker container list */
.docker-row {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .4rem 1rem;
  border-bottom: 1px solid var(--border);
  font-size: .82rem;
}
.docker-row:last-child { border-bottom: none; }
.docker-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}
.docker-dot.up   { background: var(--good); }
.docker-dot.down { background: var(--bad); }
.docker-name { font-family: 'SF Mono', ui-monospace, monospace; font-size: .78rem; }
.docker-status { margin-left: auto; font-size: .75rem; color: var(--muted); }

/* ---- Day selector (history) ---------------------------- */
.day-selector { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: 1.5rem; }
.day-selector a {
  padding: .3rem .85rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  text-decoration: none;
  color: var(--text);
  font-size: .82rem;
  background: var(--surface);
  transition: all .15s;
}
.day-selector a:hover  { border-color: var(--primary); color: var(--primary); }
.day-selector a.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ---- Chart card ---------------------------------------- */
.chart-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  margin-bottom: 1rem;
}
.chart-card-title {
  padding: .6rem 1rem;
  border-bottom: 1px solid var(--border);
  font-size: .78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--muted);
}
.chart-card-body { padding: 1rem; position: relative; height: 200px; }

/* ---- ntfy header icon ---------------------------------- */
a.ntfy-header-link {
  display: inline-flex;
  align-items: center;
  opacity: .7;
  transition: opacity .15s;
  border-radius: 4px;
}
a.ntfy-header-link:hover { opacity: 1; }
.ntfy-header-icon {
  width: 22px;
  height: 22px;
  border-radius: 4px;
  display: block;
}

/* ---- Logout button (header) ---------------------------- */
a.btn-logout {
  font-size: .75rem;
  color: #64748b;
  text-decoration: none;
  padding: .25rem .65rem;
  border: 1px solid #334155;
  border-radius: 5px;
  transition: all .15s;
  white-space: nowrap;
}
a.btn-logout:hover { color: #f1f5f9; border-color: #475569; background: rgba(255,255,255,.07); }

/* ---- Login form ---------------------------------------- */
.login-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 52px);
  padding: 2rem;
}
.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 2rem 2.25rem;
  width: 100%;
  max-width: 360px;
}
.login-card h2 {
  font-size: 1.05rem;
  font-weight: 700;
  margin-bottom: 1.5rem;
  color: var(--text);
}
.form-group { margin-bottom: 1rem; }
.form-group label {
  display: block;
  font-size: .78rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: .35rem;
  text-transform: uppercase;
  letter-spacing: .05em;
}
.form-group input[type="text"],
.form-group input[type="password"] {
  width: 100%;
  padding: .55rem .75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: .9rem;
  color: var(--text);
  background: var(--surface);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.form-group input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59,130,246,.15);
}
.btn-submit {
  width: 100%;
  padding: .6rem;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
  margin-top: .75rem;
  transition: background .15s;
}
.btn-submit:hover { background: var(--primary-dark); }
.alert-error {
  background: var(--bad-bg);
  color: var(--bad);
  border: 1px solid var(--bad-border);
  border-radius: 6px;
  padding: .5rem .75rem;
  font-size: .82rem;
  margin-bottom: 1.25rem;
}

/* ---- State messages ------------------------------------ */
.state-msg {
  text-align: center;
  padding: 3rem 2rem;
  color: var(--muted);
  font-size: .9rem;
}
.state-msg.error { color: var(--bad); }

/* ---- Buttons (allgemein) -------------------------------- */
.btn-primary, .btn-secondary, .btn-danger {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  padding: .45rem .9rem;
  border-radius: 6px;
  font-size: .82rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all .15s;
  white-space: nowrap;
  line-height: 1.4;
}
.btn-primary   { background: var(--primary);  color: #fff;         border-color: var(--primary); }
.btn-primary:hover   { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-secondary { background: #fff;            color: var(--text);  border-color: var(--border); }
.btn-secondary:hover { background: #f1f5f9; border-color: #94a3b8; }
.btn-danger    { background: var(--bad-bg);   color: var(--bad);   border-color: var(--bad-border); }
.btn-danger:hover    { background: #fca5a5;   color: var(--bad); }
.btn-sm { padding: .28rem .65rem; font-size: .75rem; }
.btn-icon-danger {
  background: none; border: none; cursor: pointer;
  color: #94a3b8; font-size: .9rem; padding: .2rem .4rem;
  border-radius: 4px; transition: color .15s, background .15s;
  line-height: 1;
}
.btn-icon-danger:hover { color: var(--bad); background: var(--bad-bg); }

/* ---- Gruppierte Dashboard-Ansicht ----------------------- */
.pathology-group {
  margin-bottom: 1.25rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.pathology-group-header {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .65rem 1rem;
  border-bottom: 1px solid var(--border);
  background: #f8fafc;
  border-left: 4px solid var(--border);
}
.pathology-group-header.pg-good    { border-left-color: var(--good); }
.pathology-group-header.pg-warn    { border-left-color: var(--warn); }
.pathology-group-header.pg-bad     { border-left-color: var(--bad); }
.pathology-group-header.pg-offline { border-left-color: var(--offline-border); }
.pg-name    { font-weight: 700; font-size: .88rem; color: var(--text); }
.pg-summary { font-size: .78rem; }
.pg-admin-link {
  margin-left: auto;
  font-size: .75rem;
  color: var(--muted);
  text-decoration: none;
  transition: color .15s;
  white-space: nowrap;
}
.pg-admin-link:hover { color: var(--primary); }
.pg-notes {
  padding: .35rem 1rem;
  font-size: .78rem;
  color: var(--muted);
  background: #fafbfc;
  border-bottom: 1px solid var(--border);
}
.unregistered-group .pathology-group-header { background: var(--warn-bg); }

/* ---- Admin-Seite ---------------------------------------- */
.admin-form-card { margin-bottom: 1.25rem; overflow: visible; }
.admin-form-header {
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
  padding: .55rem 1rem;
  font-size: .78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--muted);
}
.admin-form-body  { padding: 1rem; }
.admin-form-row   { display: flex; gap: 1rem; flex-wrap: wrap; }
.admin-form-row .form-group { flex: 1; min-width: 180px; }
.admin-form-actions {
  display: flex;
  align-items: center;
  gap: .5rem;
  margin-top: .75rem;
  flex-wrap: wrap;
}
.admin-input {
  width: 100%;
  padding: .45rem .65rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: .85rem;
  color: var(--text);
  background: var(--surface);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.admin-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59,130,246,.12);
}
.admin-input-sm {
  padding: .3rem .55rem;
  border: 1px solid var(--border);
  border-radius: 5px;
  font-size: .8rem;
  color: var(--text);
  background: var(--surface);
  outline: none;
  transition: border-color .15s;
  min-width: 140px;
}
.admin-input-sm:focus { border-color: var(--primary); }

.admin-pathology-card { margin-bottom: 1.25rem; overflow: visible; }
.admin-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .65rem 1rem;
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
  gap: .75rem;
}
.admin-card-title-row  { display: flex; align-items: baseline; gap: .6rem; flex-wrap: wrap; }
.admin-pathology-name  { font-weight: 700; font-size: .95rem; }
.admin-pathology-notes { color: var(--muted); }
.admin-card-actions    { display: flex; gap: .4rem; flex-shrink: 0; }

.admin-edit-form {
  background: #fffbeb;
  border-bottom: 1px solid var(--warn-border);
  padding: 0;
}
.admin-edit-form .admin-form-body { padding: .85rem 1rem; }
.admin-server-table { border-top: none; }
.admin-td-center { text-align: center; }
.admin-td-right  { text-align: right; }

.admin-toggle {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  font-size: .8rem;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
}
.admin-toggle input[type="checkbox"] { cursor: pointer; }

.admin-add-server {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .65rem 1rem;
  background: #f8fafc;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}

.admin-empty-state {
  text-align: center;
  padding: 3rem 2rem;
  color: var(--muted);
  font-size: .9rem;
  line-height: 2;
}

.admin-error {
  color: var(--bad);
  font-size: .8rem;
  font-weight: 500;
}

.section-divider {
  display: flex;
  align-items: baseline;
  gap: .5rem;
  margin-bottom: 1rem;
}
.section-divider-label {
  font-size: .78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--muted);
}
