/* Hotspot Monitor – mørkt, datatæt network-ops-tema */

:root {
  --bg: #0d1117;
  --surface: #141a22;
  --surface-2: #1a222c;
  --surface-3: #202a36;
  --border: #2a3543;
  --divider: #1f2933;
  --text: #dbe3ec;
  --text-muted: #8b98a8;
  --text-faint: #5c6875;
  --accent: #4cc2d7;
  --accent-dim: #2b5a66;
  --online: #46c07a;
  --offline: #e05260;
  --unknown: #d9a03f;
  --font-body: 'General Sans', 'Inter', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', 'SFMono-Regular', Consolas, monospace;
  --radius: 8px;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}

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

html { -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }

body {
  min-height: 100dvh;
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: none; }
a { color: var(--accent); text-decoration: none; }

::selection { background: rgba(76, 194, 215, 0.25); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums lining-nums; }

/* ---------- Layout ---------- */

.app { display: grid; grid-template-columns: 216px 1fr; min-height: 100dvh; }

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 20px 12px;
  display: flex; flex-direction: column; gap: 4px;
  position: sticky; top: 0; height: 100dvh; overflow-y: auto;
  overscroll-behavior: contain;
}

.brand {
  display: flex; align-items: center; gap: 10px;
  padding: 4px 10px 18px; font-weight: 600; font-size: 15px;
}
.brand svg { flex: none; }
.brand .sub { display: block; font-size: 11px; font-weight: 400; color: var(--text-faint); }

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: var(--radius);
  color: var(--text-muted); font-size: 13.5px; font-weight: 500;
  border: 1px solid transparent;
}
.nav-item:hover { color: var(--text); background: var(--surface-2); }
.nav-item.active { color: var(--text); background: var(--surface-3); border-color: var(--border); }
.nav-item .count {
  margin-left: auto; font-size: 11px; font-family: var(--font-mono);
  background: var(--offline); color: #fff; border-radius: 999px;
  padding: 1px 7px; min-width: 20px; text-align: center;
}
.nav-item .count:empty, .nav-item .count[data-zero="1"] { display: none; }

.sidebar-foot {
  margin-top: auto; padding: 10px; font-size: 11px; color: var(--text-faint);
  border-top: 1px solid var(--divider); line-height: 1.7;
}
.sidebar-foot .dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 6px; background: var(--unknown); }
.sidebar-foot .dot.ok { background: var(--online); }
.sidebar-foot .dot.err { background: var(--offline); }

.main { min-width: 0; display: flex; flex-direction: column; }

.topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 16px 24px; border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky; top: 0; z-index: 20;
}
.topbar h1 { font-size: 17px; font-weight: 600; letter-spacing: 0.2px; }
.topbar .spacer { flex: 1; }
.topbar .updated { font-size: 12px; color: var(--text-muted); }

.content { padding: 20px 24px 40px; overflow-y: auto; overscroll-behavior: contain; }

/* ---------- KPI-kort ---------- */

.kpi-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px; margin-bottom: 20px;
}
.kpi {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 16px;
}
.kpi .label { font-size: 12px; color: var(--text-muted); margin-bottom: 4px; }
.kpi .value { font-size: 26px; font-weight: 600; font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.kpi .value.ok { color: var(--online); }
.kpi .value.bad { color: var(--offline); }
.kpi .value.warn { color: var(--unknown); }

/* ---------- Site-kort ---------- */

.site-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.site-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px; cursor: pointer;
  transition: border-color 0.15s ease;
}
.site-card:hover { border-color: var(--accent-dim); }
.site-card .head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 12px; }
.site-card .head h3 { font-size: 14px; font-weight: 600; }
.site-card .head .slug { font-size: 11px; color: var(--text-faint); font-family: var(--font-mono); }
.site-card .stats { display: flex; gap: 16px; margin-bottom: 12px; }
.site-card .stat { display: flex; align-items: center; gap: 7px; font-size: 13px; color: var(--text-muted); }
.site-card .stat b { font-family: var(--font-mono); font-size: 15px; color: var(--text); font-weight: 600; }
.bar { height: 5px; border-radius: 999px; background: var(--surface-3); display: flex; overflow: hidden; margin-bottom: 12px; }
.bar .seg-online { background: var(--online); }
.bar .seg-offline { background: var(--offline); }
.bar .seg-unknown { background: var(--unknown); }
.site-card .meta { display: flex; gap: 14px; font-size: 11.5px; color: var(--text-faint); flex-wrap: wrap; }
.site-card .meta .alert { color: var(--offline); }

/* ---------- Filtre ---------- */

.filters {
  display: flex; gap: 10px; flex-wrap: wrap; align-items: center;
  margin-bottom: 16px;
}
.filters input[type="search"], .filters select, .filters input[type="text"], .filters input[type="number"] {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 8px 10px; font-size: 13px; color: var(--text); min-width: 120px;
}
.filters input[type="search"] { flex: 1; min-width: 200px; }
.filters select { appearance: none; padding-right: 28px;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-muted) 50%), linear-gradient(135deg, var(--text-muted) 50%, transparent 50%);
  background-position: calc(100% - 15px) 55%, calc(100% - 10px) 55%; background-size: 5px 5px; background-repeat: no-repeat; }
.filters .chip {
  font-size: 12px; padding: 5px 10px; border-radius: 999px;
  background: var(--accent-dim); color: var(--accent);
  display: inline-flex; align-items: center; gap: 6px;
}
.filters .chip button { color: inherit; font-size: 13px; }

/* ---------- Tabeller ---------- */

.table-wrap {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: auto; overscroll-behavior: contain;
}
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
  position: sticky; top: 0; z-index: 1;
  background: var(--surface-2); color: var(--text-muted);
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.6px;
  font-weight: 600; text-align: left; padding: 9px 12px;
  border-bottom: 1px solid var(--border); white-space: nowrap;
}
tbody td { padding: 9px 12px; border-bottom: 1px solid var(--divider); white-space: nowrap; }
tbody tr { cursor: pointer; transition: background 0.12s ease; }
tbody tr:hover { background: var(--surface-2); }
tbody tr:last-child td { border-bottom: none; }

.status-badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 500;
}
.status-badge::before { content: ""; width: 8px; height: 8px; border-radius: 50%; flex: none; }
.status-badge.online::before { background: var(--online); box-shadow: 0 0 6px rgba(70, 192, 122, 0.5); }
.status-badge.offline::before { background: var(--offline); }
.status-badge.unknown::before { background: var(--unknown); }
.status-badge.online { color: var(--online); }
.status-badge.offline { color: var(--offline); }
.status-badge.unknown { color: var(--unknown); }

td .note-ind { color: var(--text-faint); font-size: 11px; margin-left: 6px; }

.empty {
  padding: 48px 20px; text-align: center; color: var(--text-muted); font-size: 13.5px;
}
.empty .big { font-size: 15px; color: var(--text); margin-bottom: 6px; }

/* ---------- Drawer ---------- */

.drawer-veil {
  position: fixed; inset: 0; background: rgba(4, 8, 12, 0.6);
  z-index: 50; opacity: 0; pointer-events: none; transition: opacity 0.18s ease;
}
.drawer-veil.open { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed; top: 0; right: -480px; bottom: 0; width: 460px; max-width: 94vw;
  background: var(--surface); border-left: 1px solid var(--border);
  z-index: 51; overflow-y: auto; overscroll-behavior: contain;
  transition: right 0.2s cubic-bezier(0.16, 1, 0.3, 1); padding: 20px 22px 40px;
}
.drawer.open { right: 0; }
.drawer .close {
  position: absolute; top: 14px; right: 14px; color: var(--text-faint);
  font-size: 20px; line-height: 1; padding: 6px;
}
.drawer .close:hover { color: var(--text); }
.drawer h2 { font-size: 16px; font-weight: 600; margin: 2px 40px 2px 0; }
.drawer .sub { font-size: 12px; color: var(--text-muted); margin-bottom: 16px; }
.drawer h3 {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.6px;
  color: var(--text-muted); margin: 20px 0 8px; font-weight: 600;
}
.kv { display: grid; grid-template-columns: 110px 1fr; gap: 6px 12px; font-size: 13px; }
.kv dt { color: var(--text-faint); }
.kv dd { word-break: break-all; }
.drawer textarea {
  width: 100%; min-height: 90px; background: var(--surface-2);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 10px; font-size: 13px; resize: vertical;
}
.hist { max-height: 220px; overflow-y: auto; overscroll-behavior: contain; }
.hist .row {
  display: flex; justify-content: space-between; gap: 10px;
  font-size: 12px; padding: 4px 0; border-bottom: 1px solid var(--divider);
  font-family: var(--font-mono); font-variant-numeric: tabular-nums;
}
.evt-list .evt {
  display: flex; justify-content: space-between; gap: 10px; font-size: 12.5px;
  padding: 7px 0; border-bottom: 1px solid var(--divider);
}
.evt-list .evt .dur { color: var(--text-muted); font-family: var(--font-mono); }

/* ---------- Knapper og forms ---------- */

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--surface-3); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 7px 12px; font-size: 13px; font-weight: 500;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.btn:hover { border-color: var(--accent-dim); }
.btn.primary { background: var(--accent-dim); border-color: transparent; color: #dff3f7; }
.btn.primary:hover { background: #35707f; }
.btn.danger { color: var(--offline); }
.btn.small { padding: 4px 8px; font-size: 12px; }
.btn:disabled { opacity: 0.5; cursor: default; }

.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; }
.field label { font-size: 12px; color: var(--text-muted); font-weight: 500; }
.field input, .field select, .field textarea {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 8px 10px; font-size: 13px;
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.admin-section { margin-bottom: 28px; }
.admin-section > h2 { font-size: 14px; font-weight: 600; margin-bottom: 12px; }
.admin-section .actions { margin-bottom: 12px; display: flex; gap: 8px; }

.toast {
  position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%) translateY(8px);
  background: var(--surface-3); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 10px 16px; font-size: 13px; z-index: 100; opacity: 0;
  transition: opacity 0.2s ease, transform 0.2s ease; pointer-events: none;
  box-shadow: var(--shadow); max-width: 90vw;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { border-color: var(--offline); color: #f3b6bc; }
.toast.ok { border-color: var(--online); color: #b9e8cd; }

.src-status { font-size: 11.5px; }
.src-status.ok { color: var(--online); }
.src-status.err { color: var(--offline); }

@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 10px 12px; gap: 6px; }
  .brand { padding: 4px 8px; }
  .sidebar-foot { display: none; }
  .nav-item { padding: 6px 10px; }
  .nav-item .count { margin-left: 4px; }
  .content { padding: 14px 12px 32px; }
  .topbar { padding: 12px 14px; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
}
