/* =====================================================================================
   UNETIK ERP — Shared UI Components (умумий компонентлар)
   Ҳар бир бўлим шу ердаги компонент ва утилиталардан фойдаланади; бўлимга хос нусха ёзилмайди.
   Қийматлар фақат tokens.css токенларидан. Рўйхат ва мисоллар: docs/UI_COMPONENTS.md
   ===================================================================================== */

/* ---------- Утилиталар (inline style="…" ўрнига) ---------- */
.mt-0 { margin-top: 0; }
.mt-1 { margin-top: var(--sp-1); }
.mt-2 { margin-top: var(--sp-2); }
.mt-3 { margin-top: var(--sp-3); }
.mt-4 { margin-top: var(--sp-4); }
.mt-6 { margin-top: var(--sp-6); }
.mb-0 { margin-bottom: 0; }
.mb-2 { margin-bottom: var(--sp-2); }
.mb-3 { margin-bottom: var(--sp-3); }
.mb-4 { margin-bottom: var(--sp-4); }
.m-0 { margin: 0; }
.pt-0 { padding-top: 0; }
.gap-1 { gap: var(--sp-1); }
.gap-2 { gap: var(--sp-2); }
.gap-3 { gap: var(--sp-3); }
.gap-4 { gap: var(--sp-4); }
.justify-end { justify-content: flex-end; }
.justify-between { justify-content: space-between; }
.nowrap { flex-wrap: nowrap; white-space: nowrap; }
.min-w-0 { min-width: 0; }
.w-full { width: 100%; }
.span-all { grid-column: 1 / -1; }
.text-2xs { font-size: var(--fs-2xs); }
.text-xs { font-size: var(--fs-xs); }
.text-sm { font-size: var(--fs-sm); }
.text-left { text-align: left; }
.text-right { text-align: right; }

/* ---------- Universal Data Table: устун турлари ----------
   <th class="col-model">…</th> — кенглик токендан; рақам устунлари ўнгга текисланади.
   .table (рўйхат) ва .xgrid (Excel-таҳрир) иккаласида бир хил ишлайди. */
:is(.table, .xgrid) :is(th, td).col-no { width: var(--col-no); text-align: center; }
:is(.table, .xgrid) :is(th, td).col-model { min-width: var(--col-model); }
:is(.table, .xgrid) :is(th, td).col-text { width: var(--col-text); }
:is(.table, .xgrid) :is(th, td).col-date { width: var(--col-date); white-space: nowrap; }
:is(.table, .xgrid) :is(th, td).col-doc { width: var(--col-doc); white-space: nowrap; font-variant-numeric: tabular-nums; }
:is(.table, .xgrid) :is(th, td).col-status { width: var(--col-status); }
:is(.table, .xgrid) :is(th, td):is(.col-qty, .col-price, .col-sum) { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
:is(.table, .xgrid) :is(th, td).col-qty { width: var(--col-qty); }
:is(.table, .xgrid) :is(th, td).col-price { width: var(--col-price); }
:is(.table, .xgrid) :is(th, td).col-sum { width: var(--col-sum); }
:is(.table, .xgrid) :is(th, td).col-actions { width: var(--col-actions); text-align: right; white-space: nowrap; }

/* ---------- Фильтр ва қидирув панели (ягона) ----------
   <form class="card__body filters"> қидирув · танловлар · саналар · спиннер </form>
   Элементлар сонидан қатъи назар ўзи жойлашади; бўлимга хос модификатор ёзилмайди. */
.filters { display: flex; flex-wrap: wrap; gap: var(--sp-2); align-items: center; border-bottom: 1px solid var(--border); }
.filters > * { flex: 1 1 160px; min-width: 0; max-width: 260px; }
.filters > input[type=search] { flex: 3 1 220px; max-width: none; }
.filters > input[type=date] { flex: 0 1 150px; }
.filters > .spinner { flex: 0 0 20px; }
.filters > .btn { flex: 0 0 auto; }
.filters > input[type=hidden] { display: none; }
.filters > span.dim { flex: 1 1 100%; max-width: none; }
.filters > .segmented { flex: 0 0 auto; max-width: none; }
@media (max-width: 640px) {
  .filters > *, .filters > input[type=date], .filters > .segmented { flex: 1 1 100%; max-width: none; }
  .filters > .spinner { display: none; }
  .filters > .segmented .segmented__item { flex: 1; justify-content: center; padding: 0 var(--sp-2); }
}

/* ---------- Universal Data Table ----------
   Барча рўйхат жадваллари: <div class="table-wrap"><table class="table table--responsive">…</table></div>
   Excel кўриниши: катак чизиқлари, бир хил қатор баландлиги, zebra, рақамлар ўнгда, жами — <tfoot>.
   Устун тури — th'га .col-* класс (юқорида). Телефонда (≤640) .table--responsive карточкага айланади. */
.table :is(th, td).num { text-align: right; }
.table td.c-center, .table th.c-center { text-align: center; }
@media (min-width: 641px) {
  .table { font-size: var(--fs-sm); }
  .table th, .table td {
    height: var(--row-h); padding: var(--sp-1) var(--cell-px);
    border-bottom: 1px solid var(--grid-line); border-right: 1px solid var(--grid-line);
  }
  .table th:last-child, .table td:last-child { border-right: 0; }
  .table thead th { font-size: var(--fs-xs); z-index: 1; }
  .table tbody tr:last-child td { border-bottom: 0; }
  .table tfoot :is(td, th) {
    height: var(--row-h-foot); font-weight: 600; background: var(--surface-2);
    border-top: 1px solid var(--grid-line); border-bottom: 0;
  }
}
@media (max-width: 640px) {
  /* Карточка қатори: ёрлиқ чапда, қиймат (бир нечта элемент бўлса ҳам яхлит) ўнгда */
  .table--responsive td { display: block; text-align: right; overflow-wrap: anywhere; }
  .table--responsive td::before { float: left; margin-right: var(--sp-3); }
  .table--responsive td::after { content: ""; display: table; clear: both; }
  .table--responsive td.actions { display: flex; }
}

/* Қўшимча утилиталар (В5: inline style ўрнига) */
.text-lg { font-size: var(--fs-lg); }
.fw-medium { font-weight: 500; }
.flex-1 { flex: 1; }
.ws-normal { white-space: normal; }
.text-center { text-align: center; }
