/* PTO-UZ — Nocturne komponent qatlami (web, admin, landing uchun umumiy).
   Bu fayl QO'LDA yoziladi; ranglar/o'lchamlar faqat tokens.css dagi o'zgaruvchilardan olinadi
   (design/tokens.json -> Build-Tokens.ps1). Nusxalari wwwroot/css/components.css ga ko'chiriladi.

   Manba: handoff'dagi Nocturne dizayn tizimi (_ds papkasidagi styles.css) + handoff/README.md.
   DIQQAT: izoh ichida yulduzcha-slash ketma-ketligini yozmang — u izohni erta yopadi va
   keyingi qoidani (box-sizing reset) parser yutib yuboradi. */

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

body {
  margin: 0;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: var(--fs-body);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  font-weight: var(--font-heading-weight);
  line-height: 1.12;
  letter-spacing: -0.015em;
  margin: 0;
}
p { margin: 0; }
img { display: block; max-width: 100%; }

a { color: var(--color-accent); text-underline-offset: 3px; }
a:hover { color: var(--t-accent-body); }

:focus { outline: none; }
:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 2px; }
::selection { background: var(--tint-accent-30); }

.mono { font-family: var(--font-mono); }
.text-muted { color: var(--t-muted); }
.text-faint { color: var(--t-faint); }

/* Uppercase micro-label — 11px, .08em. Nocturne'ning h6 i bilan bir xil. */
.lbl {
  font-size: var(--fs-label);
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--t-faint);
}

/* Hairline: ikki chekkasida shaffofga so'nadi (48px bir chekka) — Nocturne imzosi.
   Erkin turgan chiziqlar so'nadi; quti chegaralari va qisqa aksent belgilari qat'iy qoladi. */
.hr {
  height: 1px; border: 0; margin: 0;
  background: linear-gradient(to right,
    transparent, var(--color-divider) 48px,
    var(--color-divider) calc(100% - 48px), transparent);
}

/* Registratsiya belgilari: bosma varaqdagi trim mark kabi chegara ustida o'tiradi.
   Eski chizma tilidan ataylab saqlangan. */
.marks { display: contents; }
.mark {
  position: absolute;
  font-size: 12px; line-height: 1;
  color: var(--color-accent);
  pointer-events: none;
}
.mark.tl { left: -4px; top: -8px; }
.mark.tr { right: -4px; top: -8px; }
.mark.bl { left: -4px; bottom: -8px; }
.mark.br { right: -4px; bottom: -8px; }

/* ------------------------------------------------------------------ shell --
   Chap sidebar + kontent. Navigatsiya BITTA joyda turadi: bo'limlar sidebar'da,
   filtrlar esa o'z kontentida qoladi (filtr — navigatsiya emas). */

.shell { display: grid; grid-template-columns: 224px minmax(0, 1fr); min-height: 100vh; }

.side {
  display: flex; flex-direction: column; gap: var(--space-6);
  padding: 16px 12px;
  background: var(--color-surface);
  /* uzun jadvalda navigatsiya skroll bilan yo'qolib ketmasligi kerak.
     overflow-x ni ochiq qoldirib bo'lmaydi: biri auto bo'lsa, ikkinchisi ham auto ga
     aylanadi va pastda keraksiz gorizontal skroll paydo bo'ladi. */
  /* max-height emas, height: kontent kalta bo'lganda ham ustun to'liq bo'yaladi */
  position: sticky; top: 0; align-self: start;
  height: 100vh; overflow-y: auto; overflow-x: hidden;
}
.side-brand { display: flex; align-items: center; gap: 10px; padding: 2px 8px 0; min-width: 0; }
.side-brand .mk {
  width: 32px; height: 32px; flex: none;
  border: 1px solid var(--color-accent); border-radius: var(--radius-sm);
  display: grid; place-items: center; overflow: hidden;
}
.side-brand b { font-family: var(--font-heading); font-weight: var(--font-heading-weight); font-size: 15px; }
.side-brand span { display: block; font-size: 11px; color: var(--t-faint); }

.side-nav { display: flex; flex-direction: column; gap: 2px; }
.side-sep { margin: 6px 8px; }

.side-link {
  display: flex; align-items: center; gap: 9px;
  width: 100%; padding: 8px 10px;
  border: 0; border-radius: var(--radius-md);
  background: transparent; color: var(--t-body);
  font-family: var(--font-body); font-size: 13.5px; text-align: left; text-decoration: none;
  cursor: pointer;
}
.side-link:hover { background: var(--tint-text-7); color: var(--color-text); }
/* faol bo'lim: chap chekkada aksent rels + yengil tint */
.side-link.on { background: var(--tint-accent-12); color: var(--color-accent); box-shadow: inset 2px 0 0 var(--color-accent); }
.side-link svg { width: 16px; height: 16px; flex: none; }
.side-link .lbl-txt { flex: 1; min-width: 0; }
.side-link .ext { flex: none; opacity: .55; }

.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 8px; padding: 0 8px; }

.topbar { display: flex; align-items: center; gap: 12px; padding: 13px 22px; }
.topbar .title { flex: 1; min-width: 0; font-family: var(--font-heading); font-weight: var(--font-heading-weight); font-size: var(--fs-h5); }

@media (max-width: 860px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .side { flex-direction: row; align-items: center; gap: 10px; padding: 10px 12px;
          overflow-x: auto; overflow-y: hidden; height: auto; position: static; }
  .side-brand { padding: 0; flex: none; margin-right: 4px; }
  .side-brand .txt { display: none; }
  .side-nav { flex-direction: row; gap: 4px; }
  .side-link { width: auto; white-space: nowrap; padding: 7px 10px; }
  .side-link.on { box-shadow: inset 0 -2px 0 var(--color-accent); }
  .side-sep, .side-foot { display: none; }
}

/* ---------------------------------------------------------------- buttons -- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  cursor: pointer; text-decoration: none; white-space: nowrap;
  font-family: var(--font-heading);
  font-weight: var(--font-heading-weight);
  font-size: 14px; line-height: 1.2;
  color: var(--color-text);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  padding: var(--space-2) calc(var(--space-3) * 1.2);
}
.btn:disabled { opacity: .45; cursor: not-allowed; }

/* Nocturne qoidasi: asosiy amal — aksent KONTUR, to'ldirilgan emas. */
.btn-primary { color: var(--color-accent); border-color: var(--color-accent); }
.btn-primary:not(:disabled):hover { background: var(--tint-accent-12); }
.btn-primary:not(:disabled):active { background: var(--tint-accent-22); }

.btn-secondary { border-color: var(--color-divider); }
.btn-secondary:not(:disabled):hover { background: var(--tint-text-7); }
.btn-secondary:not(:disabled):active { background: var(--tint-text-14); }

.btn-ghost { color: var(--color-accent); padding-inline: var(--space-1); }
.btn-ghost:not(:disabled):hover { background: var(--tint-accent-10); }
.btn-ghost:not(:disabled):active { background: var(--tint-accent-18); }

.btn-icon { width: 36px; height: 36px; padding: 0; }
.btn-block { width: 100%; }

/* ------------------------------------------------------------------ cards -- */

.card {
  display: flex; flex-direction: column; gap: var(--space-4);
  padding: 18px;
  border-radius: var(--radius-lg);
  background: var(--color-surface);
}
.elev-sm { box-shadow: var(--shadow-sm); }
.elev-md { box-shadow: var(--shadow-md); }
.elev-lg { box-shadow: var(--shadow-lg); }

/* ------------------------------------------------------------------ forms -- */

.field > label { display: block; font-size: 12px; margin-bottom: 5px; color: var(--t-muted); }

.input {
  width: 100%; min-height: 36px; padding: 6px 10px;
  font: inherit; font-size: 14px;
  color: var(--color-text); caret-color: var(--color-accent);
  background: var(--color-surface);
  border: 1px solid var(--color-divider);
  border-radius: var(--radius-md);
}
.input:hover { border-color: var(--tint-text-45); }
.input:focus-visible { border-color: var(--color-accent); outline-offset: 0; }
textarea.input { min-height: 90px; resize: vertical; }

/* Inline maydon xatosi: chegara aksentga o'tadi + ostida 11px matn.
   Jim qolgan validatsiya o'rniga (spetsifikatsiya §12 #10). */
.input.bad { border-color: var(--color-accent); }
.err-msg { font-size: var(--fs-label); color: var(--t-accent-body); margin-top: 4px; }

/* Checkbox: 15x15 kvadrat, radius 3. Yorliq to'liq matn rangida — bu opsiyalar
   formaning o'zi, izohi emas. */
.check { display: flex; align-items: flex-start; gap: 9px; cursor: pointer; user-select: none; }
.check input { position: absolute; opacity: 0; width: 0; height: 0; pointer-events: none; }
.check .box {
  flex: none; width: 15px; height: 15px; margin-top: 2px;
  border: 1px solid var(--t-dim); border-radius: 3px;
  background: transparent;
  display: grid; place-items: center;
}
.check .box::after {
  content: ""; width: 8px; height: 4px;
  border-left: 2px solid var(--t-chip-fg); border-bottom: 2px solid var(--t-chip-fg);
  transform: rotate(-45deg) translate(1px, -1px);
  opacity: 0;
}
.check:hover .box { border-color: var(--color-accent); }
.check input:checked + .box { background: var(--color-accent); border-color: var(--color-accent); }
.check input:checked + .box::after { opacity: 1; }
.check input:focus-visible + .box { outline: 2px solid var(--color-accent); outline-offset: 2px; }
.check input:disabled ~ * { opacity: .45; }
.check .txt { font-size: 13px; }

/* ------------------------------------------------------------------- tags -- */

.tag {
  display: inline-flex; align-items: center;
  font-size: 11px; letter-spacing: .02em; padding: 3px 10px;
  border-radius: calc(var(--radius-md) * .75);
  white-space: nowrap;
}
.tag-accent { background: var(--t-chip-bg); color: var(--t-chip-fg); }
.tag-neutral { background: var(--tint-text-8); color: var(--t-muted); }
.tag-outline { border: 1px solid var(--color-accent); color: var(--color-accent); }

/* ------------------------------------------------------------- 19px marks -- */

/* Natija ✓ va ogohlantirish ! kvadratchalari — kartalar ichida bir xil o'lchamda. */
.sq {
  flex: none; width: 19px; height: 19px;
  display: grid; place-items: center;
  border-radius: var(--radius-sm);
  font-size: 12px; font-weight: 600; line-height: 1;
}
.sq-ok { background: var(--color-accent); color: var(--color-bg); }
.sq-warn { background: var(--t-mark-bg); color: var(--color-neutral-100); }

/* --------------------------------------------------------------- progress -- */

.bar { flex: 1; height: 6px; border-radius: 3px; background: var(--t-track); overflow: hidden; }
.bar > i { display: block; width: 40%; height: 100%; background: var(--color-accent); border-radius: 3px; }
.bar.indet > i { animation: barSlide 1.1s ease-in-out infinite; }
@keyframes barSlide { from { margin-left: -40%; } to { margin-left: 100%; } }

/* ---------------------------------------------------------------- toasts --
   O'tkinchi tasdiq: o'ng-past, 3500 ms, maks 3 ta, hover'da pauza, ✕ bilan. */

.toast-host {
  position: fixed; right: 16px; bottom: 16px; z-index: 60;
  display: flex; flex-direction: column; align-items: flex-end; gap: 8px;
  pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: 9px;
  max-width: 330px; padding: 9px 12px;
  border-radius: var(--radius-md);
  background: var(--color-surface);
  box-shadow: var(--shadow-md);
  animation: toastIn .18s ease-out;
  pointer-events: auto;
}
.toast .sq { width: 16px; height: 16px; border-radius: 4px; font-size: 10px; }
.toast .txt { flex: 1; font-size: 13px; }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* --------------------------------------------------------------- dialog --- */

.dialog-backdrop {
  position: fixed; inset: 0; z-index: 70;
  display: grid; place-items: center; padding: var(--space-4);
  background: var(--tint-text-50);
}
.dialog {
  width: min(440px, 100%);
  display: flex; flex-direction: column; gap: var(--space-3);
  padding: var(--space-4);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
  box-shadow: var(--shadow-lg);
}
.dialog-title { font-family: var(--font-heading); font-weight: var(--font-heading-weight); font-size: var(--fs-h4); }
.dialog-body { font-size: 14px; color: var(--t-body); }
.dialog-actions { display: flex; justify-content: flex-end; gap: var(--space-2); margin-top: var(--space-2); }

/* ---------------------------------------------------------------- tables -- */

.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th {
  text-align: left; padding: var(--space-2);
  font-size: 11px; letter-spacing: .08em; text-transform: uppercase;
  color: var(--t-muted); white-space: nowrap;
  border-bottom: 1px solid transparent;
}
.table td { padding: var(--space-2); border-bottom: 1px solid transparent; vertical-align: top; }
/* Qator chiziqlari qator darajasida — shunda so'nish butun qatorni qamraydi, katakni emas. */
.table thead tr {
  background: linear-gradient(to right, transparent, var(--color-divider) 48px,
    var(--color-divider) calc(100% - 48px), transparent) no-repeat bottom / 100% 1px;
}
.table tbody tr {
  background: linear-gradient(to right, transparent, var(--tint-text-8) 48px,
    var(--tint-text-8) calc(100% - 48px), transparent) no-repeat bottom / 100% 1px;
}
.table tbody tr:hover {
  background:
    linear-gradient(var(--tint-text-4), var(--tint-text-4)) no-repeat 0 0 / 100% 100%,
    linear-gradient(to right, transparent, var(--tint-text-8) 48px,
      var(--tint-text-8) calc(100% - 48px), transparent) no-repeat bottom / 100% 1px;
}

@media (prefers-reduced-motion: reduce) {
  .toast, .bar.indet > i { animation: none; }
}
