/* ==========================================================================
   Lingo90 — asosiy dizayn tizimi (tokenlar, layout, komponentlar)
   ========================================================================== */

:root {
  /* Brend gradienti */
  --brand-1: #7C5CFC;
  --brand-2: #5B7FFF;
  --gradient: linear-gradient(135deg, #7C5CFC 0%, #5B7FFF 100%);
  --gradient-soft: linear-gradient(135deg, rgba(124, 92, 252, .12) 0%, rgba(91, 127, 255, .12) 100%);

  /* Holat ranglari (Duolingo uslubi) */
  --green: #58CC02;
  --green-dark: #48A502;
  --orange: #FF9600;
  --red: #FF4B4B;
  --gold: #FFC800;
  --blue: #1CB0F6;

  /* Neytral ranglar */
  --bg: #F4F5FB;
  --surface: #FFFFFF;
  --surface-2: #F7F7FC;
  --border: #E8E8F3;
  --text: #1F2033;
  --text-2: #6B6D85;
  --text-3: #9A9CB2;

  /* Shakl va soya */
  --r-sm: 12px;
  --r-md: 18px;
  --r-lg: 24px;
  --r-xl: 32px;
  --shadow-sm: 0 2px 8px rgba(31, 32, 51, .06);
  --shadow-md: 0 8px 24px rgba(31, 32, 51, .08);
  --shadow-brand: 0 10px 24px rgba(124, 92, 252, .32);

  /* O'lchamlar */
  --tabbar-h: 64px;
  --sidebar-w: 264px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* Qorong'i mavzu — Telegram theme yoki tizim sozlamasi bo'yicha */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14141C;
    --surface: #1D1D28;
    --surface-2: #24242F;
    --border: #2E2E3C;
    --text: #F2F2F7;
    --text-2: #A6A8BD;
    --text-3: #767890;
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, .3);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, .35);
  }
}
:root[data-theme="dark"] {
  --bg: #14141C;
  --surface: #1D1D28;
  --surface-2: #24242F;
  --border: #2E2E3C;
  --text: #F2F2F7;
  --text-2: #A6A8BD;
  --text-3: #767890;
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, .3);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, .35);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overscroll-behavior-y: none;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: "Nunito", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { margin: 0; font-weight: 800; letter-spacing: -.02em; }
p { margin: 0; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; border: none; background: none; cursor: pointer; }
ul { margin: 0; padding: 0; list-style: none; }
[hidden] { display: none !important; }

/* --------------------------------------------------------------------------
   Layout
   -------------------------------------------------------------------------- */

.app {
  display: flex;
  min-height: 100%;
}

.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  padding-bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 12px);
}

.screen {
  flex: 1;
  width: 100%;
  max-width: 620px;
  margin: 0 auto;
  padding: 8px 16px 24px;
  animation: screen-in .28s ease both;
}

@keyframes screen-in {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: none; }
}

/* Yuqori panel */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  padding: calc(var(--safe-top) + 10px) 16px 10px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid transparent;
}
.topbar__inner {
  max-width: 620px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 40px;
}
.topbar__inner > div { min-width: 0; }
.topbar__title { font-size: 20px; font-weight: 900; }
.topbar__sub {
  font-size: 12px; color: var(--text-2); font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.topbar__spacer { flex: 1; }
.topbar__inner .chip { flex: none; }
@media (max-width: 380px) {
  .topbar__inner { gap: 8px; }
  .topbar__inner .chip { padding: 4px 8px; font-size: 11px; }
}

.iconbtn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 18px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  flex: none;
  transition: transform .15s ease;
}
.iconbtn:active { transform: scale(.92); }

/* Pastki tab menyu (mobil) */
.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  display: flex;
  height: calc(var(--tabbar-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--border);
}
.tab {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 0 2px;
  color: var(--text-3);
  font-weight: 700;
  transition: color .18s ease;
}
.tab__label {
  font-size: 9.5px;
  line-height: 1.15;
  text-align: center;
  max-width: 100%;
}
.tab__icon {
  font-size: 19px;
  line-height: 1;
  filter: grayscale(1);
  opacity: .55;
  transition: transform .2s ease, filter .2s ease, opacity .2s ease;
}
.tab.is-active { color: var(--brand-1); }
.tab.is-active .tab__icon { filter: none; opacity: 1; transform: translateY(-2px) scale(1.12); }

/* Yon panel (desktop) */
.sidebar { display: none; }

/* --------------------------------------------------------------------------
   Komponentlar
   -------------------------------------------------------------------------- */

.card {
  background: var(--surface);
  border-radius: var(--r-lg);
  padding: 18px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
}
.card--flat { box-shadow: none; }
.card--tight { padding: 14px; }

.card-gradient {
  background: var(--gradient);
  color: #fff;
  border: none;
  box-shadow: var(--shadow-brand);
  position: relative;
  overflow: hidden;
}
.card-gradient::after {
  content: "";
  position: absolute;
  right: -40px;
  top: -60px;
  width: 180px;
  height: 180px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .12);
}

.section-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin: 22px 4px 10px;
}
.section-title h2 { font-size: 17px; }
.section-title a, .section-title button {
  font-size: 13px;
  font-weight: 800;
  color: var(--brand-1);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 20px;
  border-radius: var(--r-md);
  font-weight: 800;
  font-size: 15px;
  text-align: center;
  transition: transform .12s ease, box-shadow .2s ease, opacity .2s ease;
  user-select: none;
}
.btn:active { transform: translateY(2px) scale(.99); }
.btn--block { width: 100%; }
.btn--sm { padding: 9px 14px; font-size: 13px; border-radius: var(--r-sm); }
.btn--primary { background: var(--gradient); color: #fff; box-shadow: var(--shadow-brand); }
.btn--green { background: var(--green); color: #fff; box-shadow: 0 4px 0 var(--green-dark); }
.btn--green:active { box-shadow: 0 1px 0 var(--green-dark); }
.btn--ghost { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
.btn--white { background: #fff; color: var(--brand-1); }
.btn--outline { background: transparent; color: var(--brand-1); border: 2px solid var(--brand-1); }
.btn[disabled], .btn.is-disabled { opacity: .5; pointer-events: none; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  background: var(--surface-2);
  color: var(--text-2);
  border: 1px solid var(--border);
}
.chip--brand { background: var(--gradient-soft); color: var(--brand-1); border-color: transparent; }
.chip--green { background: rgba(88, 204, 2, .14); color: var(--green-dark); border-color: transparent; }
.chip--gold  { background: rgba(255, 200, 0, .18); color: #B98800; border-color: transparent; }
.chip--glass { background: rgba(255, 255, 255, .2); color: #fff; border-color: rgba(255, 255, 255, .3); }
/* Bugun ilovada o'tkazilgan vaqt — topbardagi kichik hisoblagich */
.chip--time { background: var(--gradient-soft); color: var(--brand-1); border-color: transparent; white-space: nowrap; }

/* Progress bar */
.progress {
  height: 12px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
  border: 1px solid var(--border);
}
.progress__fill {
  height: 100%;
  border-radius: 999px;
  background: var(--gradient);
  transition: width .6s cubic-bezier(.22, 1, .36, 1);
}
.progress--onbrand { background: rgba(255, 255, 255, .25); border-color: transparent; }
.progress--onbrand .progress__fill { background: #fff; }
.progress--green .progress__fill { background: var(--green); }

/* Statistika kataklari */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 12px 8px;
  text-align: center;
  box-shadow: var(--shadow-sm);
}
.stat__icon { font-size: 20px; line-height: 1; }
.stat__value { font-size: 18px; font-weight: 900; margin-top: 2px; }
.stat__label { font-size: 11px; color: var(--text-2); font-weight: 700; }

/* Ro'yxat elementi */
.row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-sm);
  width: 100%;
  text-align: left;
  transition: transform .12s ease;
}
.row:active { transform: scale(.985); }
.row__icon {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  font-size: 20px;
  background: var(--gradient-soft);
  flex: none;
}
.row__body { flex: 1; min-width: 0; }
.row__title { font-weight: 800; font-size: 15px; }
.row__sub { font-size: 12.5px; color: var(--text-2); font-weight: 600; }
.row__arrow { color: var(--text-3); font-size: 18px; flex: none; }

.stack { display: flex; flex-direction: column; gap: 10px; }
.muted { color: var(--text-2); }
.center { text-align: center; }

/* Bo'sh holat */
.empty { text-align: center; padding: 48px 16px; color: var(--text-2); }
.empty__emoji { font-size: 44px; }

/* Toast xabar */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 16px);
  transform: translate(-50%, 20px);
  z-index: 100;
  max-width: min(90vw, 420px);
  padding: 12px 18px;
  border-radius: 999px;
  background: #1F2033;
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  box-shadow: var(--shadow-md);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
}
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(15, 15, 25, .5);
  backdrop-filter: blur(3px);
  animation: fade-in .2s ease both;
}
.modal__sheet {
  width: min(100%, 520px);
  background: var(--surface);
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  padding: 22px 20px calc(22px + var(--safe-bottom));
  animation: sheet-up .3s cubic-bezier(.22, 1, .36, 1) both;
}
@keyframes fade-in { from { opacity: 0 } to { opacity: 1 } }
@keyframes sheet-up { from { transform: translateY(100%) } to { transform: none } }

/* --------------------------------------------------------------------------
   Responsive — planshet va desktop
   -------------------------------------------------------------------------- */

@media (min-width: 900px) {
  :root { --tabbar-h: 0px; }

  .tabbar { display: none; }

  .sidebar {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: var(--sidebar-w);
    flex: none;
    padding: 24px 16px;
    background: var(--surface);
    border-right: 1px solid var(--border);
    position: sticky;
    top: 0;
    height: 100vh;
  }
  .sidebar__brand { display: flex; align-items: center; gap: 12px; padding: 0 8px 20px; }
  .sidebar__logo {
    width: 44px; height: 44px; border-radius: 14px;
    background: var(--gradient); color: #fff;
    display: grid; place-items: center;
    font-weight: 900; font-size: 16px;
    box-shadow: var(--shadow-brand);
  }
  .sidebar__title { font-weight: 900; font-size: 16px; }
  .sidebar__subtitle { font-size: 12px; color: var(--text-2); font-weight: 600; }
  .sidebar__nav { display: flex; flex-direction: column; gap: 4px; }
  .navlink {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 14px;
    border-radius: var(--r-md);
    font-weight: 700;
    color: var(--text-2);
    transition: background .18s ease, color .18s ease;
  }
  .navlink:hover { background: var(--surface-2); color: var(--text); }
  .navlink.is-active { background: var(--gradient-soft); color: var(--brand-1); }
  .navlink__icon { font-size: 18px; }

  .sidebar__promo {
    margin-top: auto;
    background: var(--gradient);
    color: #fff;
    border-radius: var(--r-lg);
    padding: 18px;
    cursor: pointer;
    box-shadow: var(--shadow-brand);
  }
  .sidebar__promo-title { font-weight: 900; margin-bottom: 6px; }
  .sidebar__promo-text { font-size: 12.5px; opacity: .9; margin-bottom: 12px; line-height: 1.45; }

  .main { padding-bottom: 24px; }
  .screen { max-width: 720px; padding: 12px 32px 48px; }
  .topbar { background: transparent; backdrop-filter: none; padding-top: 20px; }
  .topbar__inner { max-width: 720px; padding: 0 16px; }
  .toast { bottom: 24px; }
  .modal { align-items: center; }
  .modal__sheet { border-radius: var(--r-xl); padding-bottom: 22px; }
}

@media (min-width: 1200px) {
  .screen { max-width: 860px; }
  .topbar__inner { max-width: 860px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
