/*
 * Monitor — NOC (Network Operations Center) dizayn sistemi.
 * Token mənbəyi: ../assets/design/tokens.css (skin: neutral-pro, tema: dark).
 * Bu fayl sıfırdan yazılmayıb — mövcud sinif adları VƏ mövcud CSS dəyişən
 * adları (--bg-void, --neon-red, --status-up və s.) saxlanılır, çünki
 * `web/js/*.js`, `web/index.html`, `web/admin.html` bu adlara bağlıdır və bu
 * tapşırığın zonasından kənardır (bax .autopilot/.../interfaces.md).
 * Aşağıdakı ilk :root bloku məhz bu adları yeni primitivlərə "tərcümə edir" —
 * əsl rəng/ölçü dəyərləri BURADA deyil, tokens.css-dədir.
 *
 * Rəng intizamı (spesifikasiya, prinsip 1): rəng YALNIZ avadanlıq statusu
 * üçündür. `.btn`, `.panel`, `.input`, `.select`, cədvəl başlığı, `.modal`
 * neytraldır; doymuş rəng yalnız `.badge-*`, `.dot-*`, `.text-*`, `.topo-*`
 * sinif ailələrində görünür. Bax interfaces.md → "Rəng intizamı".
 */

@import url("../assets/design/tokens.css");

:root {
  /* --- Səth qatları (4 səviyyə, hərəsi qonşusundan ölçülə bilən fərqlə) --- */
  --bg-void: var(--bg-subtle);        /* L0 — səhifə fonu, ən tünd */
  --bg-base: var(--bg);               /* L1 — baza konteyner */
  --bg-panel: var(--surface);         /* L2 — panel səthi */
  --bg-panel-raised: var(--surface-2); /* L3 — qalxmış/hover səth */
  --bg-inset: var(--bg-subtle);       /* batıq sahə (input, track) — L0 təkrarı, yeni səviyyə deyil */

  /* --- Sərhədlər (3 tier) --- */
  --line-subtle: var(--surface-2);    /* zəif ayırıcı, səthlə demək olar bir rəngdə */
  --line: var(--border);
  --line-strong: var(--border-strong);

  /* --- Mətn ---
     NİYƏ --text-secondary literal oklch: legacy adı `--text-secondary` təsadüfən
     primitivin öz adı `--text-muted`-a bağlanmalıdır, AMMA bu blokda `--text-muted`
     (legacy) da AYRI bir primitivə (--text-subtle) yenidən təyin olunur. CSS-də
     bir dəyişənin YALNIZ bir kaskad dəyəri olur — `--text-muted`-i eyni bloqda
     həm oxumaq (köhnə mənasında) həm yenidən yazmaq mümkün deyil (var() son
     kaskad dəyərini oxuyur, "əvvəlki" dəyəri yox). Ona görə burada primitivin
     --text-muted (tokens.css) dəyəri bir dəfəlik ədədi köçürülüb — uydurma
     rəng deyil, --text-muted primitivinin öz dəyəridir. */
  --text-primary: var(--text);
  --text-secondary: oklch(0.74 0.012 260); /* = tokens.css --text-muted (bax yuxarı qeyd) */
  --text-muted: var(--text-subtle);
  --text-dim: var(--text-disabled);   /* yalnız disabled/placeholder — 4.5:1 tələb olunmur (WCAG SC 1.4.3 istisnası) */

  /* --- Status rəngləri (yalnız badge/dot/text/topo sinifləri istifadə edir) --- */
  --neon-teal: var(--focus);          /* köhnə "aksent" adı — indi neytral fokus rəngi, marka rəngi DEYİL */
  --neon-teal-dim: var(--line-strong);
  --neon-teal-rgb: 240, 242, 244;     /* --text ilə üst-üstə, yalnız fokus halqası alfa-şəffaflığı üçün */
  --neon-teal-glow: transparent;      /* dizayn qərarı: fokusda halə yoxdur (prinsip 2 — dərinlik səthlə, glow ilə yox) */

  --neon-green: var(--success);
  --neon-green-dim: var(--success-subtle);
  --neon-green-rgb: 97, 195, 128;     /* --success-hex (#61c380) komponentləri — rgba() üçün, xarici fayllarda istifadə olunur */
  --neon-green-glow: rgba(var(--neon-green-rgb), 0.45);

  --neon-red: var(--danger);
  --neon-red-dim: var(--danger-subtle);
  --neon-red-rgb: 242, 113, 104;      /* --danger-hex (#f27168) komponentləri — eyni səbəb */
  --neon-red-glow: rgba(var(--neon-red-rgb), 0.5);

  --neon-amber: var(--warning);

  --grey-status: var(--text-secondary); /* "disabled" — neytral boz, aydın görünür (0.74 — bax yuxarı --text-secondary qeydi) */
  --pale-status: var(--text-subtle);  /* "unknown" — solğun neytral, boz-dan bir pillə açıq */

  --status-up: var(--neon-green);
  --status-up-glow: var(--neon-green-glow);
  --status-down: var(--neon-red);
  --status-down-glow: var(--neon-red-glow);
  --status-upstream: var(--neon-amber);
  --status-disabled: var(--grey-status);
  --status-unknown: var(--pale-status);

  /* --- Tipoqrafiya rolları (spesifikasiya, prinsip 3) ---
     sans (--font-body) = etiket/başlıq/düymə; mono (--font-mono) = YALNIZ
     məlumat (IP, vaxt, müddət, rəqəm). Hər ikisi artıq tokens.css-də eyni
     adla təyin olunub — burada təkrar elan etmirik (özünə-istinad olardı). */

  --fs-xs: var(--size-xs);     /* 0.75rem */
  --fs-sm: var(--size-sm);     /* 0.8125rem */
  --fs-base: var(--size-base); /* 0.875rem — gövdə mətni */
  --fs-md: var(--size-md);     /* 1rem */
  --fs-lg: var(--size-lg);     /* 1.125rem */
  --fs-xl: var(--size-xl);     /* 1.375rem */
  --fs-2xl: var(--size-3xl);   /* 2rem — saat/sayğac (TV rejimi bunu daha da böyüdür) */
  --fs-3xl: var(--size-5xl);   /* 3rem — ən iri display rəqəmi */

  --lh-tight: var(--leading-tight);
  --lh-normal: var(--leading-normal);

  /* --- Aralıq --- */
  --sp-1: var(--space-1);
  --sp-2: var(--space-2);
  --sp-3: var(--space-3);
  --sp-4: var(--space-4);
  --sp-5: var(--space-5);
  --sp-6: var(--space-6);
  --sp-8: var(--space-8);

  /* --- Radius --- */
  /* --radius-sm/md/lg artıq tokens.css-də eyni adla təyin olunub (özünə-
     istinad olmasın deyə burada təkrar elan etmirik) — yalnız fərqli adlı
     alias lazımdır: */
  --radius-round: var(--radius-full);

  /* --- Kölgə (dərinlik səthlə verilir, glow ilə yox — prinsip 2) --- */
  --glow-teal: none;
  --glow-green: none;
  --glow-amber: none;
  --shadow-panel: var(--shadow-lg);

  /* --- Keçid --- */
  --ease: var(--ease-in-out);
  --dur-fast: var(--duration-fast);
  --dur-med: var(--duration-slow);
}

/* ==================== Reset ==================== */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  /* NİYƏ: köhnə versiyada burada teal-tintli qrid arxa fon var idi (dekorativ
     "cyber" motivi). Prinsip 1 və 2-yə görə silinib — dərinlik səth
     qatlarından gəlir, ambient rəng/naxışdan yox. */
  background: var(--bg-void);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: var(--fs-base);
  line-height: var(--lh-normal);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
  font-family: var(--font-body);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-normal);
  margin: 0 0 var(--sp-3);
  color: var(--text-primary);
}

h1 { font-size: var(--fs-2xl); }
h2 { font-size: var(--fs-xl); }
h3 { font-size: var(--fs-lg); }
h4 { font-size: var(--fs-md); }

p { margin: 0 0 var(--sp-3); color: var(--text-secondary); }

a { color: var(--text-primary); }

code, .mono { font-family: var(--font-mono); }

/* NİYƏ: `iconSvg()` (web/js/admin.js) `<svg class="icon ...">` yaradır, inline
   width/height olmadan — ölçü tamamilə CSS-dən gəlməlidir. Dəfolt yox idi,
   sprite `<use>` UA-defolt ölçüdə (yüzlərlə piksel) render olunurdu (bax
   admin.html cədvəl sətirləri). `em` ilə əhatə edən mətnlə miqyaslanır;
   daha spesifik qaydalar (məs. `.admin-nav__link .icon`) və inline
   `style="width:...;height:..."` spesifiklik/inline üstünlüyü ilə qalib gəlir. */
.icon {
  width: 1.5em;
  height: 1.5em;
  flex-shrink: 0;
}

button, input, select, textarea { font-family: inherit; }

/* NİYƏ !important: `[hidden]` atribut selektoru ilə `.banner`/`.empty` kimi
   komponent sinifləri EYNİ spesifiklikdədir (0,0,1,0) — kaskadda importance
   specificity-dən ƏVVƏL müqayisə olunur, ona görə burada !important olmadan
   belə nəzəri olaraq `[hidden]` udmalıdır, AMMA canlı ekranda əksi müşahidə
   olunub (reconnect/network banner-ları və `.empty` `hidden=true` olduğu
   halda `display:flex` qalıb görünür). Kaskad sırasına etibar etmək əvəzinə
   burada MÜTLƏQ, şərtsiz qazanan bir qayda qoyulur — JS-in `element.hidden`
   ilə idarə etdiyi HƏR element (bax web/js/monitor.js və s.) buna görə
   gizlənir, hansı sinifdə olmasından asılı olmayaraq. */
[hidden] { display: none !important; }

::selection {
  background: var(--hover-veil);
  color: var(--text-primary);
}

/* ==================== Layout helpers ==================== */

.container {
  max-width: var(--container-wide);
  margin: 0 auto;
  padding: var(--sp-5);
}

.stack { display: flex; flex-direction: column; gap: var(--sp-4); }
.row { display: flex; align-items: center; gap: var(--sp-3); }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); }
.grow { flex: 1 1 auto; }

/* ==================== Panel — neytral ==================== */

.panel {
  background: var(--bg-panel);
  border: var(--space-px) solid var(--line);
  border-radius: var(--radius-lg);
  padding: var(--sp-5);
  box-shadow: var(--shadow-panel);
}

.panel-raised {
  background: var(--bg-panel-raised);
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  margin-bottom: var(--sp-4);
  padding-bottom: var(--sp-3);
  border-bottom: var(--space-px) solid var(--line-subtle);
}

/* ==================== Buttons — neytral (rəng yalnız status siniflərində) ====================
   İyerarxiya rəngdən yox, dolgu çəkisindən gəlir: primary = çevrilmiş neytral
   dolgu (açıq fon/tünd mətn), secondary = konturlu neytral, ghost = şəffaf,
   danger = eyni neytral dolgu + güclü sərhəd (mətn "Sil" sözü ilə fərqlənir). */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  font-family: var(--font-body);
  font-size: var(--fs-sm);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-normal);
  padding: var(--sp-2) var(--sp-4);
  border-radius: var(--radius-md);
  border: var(--space-px) solid var(--line);
  background: var(--bg-panel-raised);
  color: var(--text-primary);
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease),
    border-color var(--dur-fast) var(--ease),
    transform var(--dur-fast) var(--ease);
}

.btn:hover {
  background: var(--hover-veil);
  border-color: var(--line-strong);
}

.btn:active { transform: translateY(var(--space-px)); }

.btn:focus-visible {
  outline: var(--space-0-5) solid var(--neon-teal);
  outline-offset: var(--space-0-5);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--text-primary);
  color: var(--bg-void);
  border-color: var(--text-primary);
}

.btn-primary:hover {
  background: var(--text-secondary);
  border-color: var(--text-secondary);
}

.btn-danger {
  border-color: var(--line-strong);
  background: var(--bg-panel-raised);
  color: var(--text-primary);
}

.btn-danger:hover {
  background: var(--hover-veil);
  border-color: var(--text-secondary);
}

.btn-ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--text-secondary);
}

.btn-ghost:hover {
  border-color: var(--line-strong);
  background: var(--hover-veil);
  color: var(--text-primary);
}

.btn-sm { padding: var(--sp-1) var(--sp-3); font-size: var(--fs-xs); }
.btn-icon { padding: var(--sp-2); }

/* ==================== Forms — neytral ==================== */

.field { display: flex; flex-direction: column; gap: var(--sp-1); }

.label {
  font-family: var(--font-body);
  font-size: var(--fs-xs);
  font-weight: var(--weight-medium);
  color: var(--text-secondary);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
}

.input,
.select {
  background: var(--bg-inset);
  border: var(--space-px) solid var(--line);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  padding: var(--sp-2) var(--sp-3);
  font-size: var(--fs-sm);
  transition: border-color var(--dur-fast) var(--ease);
}

.input::placeholder { color: var(--text-dim); }

.input:focus,
.select:focus {
  outline: none;
  border-color: var(--line-strong);
  box-shadow: 0 0 0 var(--space-1) var(--hover-veil);
}

.input.is-invalid {
  border-color: var(--line-strong);
}

.field-error {
  font-size: var(--fs-xs);
  color: var(--neon-red);
}

.select {
  /* NİYƏ: 11px/5px — əl ilə çəkilmiş oxcuq üçbucağının həndəsi ofset/ölçüsü,
     aralıq şkalasında qarşılığı yoxdur (dizayn tokeni deyil, sırf CSS-forma
     riyaziyyatıdır) — bilərəkdən literal saxlanılıb. */
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-secondary) 50%),
    linear-gradient(135deg, var(--text-secondary) 50%, transparent 50%);
  background-position: calc(100% - var(--space-4)) 55%, calc(100% - 11px) 55%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: var(--sp-6);
}

/* ==================== Badge — status rəngi icazəlidir ==================== */

.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  padding: var(--space-0-5) var(--sp-2);
  border-radius: var(--radius-round);
  border: var(--space-px) solid currentColor;
  line-height: 1.6;
}

.badge::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  flex: none;
}

.badge-up { color: var(--status-up); background: var(--success-subtle); }
.badge-down {
  color: var(--status-down);
  background: var(--danger-subtle);
  animation: badge-pulse 1.1s ease-in-out infinite;
}
.badge-upstream { color: var(--status-upstream); background: var(--warning-subtle); }
.badge-disabled { color: var(--status-disabled); background: var(--bg-inset); }
.badge-unknown { color: var(--status-unknown); background: var(--bg-inset); }

@keyframes badge-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}

/* ==================== Banner ==================== */

.banner {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--radius-md);
  border: var(--space-px) solid var(--line);
  background: var(--bg-panel-raised);
  font-family: var(--font-body);
  font-size: var(--fs-sm);
}

.banner-danger {
  border-color: var(--neon-red-dim);
  background: var(--danger-subtle);
  color: var(--neon-red);
  animation: banner-flicker 1.6s ease-in-out infinite;
}

.banner-warn {
  border-color: var(--warning-subtle);
  background: var(--warning-subtle);
  color: var(--neon-amber);
}

.banner-ok {
  border-color: var(--neon-green-dim);
  background: var(--success-subtle);
  color: var(--neon-green);
}

@keyframes banner-flicker {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.72; }
}

/* ==================== Empty state — neytral ==================== */

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--sp-3);
  padding: var(--sp-8) var(--sp-5);
  text-align: center;
  color: var(--text-muted);
  border: var(--space-px) dashed var(--line);
  border-radius: var(--radius-lg);
}

.empty-icon {
  width: var(--space-12);
  height: var(--space-12);
  color: var(--text-muted);
}

.empty-title {
  font-family: var(--font-body);
  font-weight: var(--weight-semibold);
  font-size: var(--fs-md);
  color: var(--text-secondary);
}

/* ==================== Table — başlıq neytral ==================== */

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-sm);
}

.table th,
.table td {
  text-align: left;
  padding: var(--sp-2) var(--sp-3);
  border-bottom: var(--space-px) solid var(--line-subtle);
}

.table th {
  font-family: var(--font-body);
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
  color: var(--text-muted);
  font-weight: var(--weight-semibold);
}

.table tbody tr:hover {
  background: var(--hover-veil);
}

/* ==================== Modal — neytral ==================== */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: var(--overlay);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: var(--z-modal-backdrop);
  /* NİYƏ: backdrop-a onclick QƏSDƏN yoxdur — modal YALNIZ düymələrlə bağlanır
     (layihə qaydası). Klik burada heç nə etmir. */
}

.modal {
  /* 480px — komponent enidir, konteyner şkalasında (--container-*) qarşılığı
     yoxdur (ən yaxını --container-narrow=672px, modal üçün çox geniş olardı) —
     bilərəkdən literal saxlanılıb. */
  width: min(480px, 92vw);
  background: var(--bg-panel);
  border: var(--space-px) solid var(--line-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-panel);
  padding: var(--sp-5);
}

.modal-title {
  font-family: var(--font-body);
  font-weight: var(--weight-semibold);
  font-size: var(--fs-lg);
  margin-bottom: var(--sp-2);
}

.modal-body {
  color: var(--text-secondary);
  margin-bottom: var(--sp-5);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--sp-2);
}

/* ==================== Status utility rəngləri — icazəlidir ==================== */

.text-up { color: var(--status-up); }
.text-down { color: var(--status-down); }
.text-upstream { color: var(--status-upstream); }
.text-disabled { color: var(--status-disabled); }
.text-unknown { color: var(--status-unknown); }

.dot {
  /* 10px/14px/7px (aşağıda .badge::before, .screen-tv .dot) — status
     nişanının qlif ölçüsüdür, aralıq şkalası deyil, bir toxunuşluq göz
     ölçüsü tənzimləməsidir — literal saxlanılıb. */
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: currentColor;
}

.dot-up { color: var(--status-up); }
.dot-down {
  color: var(--status-down);
  animation: dot-pulse 1.1s ease-in-out infinite;
}
.dot-upstream { color: var(--status-upstream); }
.dot-disabled { color: var(--status-disabled); }
.dot-unknown { color: var(--status-unknown); }

@keyframes dot-pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.35); opacity: 0.6; }
}

/* ==================== Toast ==================== */

.toast-host {
  position: fixed;
  right: var(--sp-5);
  bottom: var(--sp-5);
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  z-index: var(--z-toast);
}

.toast {
  font-family: var(--font-body);
  font-size: var(--fs-sm);
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--radius-md);
  border: var(--space-px) solid var(--line);
  background: var(--bg-panel-raised);
  color: var(--text-primary);
  box-shadow: var(--shadow-panel);
  animation: toast-in var(--dur-med) var(--ease);
}

.toast-error {
  border-color: var(--neon-red-dim);
  color: var(--neon-red);
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(var(--space-2)); }
  to { opacity: 1; transform: translateY(0); }
}

/* ==================== TV / uzaqdan baxış rejimi ==================== */

.screen-tv {
  font-size: 1.35em;
}

.screen-tv h1 { font-size: calc(var(--fs-3xl) * 1.1); }
.screen-tv h2 { font-size: calc(var(--fs-2xl) * 1.05); }
.screen-tv .badge,
.screen-tv .banner {
  font-size: var(--fs-md);
}

.screen-tv .dot { width: 14px; height: 14px; }

/* ==================== Hərəkət tərcihi ==================== */

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}
