/* v2uptime — shared styles (public status page + admin panel). */

@font-face {
  font-family: "Vazirmatn";
  src: url("../fonts/Vazirmatn-Variable.woff2") format("woff2-variations"),
       url("../fonts/Vazirmatn-Variable.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-2: #f1f3f7;
  --surface-3: #e8ebf1;
  --border: #e1e5ec;
  --text: #161b22;
  --text-2: #3b4350;
  --muted: #6b7482;
  --accent: #2f6fed;
  --accent-soft: #e6eefe;
  --accent-text: #ffffff;
  --ok: #18a058;
  --ok-soft: #e3f6ec;
  --warn: #d48806;
  --warn-soft: #fdf3dc;
  --bad: #d93a3a;
  --bad-soft: #fde8e8;
  --unknown: #8a94a3;
  --unknown-soft: #eef0f3;
  --lv-up: #22b26b;
  --lv-minor: #9ccc3d;
  --lv-major: #f0a020;
  --lv-down: #e04848;
  --lv-none: #d5dae2;
  --shadow: 0 1px 2px rgba(17, 24, 39, .04), 0 6px 18px rgba(17, 24, 39, .05);
  --shadow-lg: 0 12px 40px rgba(17, 24, 39, .18);
  --radius: 14px;
  --radius-sm: 9px;
  --focus: 0 0 0 3px rgba(47, 111, 237, .35);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1116;
    --surface: #161a21;
    --surface-2: #1c212a;
    --surface-3: #252b36;
    --border: #2a303b;
    --text: #e8ecf2;
    --text-2: #c3cad5;
    --muted: #8d97a6;
    --accent: #5b8cff;
    --accent-soft: #1d2a45;
    --ok: #34c77b;
    --ok-soft: #14301f;
    --warn: #f0b13d;
    --warn-soft: #332810;
    --bad: #f06464;
    --bad-soft: #3a1a1c;
    --unknown: #8d97a6;
    --unknown-soft: #232831;
    --lv-up: #2fbf73;
    --lv-minor: #9ac83f;
    --lv-major: #e9a12a;
    --lv-down: #e25555;
    --lv-none: #2d333e;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 18px rgba(0, 0, 0, .25);
    --shadow-lg: 0 12px 40px rgba(0, 0, 0, .55);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #0e1116;
  --surface: #161a21;
  --surface-2: #1c212a;
  --surface-3: #252b36;
  --border: #2a303b;
  --text: #e8ecf2;
  --text-2: #c3cad5;
  --muted: #8d97a6;
  --accent: #5b8cff;
  --accent-soft: #1d2a45;
  --ok: #34c77b;
  --ok-soft: #14301f;
  --warn: #f0b13d;
  --warn-soft: #332810;
  --bad: #f06464;
  --bad-soft: #3a1a1c;
  --unknown: #8d97a6;
  --unknown-soft: #232831;
  --lv-up: #2fbf73;
  --lv-minor: #9ac83f;
  --lv-major: #e9a12a;
  --lv-down: #e25555;
  --lv-none: #2d333e;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 18px rgba(0, 0, 0, .25);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, .55);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif, "Vazirmatn";
  font-size: 15px;
  line-height: 1.65;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
h1, h2, h3, h4 { line-height: 1.35; margin: 0; font-weight: 700; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: 6px; }
[hidden] { display: none !important; }
.ic { width: 18px; height: 18px; flex: none; vertical-align: -4px; }
small { font-size: .78em; }
code, .mono, input.mono, textarea.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; direction: ltr; }
.ltr { direction: ltr; unicode-bidi: isolate; }
.muted { color: var(--muted); }
.container { width: 100%; max-width: 1240px; margin: 0 auto; padding: 0 16px; }

/* ------------------------------------------------------------------ buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 40px; padding: 8px 16px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  cursor: pointer; font-weight: 600; font-size: 14px; white-space: nowrap; text-decoration: none;
  transition: background .15s, border-color .15s, color .15s;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn-primary:hover { background: var(--accent); filter: brightness(1.08); }
.btn-danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, var(--border)); }
.btn-danger:hover { background: var(--bad-soft); }
.btn-sm { min-height: 32px; padding: 4px 10px; font-size: 13px; }
.icon-btn {
  display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 50%;
  border: 1px solid var(--border); background: var(--surface); color: var(--text-2); cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); }

/* ------------------------------------------------------------------ public page */
.public .wrap { width: 100%; max-width: 760px; margin: 0 auto; padding: 0 16px; }
.public h1 { font-size: 20px; }
.fine { font-size: 13px; color: var(--text-2); }
.page-top { padding: 16px 0 8px; }
.page-top-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.page-top .fine { margin: 4px 0 0; }
.sort-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 8px 0 16px; }
.banner { margin: 0; padding: 12px 16px; border-radius: 12px; font-weight: 700; }
.banner-ok { background: var(--ok-soft); border: 1px solid var(--ok); }
.banner-warn { background: var(--warn-soft); border: 1px solid var(--warn); }
.banner-bad { background: var(--bad-soft); border: 1px solid var(--bad); }
.banner-wait { background: var(--surface); border: 1px solid var(--border); }
.check-line { margin: 8px 0 16px; }
.theme-toggle .ic-moon { display: none; }
:root[data-theme="dark"] .theme-toggle .ic-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .ic-moon { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .ic-sun { display: none; }
  :root:not([data-theme="light"]) .theme-toggle .ic-moon { display: block; }
}

.segmented { display: flex; gap: 4px; flex-wrap: wrap; background: var(--surface-2); border-radius: 8px; padding: 4px; width: fit-content; }
.seg {
  display: inline-flex; align-items: center; justify-content: center; border: 0; background: transparent;
  padding: 8px 12px; border-radius: 8px; cursor: pointer; color: var(--text-2); font-weight: 600; text-decoration: none;
}
.seg:hover { text-decoration: none; color: var(--text); }
.seg.is-active { background: var(--surface); color: var(--text); }
.search {
  display: flex; align-items: center; gap: 8px; flex: 1; min-width: 160px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 8px; padding: 0 12px; color: var(--text-2);
}
.search input { flex: 1; min-width: 0; border: 0; background: transparent; padding: 8px 0; outline: none; color: var(--text); }

/* ------------------------------------------------------------------ summary */
.summary { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.stat {
  display: flex; align-items: center; gap: 12px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow);
}
.stat .ic { width: 28px; height: 28px; padding: 5px; border-radius: 10px; box-sizing: content-box; }
.stat-online .ic { color: var(--ok); background: var(--ok-soft); }
.stat-degraded .ic { color: var(--warn); background: var(--warn-soft); }
.stat-offline .ic { color: var(--bad); background: var(--bad-soft); }
.stat-uptime .ic { color: var(--accent); background: var(--accent-soft); }
.stat-value { display: block; font-size: 1.35rem; font-weight: 800; line-height: 1.2; font-variant-numeric: tabular-nums; }
time, .num, .row-ping, .row-up { font-variant-numeric: tabular-nums; }
.stat-label { display: block; color: var(--muted); font-size: 12.5px; }
@media (min-width: 700px) { .summary { grid-template-columns: repeat(4, 1fr); } }
.updated { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; color: var(--muted); font-size: 13px; margin: 12px 2px 14px; }
.updated .sep { opacity: .6; }

.list-head, .row-main {
  display: grid; grid-template-columns: minmax(0, 1fr) 7.5rem 5.25rem 6.25rem; gap: 8px; align-items: center;
}
@media (max-width: 699px) {
  .row-main { grid-template-columns: minmax(0, 1fr) auto auto auto; }
}
.list-head { padding: 8px 12px 4px; }
.list-head span:nth-child(n+3), .row-ping, .row-up { text-align: end; }
.server-list { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; }
.server-list > li + li { border-top: 1px solid var(--border); }
.row-main {
  width: 100%; min-height: 44px; padding: 8px 12px; border: 0; background: transparent; color: inherit;
  cursor: pointer; text-align: start;
}
.row-main:hover { background: var(--surface-2); }
.row-server { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-status, .row-ping, .row-up { white-space: nowrap; }
.row-status.is-new { color: #4b5563; }
:root[data-theme="dark"] .row-status.is-new { color: #c5ced9; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .row-status.is-new { color: #c5ced9; }
}
.view-fastest .row-ping, .view-stable .row-up { font-weight: 800; }
.flag { line-height: 1; }
.row-detail { padding: 4px 12px 12px; }
.row-detail > p { margin: 8px 0; }
.chart-range { margin: 8px 0; }
.chip {
  font-size: 12px; padding: 1px 8px; border-radius: 6px; background: var(--surface-2); color: var(--text-2);
  direction: ltr; font-weight: 600;
}
.bars { display: flex; gap: 2px; height: 28px; direction: ltr; align-items: stretch; }
.b {
  flex: 1 1 0; min-width: 2px; border-radius: 2px; background: var(--lv-none); transition: transform .1s, filter .1s;
}
.b:hover, .b.is-hover { transform: scaleY(1.12); filter: brightness(1.1); }
.lv-up { background: var(--lv-up); }
.lv-minor { background: var(--lv-minor); }
.lv-major { background: var(--lv-major); }
.lv-down { background: var(--lv-down); }
.bars-axis { display: flex; justify-content: space-between; direction: ltr; margin-top: 4px; }
.empty {
  text-align: center; color: var(--muted); padding: 48px 16px; background: var(--surface);
  border: 1px dashed var(--border); border-radius: var(--radius);
}
.empty .ic { width: 40px; height: 40px; opacity: .6; }
.site-footer { color: var(--text-2); font-size: 13px; padding-top: 24px; padding-bottom: 32px; text-align: center; }
.public .empty { color: var(--text-2); }

/* ------------------------------------------------------------------ tooltip */
.tooltip {
  position: fixed; z-index: 60; pointer-events: none; max-width: 260px;
  background: var(--text); color: var(--bg); border-radius: 8px; padding: 8px 12px; font-size: 13px;
}
.chart { position: relative; height: 160px; direction: ltr; }
.chart canvas { width: 100%; height: 100%; display: block; }
.chart.is-loading { background: var(--surface-2); border-radius: 8px; }
.list-head { display: none; }
@media (min-width: 700px) { .list-head { display: grid; } }

/* ================================================================== admin */
.admin { background: var(--bg); }
.admin-shell { min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 30; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--border);
}
.topbar .brand { display: flex; align-items: center; gap: 8px; font-weight: 800; color: var(--text); }
.topbar .brand:hover { text-decoration: none; }
.topbar-actions { display: flex; gap: 8px; align-items: center; }
.nav-toggle { display: inline-grid; }
.admin-body { display: flex; flex: 1; min-width: 0; }
.sidenav {
  position: fixed; inset-block: 57px 0; inset-inline-start: 0; z-index: 25; width: 240px; padding: 12px;
  background: var(--surface); border-inline-end: 1px solid var(--border); transform: translateX(-100%);
  transition: transform .2s; overflow-y: auto;
}
.sidenav.is-open { transform: none; box-shadow: var(--shadow-lg); }
.sidenav a {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 10px; color: var(--text-2);
  font-weight: 600; margin-bottom: 2px;
}
.sidenav a:hover { background: var(--surface-2); text-decoration: none; }
.sidenav a.is-active { background: var(--accent-soft); color: var(--accent); }
.admin-main { flex: 1; min-width: 0; padding: 18px 16px 40px; }
@media (min-width: 960px) {
  .nav-toggle { display: none; }
  .sidenav { position: sticky; top: 57px; height: calc(100vh - 57px); transform: none; flex: none; }
  .admin-main { padding: 24px 28px 48px; }
}
.section-tabs { margin-bottom: 16px; }
.section-tabs .seg { min-height: 36px; }
.settings-page #monitoring { display: none; }
.settings-page:has(#monitoring:target) #general { display: none; }
.settings-page:has(#monitoring:target) #monitoring { display: block; }
.settings-page:not(:has(#monitoring:target)) a[data-settings-tab="general"],
.settings-page:has(#monitoring:target) a[data-settings-tab="monitoring"] { background: var(--surface); color: var(--text); }
.advanced { margin-top: 16px; }
.advanced summary { cursor: pointer; font-weight: 700; margin-bottom: 8px; }
.status-line { margin: 0 0 8px; }
.page-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.page-head h1 { font-size: 1.35rem; }
.panel {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px; margin-bottom: 16px; min-width: 0;
}
.panel > h2 { font-size: 1.05rem; margin-bottom: 12px; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.panel-head h2 { font-size: 1.05rem; }
.grid-2 { display: grid; grid-template-columns: 1fr; gap: 16px; }
@media (min-width: 1000px) { .grid-2 { grid-template-columns: 1fr 1fr; } }
.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 16px; }
@media (min-width: 800px) { .kpis { grid-template-columns: repeat(4, 1fr); } }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

.table-wrap { overflow-x: auto; margin: 0 -16px; padding: 0 16px; }
table.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th, .table td { padding: 9px 8px; text-align: start; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table th { color: var(--muted); font-weight: 600; font-size: 12.5px; white-space: nowrap; }
.table tr:last-child td { border-bottom: 0; }
.table td.actions { white-space: nowrap; text-align: end; }
.table .num { direction: ltr; text-align: end; white-space: nowrap; }
tr.is-dragging { opacity: .4; }
tr.drop-target td { box-shadow: inset 0 2px 0 var(--accent); }
.drag-handle { cursor: grab; color: var(--muted); touch-action: none; }
.status-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--unknown); margin-inline-end: 6px; }
.status-dot.online { background: var(--ok); }
.status-dot.degraded { background: var(--warn); }
.status-dot.offline { background: var(--bad); }
.pill { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; background: var(--surface-2); color: var(--text-2); }
.pill-ok { background: var(--ok-soft); color: var(--ok); }
.pill-bad { background: var(--bad-soft); color: var(--bad); }
.pill-warn { background: var(--warn-soft); color: var(--warn); }

.form-grid { display: grid; grid-template-columns: 1fr; gap: 14px; }
@media (min-width: 800px) { .form-grid { grid-template-columns: 1fr 1fr; } .form-grid .full { grid-column: 1 / -1; } }
@media (min-width: 800px) { .form-grid.single { grid-template-columns: 1fr; } }
#server-table td { white-space: nowrap; }
#server-table td:nth-child(2) { white-space: normal; min-width: 170px; }
.field label, .field .label { display: block; font-weight: 600; font-size: 13.5px; margin-bottom: 5px; }
.field .help { display: block; color: var(--muted); font-size: 12px; margin-top: 4px; }
.input, .field input[type=text], .field input[type=password], .field input[type=number], .field input[type=url],
.field input[type=time], .field input[type=search], .field select, .field textarea {
  width: 100%; border: 1px solid var(--border); background: var(--surface); border-radius: var(--radius-sm);
  padding: 9px 12px; min-height: 40px; color: var(--text);
}
.field textarea { min-height: 120px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--accent); box-shadow: var(--focus); outline: none; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 14px; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }
.checks { display: grid; gap: 6px; }
.form-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; }

.alert { border-radius: var(--radius-sm); padding: 10px 14px; margin-bottom: 14px; font-size: 14px; border: 1px solid transparent; }
.alert ul { margin: 6px 0 0; padding-inline-start: 20px; }
.alert-success { background: var(--ok-soft); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 30%, transparent); }
.alert-error { background: var(--bad-soft); color: var(--bad); border-color: color-mix(in srgb, var(--bad) 30%, transparent); }
.alert-info { background: var(--accent-soft); color: var(--accent); }
.alert-warn { background: var(--warn-soft); color: var(--warn); }

.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 380px; }
.login-card h1 { font-size: 1.3rem; margin-bottom: 4px; }
.test-result { font-size: 12.5px; margin-inline-start: 6px; }
.toast {
  position: fixed; bottom: 18px; inset-inline-start: 50%; transform: translateX(50%); z-index: 70;
  background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 10px; box-shadow: var(--shadow-lg); font-size: 14px;
}
.log-box {
  background: var(--surface-2); border-radius: 10px; padding: 10px; max-height: 260px; overflow: auto;
  font-size: 12px; white-space: pre-wrap; word-break: break-all;
}
.filter-bar { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 12px; }
.filter-bar .field { min-width: 160px; }
.pagination { display: flex; gap: 6px; justify-content: center; margin-top: 12px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
