/*
  RANG PALITRASI - o'zimizniki.

  Telegram ichida --tg-theme-* o'zgaruvchilari beriladi, lekin biz
  ularni ISHLATMAYMIZ: aks holda dizayn Telegram'ning standart ko'k
  rangiga aylanib, o'ziga xosligini yo'qotadi.

  Telegram'dan faqat bitta narsa olinadi - yorug'/qorong'i holati.
  app.js uni <html data-theme="dark"> sifatida qo'yadi.
*/

:root {
  --bg:        #ffffff;
  --card:      #f4f5f7;
  --text:      #14161a;
  --hint:      #82868e;
  --accent:    #5b4bdb;
  --accent-2:  #9333ea;
  --on-accent: #ffffff;

  --line:   rgba(20, 22, 26, 0.09);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 4px 12px rgba(0, 0, 0, 0.06);

  --ok:   #15803d;
  --warn: #b45309;
  --bad:  #b91c1c;

  --ok-bg:   rgba(21, 128, 61, 0.11);
  --warn-bg: rgba(180, 83, 9, 0.11);
  --bad-bg:  rgba(185, 28, 28, 0.11);


  /* accent = #5b4bdb ning shaffof variantlari (color-mix o'rniga) */
  --accent-a09:  rgba(91, 75, 219, 0.09);
  --accent-a12:  rgba(91, 75, 219, 0.12);
  --accent-a15:  rgba(91, 75, 219, 0.15);
  --accent-a25:  rgba(91, 75, 219, 0.25);
  --accent-a30:  rgba(91, 75, 219, 0.30);
  --accent-glow: rgba(91, 75, 219, 0.28);

  --r-sm: 10px;
  --r-md: 14px;
  --r-lg: 20px;
}

/* Qorong'i palitra */

:root[data-theme="dark"] {
  --bg:        #16181d;
  --card:      #212429;
  --text:      #eceef1;
  --hint:      #8d929b;
  --accent:    #8b7cf6;
  --accent-2:  #c084fc;
  --on-accent: #ffffff;

  --line:   rgba(255, 255, 255, 0.10);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.35), 0 4px 14px rgba(0, 0, 0, 0.3);

  --ok:   #4ade80;
  --warn: #fbbf24;
  --bad:  #f87171;

  --ok-bg:   rgba(74, 222, 128, 0.14);
  --warn-bg: rgba(251, 191, 36, 0.14);
  --bad-bg:  rgba(248, 113, 113, 0.14);

  /* accent = #8b7cf6 */
  --accent-a09:  rgba(139, 124, 246, 0.13);
  --accent-a12:  rgba(139, 124, 246, 0.16);
  --accent-a15:  rgba(139, 124, 246, 0.18);
  --accent-a25:  rgba(139, 124, 246, 0.30);
  --accent-a30:  rgba(139, 124, 246, 0.38);
  --accent-glow: rgba(139, 124, 246, 0.30);
}

/* Telegram tashqarisida (oddiy brauzer) - tizim sozlamasiga qarab */

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:        #16181d;
    --card:      #212429;
    --text:      #eceef1;
    --hint:      #8d929b;
    --accent:    #8b7cf6;
    --accent-2:  #c084fc;

    --line:   rgba(255, 255, 255, 0.10);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.35), 0 4px 14px rgba(0, 0, 0, 0.3);

    --ok:   #4ade80;
    --warn: #fbbf24;
    --bad:  #f87171;

    --ok-bg:   rgba(74, 222, 128, 0.14);
    --warn-bg: rgba(251, 191, 36, 0.14);
    --bad-bg:  rgba(248, 113, 113, 0.14);

    /* accent = #8b7cf6 */
    --accent-a09:  rgba(139, 124, 246, 0.13);
    --accent-a12:  rgba(139, 124, 246, 0.16);
    --accent-a15:  rgba(139, 124, 246, 0.18);
    --accent-a25:  rgba(139, 124, 246, 0.30);
    --accent-a30:  rgba(139, 124, 246, 0.38);
    --accent-glow: rgba(139, 124, 246, 0.30);
  }
}

* { box-sizing: border-box; }

/* mobil qurilmada bosilganda matn ajralib qolmasin */
button, .tab-btn, .list-row, .child-row, .schedule-row, .pill, .badge,
.section-title, .info-label, .stat-label {
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

html, body { height: 100%; }

body {
  margin: 0;
  padding: 18px 16px 40px;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text",
               "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

.screen {
  max-width: 520px;
  margin: 0 auto;
  animation: fade 0.22s ease;
}

@keyframes fade {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}

h2 {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 4px 0 18px;
}

/* ---------- Bo'lim sarlavhasi ---------- */

.section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--hint);
  margin: 26px 0 10px;
}

.section-title::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}

/* ---------- Yuklanish / xato ---------- */

#loading, #error {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 65vh;
  gap: 14px;
  text-align: center;
  color: var(--hint);
}

.spinner {
  width: 30px;
  height: 30px;
  border: 2.5px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.error-icon { font-size: 38px; }

#error p { white-space: pre-line; margin: 0; max-width: 300px; }

/* ---------- Karta sarlavhasi (ota-ona) ---------- */

.card-header {
  text-align: center;
  padding: 6px 0 22px;
}

.avatar {
  width: 76px;
  height: 76px;
  border-radius: 50%;
  margin: 0 auto 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--on-accent);
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 6px 18px var(--accent-glow);
}

.card-header h1 {
  font-size: 21px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0 0 10px;
  line-height: 1.25;
}

.pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
}

.pill {
  font-size: 12.5px;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: 100px;
  background: var(--card);
  color: var(--hint);
  border: 1px solid var(--line);
}

.pill.strong {
  background: var(--accent-a12);
  color: var(--accent);
  border-color: var(--accent-a25);
}

.muted { color: var(--hint); margin: 0; font-size: 13.5px; }

/* ---------- Ma'lumot kataklari ---------- */

.info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.info-item {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 12px 13px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.info-label {
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--hint);
}

.info-value {
  font-size: 14.5px;
  font-weight: 600;
  word-break: break-word;
}

/* ---------- Ro'yxat bloki ---------- */

.list-block {
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.empty-hint {
  color: var(--hint);
  font-size: 13.5px;
  text-align: center;
  padding: 22px 14px;
  background: var(--card);
  border: 1px dashed var(--line);
  border-radius: var(--r-md);
}

/* ---------- Dars jadvali ---------- */

.schedule-row {
  position: relative;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 12px 14px 12px 17px;
  overflow: hidden;
}

.schedule-row::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 4px;
  background: var(--line);
}

.schedule-row.today {
  background: var(--accent-a09);
  border-color: var(--accent-a30);
  box-shadow: var(--shadow);
}

.schedule-row.today::before { background: var(--accent); }

.schedule-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 3px;
}

.schedule-day {
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--hint);
}

.schedule-row.today .schedule-day { color: var(--accent); }

.today-tag {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.06em;
  padding: 2px 7px;
  border-radius: 100px;
  background: var(--accent);
  color: var(--on-accent);
  margin-left: 6px;
}

.schedule-time {
  font-size: 16px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}

.schedule-subject {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 2px;
}

.schedule-meta {
  font-size: 12.5px;
  color: var(--hint);
}

/* ---------- To'lovlar ---------- */

.payment-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 12px 14px;
}

.payment-month {
  font-size: 15px;
  font-weight: 600;
}

.payment-amount {
  color: var(--hint);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  margin-top: 1px;
}

.badge {
  flex-shrink: 0;
  font-size: 12px;
  font-weight: 700;
  padding: 5px 11px;
  border-radius: 100px;
  white-space: nowrap;
}

.badge.paid     { background: var(--ok-bg);   color: var(--ok); }
.badge.pending  { background: var(--warn-bg); color: var(--warn); }
.badge.rejected { background: var(--bad-bg);  color: var(--bad); }

/* ---------- Farzandlar ro'yxati ---------- */

.child-row {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 13px 14px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  margin-bottom: 9px;
  cursor: pointer;
  transition: transform 0.12s ease, opacity 0.12s ease;
}

.child-row:active { transform: scale(0.985); opacity: 0.75; }

.child-avatar {
  width: 42px;
  height: 42px;
  flex-shrink: 0;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  font-weight: 700;
  color: var(--on-accent);
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
}

.child-meta strong { display: block; font-size: 15px; font-weight: 600; }
.child-meta span   { color: var(--hint); font-size: 12.5px; }

/* ---------- Tablar ---------- */

.tab-row {
  display: flex;
  gap: 4px;
  margin: 14px 0 18px;
  padding: 4px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
}

.tab-btn {
  flex: 1;
  white-space: nowrap;
  background: none;
  border: none;
  border-radius: var(--r-sm);
  padding: 9px 6px;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  color: var(--hint);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.tab-btn.active {
  background: var(--bg);
  color: var(--text);
  box-shadow: var(--shadow);
}

.tab-pane.hidden { display: none; }

/* ---------- Tugmalar ---------- */

.back-btn {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  padding: 4px 0 14px;
  cursor: pointer;
}

.primary-btn {
  display: block;
  width: 100%;
  background: var(--accent);
  color: var(--on-accent);
  border: none;
  border-radius: var(--r-md);
  padding: 14px;
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  margin-top: 16px;
  cursor: pointer;
  box-shadow: 0 4px 14px var(--accent-glow);
  transition: transform 0.12s ease, opacity 0.12s ease;
}

.primary-btn:active { transform: scale(0.985); opacity: 0.85; }

.danger-btn {
  display: block;
  width: 100%;
  background: var(--bad-bg);
  color: var(--bad);
  border: none;
  border-radius: var(--r-md);
  padding: 13px;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  margin-top: 24px;
  cursor: pointer;
}

/* ---------- Forma maydonlari ---------- */

.field-label {
  display: block;
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--hint);
  margin: 16px 0 7px;
}

.field-select,
.field-input {
  display: block;
  width: 100%;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 12px 13px;
  font-size: 15px;
  font-family: inherit;
  color: var(--text);
  appearance: none;
  -webkit-appearance: none;
}

.field-select {
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%238b8f96' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
}

.field-input:focus,
.field-select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-a15);
}

.field-input + .field-input { margin-top: 10px; }

/* ---------- Bosiladigan ro'yxat qatori ---------- */

.list-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 13px 14px;
  cursor: pointer;
  transition: transform 0.12s ease, opacity 0.12s ease;
}

.list-row:active { transform: scale(0.985); opacity: 0.75; }

.list-row-title { font-size: 14.5px; font-weight: 600; }

.list-row-sub {
  font-size: 12.5px;
  color: var(--hint);
  margin-top: 2px;
}

.list-row-badge {
  flex-shrink: 0;
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
  background: var(--accent-a12);
  border-radius: 100px;
  padding: 4px 11px;
}

.chevron {
  flex-shrink: 0;
  color: var(--hint);
  opacity: 0.5;
  font-size: 18px;
  line-height: 1;
}

.remove-btn {
  flex-shrink: 0;
  background: none;
  border: none;
  color: var(--bad);
  font-size: 17px;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 8px;
}

.remove-btn:active { background: var(--bad-bg); }

/* ---------- "Hozir" kartochkasi (direktor) ---------- */

.live-card {
  position: relative;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 14px 15px 14px 18px;
  overflow: hidden;
}

.live-card::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 4px;
  background: var(--ok);
}

.live-card-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.live-room {
  font-size: 15.5px;
  font-weight: 700;
}

.live-time {
  font-size: 13px;
  font-weight: 600;
  color: var(--ok);
  font-variant-numeric: tabular-nums;
}

.live-subject {
  font-size: 13.5px;
  color: var(--hint);
  margin: 2px 0 8px;
}

.live-students {
  font-size: 13px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

/* ---------- Statistika paneli ---------- */

.stat-bar {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
}

.stat-box {
  flex: 1;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 13px;
  text-align: center;
}

.stat-value {
  font-size: 19px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

.stat-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--hint);
  margin-top: 2px;
}
