/* ============================================================================
   components.css — qayta ishlatiladigan UI bo'laklari (barcha vositalar shu
   sinflardan foydalanadi, shu sababli ko'rinish bir xil bo'ladi)

   Tez qo'llanma:
     <div class="card">            — asosiy oq panel
     <button class="btn btn-primary">
     <div class="grid grid-2">
     <div class="stat"><b class="stat-value">..</b><span class="stat-label">..</span></div>
     <div class="toasts"> — toast konteyneri (avtomatik yaratiladi)
   ============================================================================ */

/* ---------- Kartochka / panel ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--sp-5);
  box-shadow: var(--shadow-sm);
}
.card + .card { margin-top: 0; }
.card-head {
  display: flex; align-items: center; gap: var(--sp-3);
  flex-wrap: wrap;                 /* tor ekranda tugmalar keyingi qatorga tushadi */
  margin-bottom: var(--sp-4);
  padding-bottom: var(--sp-3);
  border-bottom: 1px solid var(--border);
}
.card-head h3 { font-size: 1rem; min-width: 0; overflow-wrap: anywhere; }
.card-head .btn { flex: 0 0 auto; }
.card-head .ico { color: var(--primary); font-size: 18px; }
.card-foot {
  margin-top: var(--sp-4); padding-top: var(--sp-4);
  border-top: 1px solid var(--border);
  display: flex; gap: var(--sp-3); flex-wrap: wrap; align-items: center;
}
.subcard {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: var(--sp-4);
}

/* ---------- Tugmalar ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: .88rem; font-weight: 600;
  cursor: pointer; white-space: nowrap;
  transition: background var(--t-fast), border-color var(--t-fast), transform var(--t-fast), box-shadow var(--t-fast), color var(--t-fast);
}
.btn:hover { border-color: var(--border-2); background: var(--surface-3); }
.btn:active { transform: scale(.975); }
.btn:disabled, .btn[disabled] { opacity: .5; cursor: not-allowed; transform: none; }
.btn .ico { font-size: 16px; }

.btn-primary { background: var(--grad); border-color: transparent; color: #fff; box-shadow: 0 5px 16px rgba(99, 102, 241, .32); }
.btn-primary:hover { background: var(--grad); filter: brightness(1.08); border-color: transparent; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-outline { background: transparent; }
.btn-outline:hover { background: var(--grad-soft); border-color: var(--primary); }
.btn-danger { color: var(--err); border-color: rgba(239, 68, 68, .35); background: rgba(239, 68, 68, .08); }
.btn-danger:hover { background: rgba(239, 68, 68, .16); border-color: var(--err); }
.btn-ok { color: var(--ok); border-color: rgba(22, 163, 74, .35); background: rgba(22, 163, 74, .08); }
.btn-sm { padding: 6px 11px; font-size: .8rem; border-radius: 8px; }
.btn-lg { padding: 13px 24px; font-size: 1rem; }
.btn-block { width: 100%; }
.btn-icon { padding: 9px; width: 38px; height: 38px; }
.btn-icon.btn-sm { width: 30px; height: 30px; padding: 0; }

.btn-group { display: inline-flex; gap: 0; }
.btn-group .btn { border-radius: 0; margin-left: -1px; }
.btn-group .btn:first-child { border-radius: var(--radius-sm) 0 0 var(--radius-sm); margin-left: 0; }
.btn-group .btn:last-child { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.btn-group .btn.is-active { background: var(--grad); color: #fff; border-color: transparent; z-index: 1; }

/* ---------- Maydonlar / tarmoq ---------- */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field-hint { font-size: .76rem; color: var(--muted); }
.field-error { font-size: .78rem; color: var(--err); }
.field-row { display: flex; gap: var(--sp-2); align-items: center; }
.field-row > .input, .field-row > .select { flex: 1 1 auto; }
.input-group { display: flex; }
.input-group .input { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.input-group .input + .input, .input-group .select { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; border-left: 0; }

.grid { display: grid; gap: var(--sp-4); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); }
.grid-tight { gap: var(--sp-2); }
.stack { display: flex; flex-direction: column; gap: var(--sp-4); }
.stack-sm { display: flex; flex-direction: column; gap: var(--sp-2); }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); flex-wrap: wrap; }

/* ---------- Natija / statistika ko'rsatkichlari ---------- */
.result {
  background: var(--grad-soft);
  border: 1px solid var(--border-2);
  border-radius: var(--radius);
  padding: var(--sp-4) var(--sp-5);
  display: flex; flex-direction: column; gap: 4px;
}
.result-label { font-size: .76rem; color: var(--text-2); text-transform: uppercase; letter-spacing: .06em; font-weight: 700; }
.result-value {
  font-size: clamp(1.5rem, 4vw, 2.1rem);
  font-weight: 750; letter-spacing: -.02em; line-height: 1.15;
  word-break: break-word;
  font-variant-numeric: tabular-nums;
}
.result-sub { font-size: .84rem; color: var(--text-2); }
.result-value.is-error { color: var(--err); font-size: 1.05rem; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: var(--sp-3); }
.stat {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: var(--sp-3) var(--sp-4);
  display: flex; flex-direction: column; gap: 2px;
}
.stat-value { font-size: 1.22rem; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.stat-label { font-size: .75rem; color: var(--muted); }
.stat.is-ok .stat-value { color: var(--ok); }
.stat.is-warn .stat-value { color: var(--warn); }
.stat.is-err .stat-value { color: var(--err); }

/* Kalit-qiymat ro'yxati */
.kv { display: flex; flex-direction: column; }
.kv > div { display: flex; justify-content: space-between; gap: var(--sp-4); padding: 9px 0; border-bottom: 1px dashed var(--border); font-size: .88rem; }
.kv > div:last-child { border-bottom: 0; }
.kv dt, .kv .k { color: var(--muted); }
.kv dd, .kv .v { font-weight: 650; font-variant-numeric: tabular-nums; text-align: right; }

/* ---------- Ro'yxatlar ---------- */
.list { display: flex; flex-direction: column; gap: 6px; }
.list-row {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: 10px var(--sp-3);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: border-color var(--t-fast), background var(--t-fast);
}
.list-row:hover { border-color: var(--border-2); }
.list-row.is-done { opacity: .55; }
.list-row.is-done .list-main { text-decoration: line-through; }
.list-main { flex: 1 1 auto; min-width: 0; }
.list-sub { font-size: .76rem; color: var(--muted); }
.list-actions { display: flex; gap: 4px; flex: 0 0 auto; }

.empty {
  text-align: center; color: var(--muted); padding: var(--sp-7) var(--sp-4);
  border: 1px dashed var(--border-2); border-radius: var(--radius);
  font-size: .88rem;
}
.empty .ico { font-size: 32px; margin: 0 auto var(--sp-2); color: var(--border-2); }

/* ---------- Yorliqlar (chip / badge / kbd) ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 11px;
  border-radius: var(--radius-full);
  background: var(--surface-2); border: 1px solid var(--border);
  font-size: .78rem; font-weight: 600; color: var(--text-2);
  cursor: pointer; transition: all var(--t-fast);
}
.chip:hover { border-color: var(--border-2); color: var(--text); }
.chip.is-active { background: var(--grad); border-color: transparent; color: #fff; }
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 9px; border-radius: var(--radius-full);
  font-size: .7rem; font-weight: 700; letter-spacing: .02em;
  background: var(--surface-3); color: var(--text-2);
  border: 1px solid var(--border);
}
.badge.is-ok { background: rgba(22, 163, 74, .14); color: var(--ok); border-color: rgba(22, 163, 74, .3); }
.badge.is-warn { background: rgba(245, 158, 11, .14); color: var(--warn); border-color: rgba(245, 158, 11, .3); }
.badge.is-err { background: rgba(239, 68, 68, .14); color: var(--err); border-color: rgba(239, 68, 68, .3); }
.badge.is-info { background: rgba(59, 130, 246, .14); color: var(--info); border-color: rgba(59, 130, 246, .3); }
kbd {
  font-size: .74rem; padding: 1px 6px; border-radius: 5px;
  background: var(--surface-3); border: 1px solid var(--border-2); color: var(--text-2);
}

/* ---------- Tablar / segment tugmalari ---------- */
.tabs {
  display: flex; gap: 2px; flex-wrap: wrap;
  border-bottom: 1px solid var(--border);
  margin-bottom: var(--sp-4);
}
.tab {
  padding: 9px 14px; font-size: .86rem; font-weight: 600; color: var(--muted);
  border-bottom: 2px solid transparent; margin-bottom: -1px;
  transition: color var(--t-fast), border-color var(--t-fast);
  display: inline-flex; align-items: center; gap: 7px;
}
.tab:hover { color: var(--text); }
.tab.is-active { color: var(--text); border-bottom-color: var(--primary); }
.tab .ico { font-size: 15px; }
.tab-panel { display: none; }
.tab-panel.is-active { display: block; animation: fadeIn .2s both; }

.segmented {
  display: flex; gap: 3px; padding: 3px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-full); width: fit-content; max-width: 100%; overflow-x: auto;
}
.segmented button {
  padding: 6px 13px; border-radius: var(--radius-full);
  font-size: .82rem; font-weight: 600; color: var(--muted); white-space: nowrap;
  transition: all var(--t-fast);
}
.segmented button:hover { color: var(--text); }
.segmented button.is-active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

/* ---------- Jadval ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.table { font-size: .86rem; min-width: 420px; }
.table th, .table td { padding: 10px var(--sp-3); text-align: left; border-bottom: 1px solid var(--border); }
.table th { background: var(--surface-2); font-size: .76rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 700; position: sticky; top: 0; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--surface-2); }
.table td.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- Almashtirish (switch) va slayder ---------- */
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: .87rem; font-weight: 500; color: var(--text); }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .track {
  width: 42px; height: 24px; border-radius: 99px; background: var(--surface-3);
  border: 1px solid var(--border-2); position: relative; flex: 0 0 auto; transition: background var(--t);
}
.switch .track::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px;
  border-radius: 50%; background: var(--muted); transition: transform var(--t), background var(--t);
}
.switch input:checked + .track { background: var(--grad); border-color: transparent; }
.switch input:checked + .track::after { transform: translateX(18px); background: #fff; }
.switch input:focus-visible + .track { outline: 2px solid var(--primary); outline-offset: 2px; }

.slider-row { display: flex; align-items: center; gap: var(--sp-3); }
.slider-row .input[type="range"] { flex: 1 1 auto; }
.slider-val { font-variant-numeric: tabular-nums; font-weight: 700; min-width: 52px; text-align: right; }

/* ---------- Progress / kuch ko'rsatkichi ---------- */
.progress { height: 9px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.progress-bar { height: 100%; width: 0; background: var(--grad); border-radius: 99px; transition: width .3s ease, background .3s ease; }
.progress-bar.is-ok { background: linear-gradient(90deg, #16a34a, #22c55e); }
.progress-bar.is-warn { background: linear-gradient(90deg, #f59e0b, #fbbf24); }
.progress-bar.is-err { background: linear-gradient(90deg, #dc2626, #ef4444); }

/* ---------- Eslatma bloki (callout) ---------- */
.callout {
  display: flex; gap: 10px; align-items: flex-start;
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--info);
  font-size: .85rem; color: var(--text-2);
}
.callout .ico { color: var(--info); font-size: 17px; margin-top: 1px; }
.callout.is-warn { border-left-color: var(--warn); }
.callout.is-warn .ico { color: var(--warn); }
.callout.is-err { border-left-color: var(--err); }
.callout.is-err .ico { color: var(--err); }
.callout.is-ok { border-left-color: var(--ok); }
.callout.is-ok .ico { color: var(--ok); }

/* ---------- Kod / matn natijasi ---------- */
.code-out {
  position: relative;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: var(--sp-3) var(--sp-4);
  font-family: var(--font-mono);
  font-size: .84rem;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 380px;
  overflow: auto;
  line-height: 1.55;
}
.code-out.has-copy { padding-right: 48px; }
.code-out .copy-float { position: absolute; top: 8px; right: 8px; }

/* ---------- Toast (bildirishnoma) ---------- */
.toasts {
  position: fixed; right: 18px; bottom: 18px; z-index: 200;
  display: flex; flex-direction: column; gap: 8px; align-items: flex-end;
  pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: 9px;
  padding: 11px 15px;
  min-width: 200px; max-width: min(380px, 92vw);
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border-2);
  border-left: 3px solid var(--primary);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  font-size: .86rem; font-weight: 550;
  animation: pop .22s both;
  pointer-events: auto;
}
.toast.is-ok { border-left-color: var(--ok); }
.toast.is-ok .ico { color: var(--ok); }
.toast.is-err { border-left-color: var(--err); }
.toast.is-err .ico { color: var(--err); }
.toast.is-warn { border-left-color: var(--warn); }
.toast.is-warn .ico { color: var(--warn); }
.toast .ico { font-size: 17px; color: var(--primary); }
.toast.is-out { animation: fadeIn .2s reverse both; }

/* ---------- Yuklanish (spinner) ---------- */
.spinner {
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid var(--border-2); border-top-color: var(--primary);
  animation: spin .7s linear infinite; display: inline-block;
}

/* ---------- QR / rasm natijasi ---------- */
.qr-box {
  display: inline-flex; flex-direction: column; gap: var(--sp-3); align-items: center;
  padding: var(--sp-4); background: #fff; border-radius: var(--radius);
  border: 1px solid var(--border);
}
.qr-box canvas, .qr-box img, .qr-box svg { max-width: 100%; height: auto; }

/* ---------- Rang ko'rsatkichi ---------- */
.swatch {
  width: 100%; height: 74px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-2);
  background-image: linear-gradient(45deg, #80808055 25%, transparent 25%, transparent 75%, #80808055 75%),
                    linear-gradient(45deg, #80808055 25%, transparent 25%, transparent 75%, #80808055 75%);
  background-size: 16px 16px; background-position: 0 0, 8px 8px;
  position: relative; overflow: hidden;
}
.swatch > span { position: absolute; inset: 0; }

.palette-row { display: flex; gap: 6px; flex-wrap: wrap; }
.palette-item {
  flex: 1 1 44px; min-width: 44px; height: 56px; border-radius: 8px;
  border: 1px solid var(--border-2); cursor: pointer; position: relative;
  display: flex; align-items: flex-end; justify-content: center;
  padding-bottom: 3px; font-size: .58rem; font-weight: 700; color: #fff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, .7);
}

/* ---------- Katta matn maydoni bilan ishlash paneli ---------- */
.split { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-4); }
@media (max-width: 800px) { .split { grid-template-columns: 1fr; } }

/* ---------- Qidiruvda topilgan so'zni belgilash ---------- */
mark {
  background: rgba(99, 102, 241, .3);
  color: inherit;
  border-radius: 3px;
  padding: 0 2px;
  box-shadow: 0 0 0 1px rgba(99, 102, 241, .35);
}

/* ---------- Kichik tuzatishlar ---------- */
.chip-group { display: flex; flex-wrap: wrap; gap: 6px; }
.mono-out { font-family: var(--font-mono); word-break: break-all; }
.text-center { text-align: center; }
.mt-0 { margin-top: 0; }
.w-100 { width: 100%; }
