/* =========================================================================
   Kurs boti — Admin panel dizayn tizimi
   Minimalist, light/dark, tabular-nums, micro-interaction.
   ========================================================================= */

:root {
  /* Rangli palitra — LIGHT (standart) */
  --bg: #f6f7f9;
  --bg-2: #eef0f3;
  --surface: #ffffff;
  --surface-2: #f8f9fb;
  --text: #16181d;
  --muted: #6b7280;
  --faint: #9aa1ac;
  --line: #e6e8ec;
  --line-strong: #d6d9df;

  --brand: #4f46e5;
  --brand-strong: #4338ca;
  --brand-soft: #eef0ff;
  --brand-ring: rgba(79, 70, 229, 0.35);

  --ok: #15803d;
  --ok-soft: #dcfce7;
  --warn: #b45309;
  --warn-soft: #fef3c7;
  --err: #dc2626;
  --err-soft: #fee2e2;

  --shadow-sm: 0 1px 2px rgba(16, 18, 23, 0.04), 0 1px 3px rgba(16, 18, 23, 0.06);
  --shadow-md: 0 4px 12px rgba(16, 18, 23, 0.08), 0 2px 4px rgba(16, 18, 23, 0.04);
  --shadow-pop: 0 12px 32px rgba(16, 18, 23, 0.14);

  --r-sm: 8px;
  --r: 12px;
  --r-lg: 16px;
  --r-full: 999px;

  --sp: 4px;
  --sidebar-w: 232px;

  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* DARK — tizim sozlamasi bo'yicha */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0c0e;
    --bg-2: #101216;
    --surface: #16181c;
    --surface-2: #1b1e23;
    --text: #e8eaed;
    --muted: #9ba1ac;
    --faint: #6c7079;
    --line: #262a30;
    --line-strong: #333842;

    --brand: #7c8cff;
    --brand-strong: #94a1ff;
    --brand-soft: #1b1f3a;
    --brand-ring: rgba(124, 140, 255, 0.4);

    --ok: #4ade80;
    --ok-soft: #10331f;
    --warn: #fbbf24;
    --warn-soft: #37290a;
    --err: #f87171;
    --err-soft: #3a1717;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 6px 18px rgba(0, 0, 0, 0.45);
    --shadow-pop: 0 16px 40px rgba(0, 0, 0, 0.6);
  }
}

/* DARK — foydalanuvchi tanlovi (toggle) ustunlik qiladi */
:root[data-theme="dark"] {
  --bg: #0b0c0e;
  --bg-2: #101216;
  --surface: #16181c;
  --surface-2: #1b1e23;
  --text: #e8eaed;
  --muted: #9ba1ac;
  --faint: #6c7079;
  --line: #262a30;
  --line-strong: #333842;
  --brand: #7c8cff;
  --brand-strong: #94a1ff;
  --brand-soft: #1b1f3a;
  --brand-ring: rgba(124, 140, 255, 0.4);
  --ok: #4ade80;
  --ok-soft: #10331f;
  --warn: #fbbf24;
  --warn-soft: #37290a;
  --err: #f87171;
  --err-soft: #3a1717;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 6px 18px rgba(0, 0, 0, 0.45);
  --shadow-pop: 0 16px 40px rgba(0, 0, 0, 0.6);
}

/* LIGHT — foydalanuvchi tanlovi (toggle) ustunlik qiladi */
:root[data-theme="light"] {
  --bg: #f6f7f9;
  --bg-2: #eef0f3;
  --surface: #ffffff;
  --surface-2: #f8f9fb;
  --text: #16181d;
  --muted: #6b7280;
  --faint: #9aa1ac;
  --line: #e6e8ec;
  --line-strong: #d6d9df;
  --brand: #4f46e5;
  --brand-strong: #4338ca;
  --brand-soft: #eef0ff;
  --brand-ring: rgba(79, 70, 229, 0.35);
  --ok: #15803d;
  --ok-soft: #dcfce7;
  --warn: #b45309;
  --warn-soft: #fef3c7;
  --err: #dc2626;
  --err-soft: #fee2e2;
  --shadow-sm: 0 1px 2px rgba(16, 18, 23, 0.04), 0 1px 3px rgba(16, 18, 23, 0.06);
  --shadow-md: 0 4px 12px rgba(16, 18, 23, 0.08), 0 2px 4px rgba(16, 18, 23, 0.04);
  --shadow-pop: 0 12px 32px rgba(16, 18, 23, 0.14);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.55;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "cv02", "cv03", "cv04", "cv11";
  text-rendering: optimizeLegibility;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

code {
  font-family: ui-monospace, "SF Mono", "Cascadia Code", Menlo, Consolas, monospace;
  font-size: 0.86em;
  background: var(--bg-2);
  padding: 1px 6px;
  border-radius: 6px;
}

::selection { background: var(--brand-ring); }

/* ---------- Layout ---------- */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--line);
  padding: 20px 14px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.logo {
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -0.01em;
  padding: 4px 10px 18px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.logo small { font-weight: 450; color: var(--muted); font-size: 12px; letter-spacing: 0; }

.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav button {
  position: relative;
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  text-align: left;
  background: none;
  border: 0;
  padding: 9px 12px;
  min-height: 40px;
  border-radius: var(--r-sm);
  cursor: pointer;
  font: inherit;
  font-weight: 500;
  color: var(--muted);
  transition: background 0.15s ease, color 0.15s ease, transform 0.06s ease;
}
.nav button:hover { background: var(--bg-2); color: var(--text); }
.nav button:active { transform: scale(0.985); }
.nav button.active { background: var(--brand-soft); color: var(--brand-strong); }
.nav button.active::before {
  content: "";
  position: absolute;
  left: -14px;
  top: 8px;
  bottom: 8px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--brand);
}

.sidebar-foot {
  border-top: 1px solid var(--line);
  padding-top: 12px;
  margin-top: 4px;
}
.theme-toggle {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  background: none;
  border: 1px solid var(--line);
  padding: 9px 12px;
  min-height: 40px;
  border-radius: var(--r-sm);
  cursor: pointer;
  font: inherit;
  font-weight: 500;
  color: var(--muted);
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s;
}
.theme-toggle:hover { background: var(--bg-2); color: var(--text); border-color: var(--line-strong); }

.main {
  flex: 1;
  padding: 28px 32px 64px;
  max-width: 1180px;
  min-width: 0;
}

h1 {
  font-size: 22px;
  font-weight: 680;
  letter-spacing: -0.02em;
  margin: 0 0 4px;
  text-wrap: balance;
}
.subtitle { color: var(--muted); margin: 0 0 22px; font-size: 13.5px; }

/* Kontent kirish animatsiyasi */
.main > h1 { animation: fadeUp 0.32s ease both; }
.main > .subtitle { animation: fadeUp 0.32s ease 0.02s both; }
.main > .grid, .main > .card, .main > div { animation: fadeUp 0.34s ease 0.04s both; }
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

/* ---------- Cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 18px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}
.card h2 {
  font-size: 14px;
  font-weight: 640;
  letter-spacing: -0.01em;
  margin: 0 0 14px;
}

.grid { display: grid; gap: 14px; }
.grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols-2 { grid-template-columns: repeat(2, 1fr); }

/* ---------- Stat tiles ---------- */
.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 16px 16px 14px;
  box-shadow: var(--shadow-sm);
  transition: transform 0.14s ease, box-shadow 0.14s ease, border-color 0.14s ease;
}
.stat:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--line-strong); }
.stat .value {
  font-size: 27px;
  font-weight: 700;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}
.stat .label {
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 500;
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* ---------- Forms ---------- */
label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  margin: 12px 0 5px;
}
input[type="text"], input[type="password"], input[type="number"], input[type="file"], select, textarea {
  width: 100%;
  padding: 9px 11px;
  min-height: 40px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  font: inherit;
  background: var(--surface);
  color: var(--text);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input::placeholder, textarea::placeholder { color: var(--faint); }
textarea { min-height: 96px; resize: vertical; line-height: 1.6; }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-ring);
}
input[type="file"] { padding: 7px 10px; cursor: pointer; }
select { cursor: pointer; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: var(--brand);
  color: #fff;
  border: 1px solid transparent;
  padding: 0 16px;
  min-height: 40px;
  border-radius: var(--r-sm);
  cursor: pointer;
  font: inherit;
  font-weight: 550;
  white-space: nowrap;
  transition: background 0.15s ease, transform 0.06s ease, box-shadow 0.15s ease, opacity 0.15s;
  box-shadow: var(--shadow-sm);
}
.btn:hover { background: var(--brand-strong); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--brand-ring); }

.btn.sec {
  background: var(--surface);
  color: var(--text);
  border-color: var(--line-strong);
  box-shadow: none;
}
.btn.sec:hover { background: var(--bg-2); border-color: var(--muted); }

.btn.danger { background: var(--err); }
.btn.danger:hover { background: var(--err); filter: brightness(0.92); }

.btn.sm { min-height: 30px; padding: 0 10px; font-size: 12.5px; border-radius: 7px; box-shadow: none; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.row { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 0; }
.row > .fixed { flex: 0 0 auto; }
.row > .fixed label { white-space: nowrap; }

/* ---------- Table ---------- */
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td {
  text-align: left;
  padding: 10px 10px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
th {
  color: var(--faint);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom-color: var(--line-strong);
  position: sticky;
  top: 0;
  background: var(--surface);
}
tbody tr { transition: background 0.12s ease; }
tbody tr:hover { background: var(--surface-2); }
tbody tr:last-child td { border-bottom: 0; }
td input { min-height: 32px; padding: 5px 9px; }
td.right, th.right { text-align: right; }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  border-radius: var(--r-full);
  font-size: 11px;
  font-weight: 550;
  line-height: 1.7;
  background: var(--bg-2);
  color: var(--muted);
  border: 1px solid transparent;
}
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.err { background: var(--err-soft); color: var(--err); }

.muted { color: var(--muted); }
.right { text-align: right; }
.nowrap { white-space: nowrap; }

details summary { list-style: none; }
details summary::-webkit-details-marker { display: none; }
details summary::before { content: "▸ "; color: var(--faint); }
details[open] summary::before { content: "▾ "; }

pre { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; }

/* ---------- Toast ---------- */
#toast {
  position: fixed;
  bottom: 22px;
  right: 22px;
  background: #111418;
  color: #fff;
  padding: 12px 16px;
  border-radius: var(--r-sm);
  opacity: 0;
  transform: translateY(12px) scale(0.98);
  transition: opacity 0.22s ease, transform 0.22s cubic-bezier(0.2, 0.9, 0.3, 1.2);
  pointer-events: none;
  max-width: 380px;
  z-index: 60;
  box-shadow: var(--shadow-pop);
  font-weight: 500;
}
#toast.show { opacity: 1; transform: none; }
#toast.err { background: var(--err); }
#toast.ok { background: var(--ok); color: #fff; }

/* ---------- Login ---------- */
.login-wrap {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 20px;
  background:
    radial-gradient(60% 50% at 50% 0%, var(--brand-soft), transparent 70%),
    var(--bg);
}
.login-box {
  width: 100%;
  max-width: 360px;
  background: var(--surface);
  padding: 30px 28px;
  border-radius: var(--r-lg);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-md);
  animation: fadeUp 0.4s ease both;
}
.login-box h1 { margin-bottom: 4px; }
.login-box .btn { width: 100%; }

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
  .app { flex-direction: column; }
  .sidebar {
    width: 100%;
    height: auto;
    position: static;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding: 12px;
  }
  .logo { padding-bottom: 10px; }
  .nav { flex-direction: row; flex-wrap: wrap; gap: 4px; }
  .nav button { width: auto; min-height: 36px; }
  .nav button.active::before { display: none; }
  .sidebar-foot { border-top: 0; padding-top: 0; margin-top: 0; }
  .theme-toggle { width: auto; }
  .main { padding: 18px 16px 48px; }
  .grid.cols-4 { grid-template-columns: repeat(2, 1fr); }
  .grid.cols-3, .grid.cols-2 { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
  .grid.cols-4 { grid-template-columns: 1fr 1fr; }
  .main { padding: 16px 12px 40px; }
}

/* Kengligi katta jadval/kartalar — gorizontal scroll ichkarida */
.card { overflow-x: auto; }

/* Harakatni kamaytirish sozlamasi */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}
