/* ==========================================================================
   FikrLab — Asosiy dizayn tizimi
   Imzo: "ikkilik" — Tanqidiy (kobalt) ↔ Kreativ (amber), firuza aksent.
   ========================================================================== */

:root {
  /* Ranglar */
  --critical: #1E3A8A;      /* kobalt — tanqidiy */
  --critical-soft: #DBEAFE;
  --creative: #C2410C;      /* amber-terrakota — kreativ */
  --creative-soft: #FFEDD5;
  --accent: #0D9488;        /* firuza — aksent */
  --accent-soft: #CCFBF1;

  --ink: #16181D;
  --ink-soft: #5B6472;
  --paper: #F4F6FA;
  --surface: #FFFFFF;
  --line: #E2E7EF;

  --success: #15803D;
  --success-soft: #DCFCE7;
  --danger: #B91C1C;
  --danger-soft: #FEE2E2;

  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 3px rgba(16,24,40,.06), 0 6px 20px rgba(16,24,40,.05);
  --shadow-lg: 0 12px 40px rgba(16,24,40,.12);
  --sidebar-w: 260px;
  --fs-base: 16px;

  --font-display: 'Sora', system-ui, sans-serif;
  --font-body: 'Inter', system-ui, sans-serif;
}

[data-theme="dark"] {
  --critical: #60A5FA; --critical-soft: #1E3A5F;
  --creative: #FB923C; --creative-soft: #4A2410;
  --accent: #2DD4BF; --accent-soft: #0F3D38;
  --ink: #E8EBF0; --ink-soft: #9BA6B5;
  --paper: #0E1116; --surface: #171B22; --line: #2A303B;
  --success: #4ADE80; --success-soft: #14351F;
  --danger: #F87171; --danger-soft: #3B1717;
  --shadow: 0 1px 3px rgba(0,0,0,.4), 0 6px 20px rgba(0,0,0,.3);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: var(--fs-base); scroll-behavior: smooth; }
body {
  font-family: var(--font-body);
  background: var(--paper); color: var(--ink);
  line-height: 1.6; -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4, .brand-name { font-family: var(--font-display); line-height: 1.25; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }

.skip-link {
  position: absolute; left: -999px; top: 8px; z-index: 999;
  background: var(--critical); color: #fff; padding: 10px 16px; border-radius: var(--radius-sm);
}
.skip-link:focus { left: 8px; }

:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

/* ---------- Tugmalar ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 20px; border: none; border-radius: var(--radius-sm);
  font-family: var(--font-body); font-size: .95rem; font-weight: 600;
  cursor: pointer; transition: transform .08s, box-shadow .2s, background .2s; text-decoration: none;
}
.btn:hover { text-decoration: none; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-sm { min-height: 36px; padding: 0 14px; font-size: .85rem; }
.btn-lg { min-height: 52px; padding: 0 28px; font-size: 1.05rem; margin-top: 10px; }
.btn-primary { background: var(--critical); color: #fff; }
.btn-creative { background: var(--creative); color: #fff; }
.btn-accent { background: var(--accent); color: #fff; }
.btn-ghost { background: transparent; color: var(--ink); border: 1.5px solid var(--line); }
.btn-ghost:hover { background: var(--paper); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-block { width: 100%; }

.icon-btn {
  width: 42px; height: 42px; border-radius: 50%; border: none; background: transparent;
  color: var(--ink-soft); cursor: pointer; display: grid; place-items: center; font-size: 1.05rem;
}
.icon-btn:hover { background: var(--paper); color: var(--ink); }

/* ---------- Kartalar ---------- */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px; box-shadow: var(--shadow);
}
.card h3 { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; font-size: 1.1rem; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

.badge {
  display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: .78rem; font-weight: 600;
  background: var(--paper); color: var(--ink-soft);
}
.badge-critical { background: var(--critical-soft); color: var(--critical); }
.badge-creative { background: var(--creative-soft); color: var(--creative); }
.badge-accent { background: var(--accent-soft); color: var(--accent); }
.badge-success { background: var(--success-soft); color: var(--success); }

.callout {
  background: var(--paper); border-left: 4px solid var(--accent); border-radius: var(--radius-sm);
  padding: 14px 16px; margin: 12px 0;
}
.callout b { display: block; margin-bottom: 4px; }
.callout.c-critical { border-left-color: var(--critical); }
.callout.c-creative { border-left-color: var(--creative); }

.progress { height: 8px; background: var(--line); border-radius: 999px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--accent); border-radius: 999px; transition: width .5s; }
.progress.p-critical > span { background: var(--critical); }
.progress.p-creative > span { background: var(--creative); }

.field { margin-bottom: 14px; }
.field label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: 6px; }
.field input, .field select, .field textarea, .topbar-search input {
  width: 100%; padding: 11px 14px; border: 1.5px solid var(--line); border-radius: var(--radius-sm);
  font-family: var(--font-body); font-size: .95rem; background: var(--surface); color: var(--ink);
}
.field textarea { min-height: 90px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--accent); outline: none; }

.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table th { font-family: var(--font-display); font-size: .85rem; color: var(--ink-soft); }

.page-title { font-size: 1.7rem; margin-bottom: 4px; }
.page-sub { color: var(--ink-soft); margin-bottom: 22px; }

/* ==========================================================================
   LANDING
   ========================================================================== */
.landing { max-width: 1100px; margin: 0 auto; padding: 0 20px; }
.landing-nav {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 0; position: sticky; top: 0; background: var(--paper); z-index: 20;
}
.hero { display: grid; grid-template-columns: 1fr 1fr; min-height: 78vh; align-items: center; gap: 40px; }
.hero-copy h1 { font-size: 3rem; line-height: 1.1; margin-bottom: 16px; }
.hero-copy .lead { font-size: 1.15rem; color: var(--ink-soft); margin-bottom: 24px; }
.hero-cta { display: flex; gap: 12px; flex-wrap: wrap; }
.hero-stats { display: flex; gap: 24px; margin-top: 30px; flex-wrap: wrap; }
.hero-stats .num { font-family: var(--font-display); font-size: 1.8rem; font-weight: 800; }
.hero-stats .lbl { font-size: .82rem; color: var(--ink-soft); }
.grad-critical { color: var(--critical); }
.grad-creative { color: var(--creative); }

.hero-visual { position: relative; height: 420px; }
.duality {
  position: absolute; inset: 0; border-radius: 28px; overflow: hidden;
  display: grid; grid-template-columns: 1fr 1fr; box-shadow: var(--shadow-lg);
}
.duality-half { display: grid; place-items: center; padding: 20px; text-align: center; color: #fff; }
.duality-half i { font-size: 3rem; margin-bottom: 12px; }
.duality-critical { background: linear-gradient(150deg, #1E3A8A, #2563EB); }
.duality-creative { background: linear-gradient(150deg, #C2410C, #EA580C); }
.duality-mid {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%,-50%);
  width: 84px; height: 84px; border-radius: 50%; background: var(--accent); color: #fff;
  display: grid; place-items: center; font-size: 1.8rem; box-shadow: var(--shadow-lg);
}

.section { padding: 70px 0; }
.section h2 { font-size: 2rem; text-align: center; margin-bottom: 8px; }
.section .sub { text-align: center; color: var(--ink-soft); margin-bottom: 40px; }
.feature-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.feature { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow); }
.feature .fic { width: 52px; height: 52px; border-radius: 14px; display: grid; place-items: center; font-size: 1.4rem; color: #fff; margin-bottom: 14px; }

.method-steps { display: grid; grid-template-columns: repeat(5, 1fr); gap: 14px; }
.method-step { text-align: center; padding: 16px; }
.method-step .n { width: 44px; height: 44px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; margin: 0 auto 10px; font-weight: 700; font-family: var(--font-display); }

/* Auth */
.auth-wrap { max-width: 460px; margin: 0 auto; }
.auth-tabs { display: flex; gap: 6px; background: var(--paper); padding: 5px; border-radius: var(--radius-sm); margin-bottom: 20px; }
.auth-tab { flex: 1; min-height: 42px; border: none; background: transparent; border-radius: var(--radius-sm); cursor: pointer; font-weight: 600; color: var(--ink-soft); }
.auth-tab[aria-selected="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.auth-panel[hidden] { display: none; }
.divider { text-align: center; color: var(--ink-soft); font-size: .82rem; margin: 16px 0; position: relative; }
.divider::before, .divider::after { content: ''; position: absolute; top: 50%; width: 40%; height: 1px; background: var(--line); }
.divider::before { left: 0; } .divider::after { right: 0; }
.form-error { color: var(--danger); font-size: .85rem; margin-top: 8px; min-height: 1.2em; }
.link-btn { background: none; border: none; color: var(--accent); cursor: pointer; font-size: .85rem; padding: 0; }

.brand { display: flex; align-items: center; gap: 10px; font-family: var(--font-display); font-size: 1.3rem; font-weight: 800; color: var(--ink); text-decoration: none; }
.brand:hover { text-decoration: none; }
.brand-mark { width: 30px; height: 30px; border-radius: 9px; overflow: hidden; display: flex; box-shadow: var(--shadow); }
.mark-half { flex: 1; } .mark-critical { background: var(--critical); } .mark-creative { background: var(--creative); }
.brand-name b { color: var(--accent); }

/* ==========================================================================
   APP SHELL
   ========================================================================== */
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w); flex-shrink: 0; background: var(--surface); border-right: 1px solid var(--line);
  padding: 18px 14px; overflow-y: auto; position: sticky; top: 0; height: 100vh;
}
.sidebar .brand { padding: 6px 8px 18px; }
.nav-group-label { font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-soft); margin: 16px 8px 6px; font-weight: 700; }
.nav-item {
  display: flex; align-items: center; gap: 12px; width: 100%; padding: 10px 12px; margin-bottom: 2px;
  border: none; background: transparent; border-radius: var(--radius-sm); color: var(--ink-soft);
  font-family: var(--font-body); font-size: .92rem; font-weight: 500; cursor: pointer; text-align: left; text-decoration: none;
}
.nav-item i { width: 20px; text-align: center; }
.nav-item:hover { background: var(--paper); color: var(--ink); text-decoration: none; }
.nav-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

.app-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 10px; padding: 12px 22px; background: var(--surface);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 15;
}
.topbar-search { position: relative; flex: 0 1 340px; }
.topbar-search i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--ink-soft); }
.topbar-search input { padding-left: 36px; min-height: 40px; }
.spacer { flex: 1; }
.menu-toggle { display: none; }
.xp-pill { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; background: var(--creative-soft); color: var(--creative); font-weight: 700; font-size: .85rem; }
.avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--critical); color: #fff; display: grid; place-items: center; font-weight: 700; text-decoration: none; }
.avatar:hover { text-decoration: none; }
.avatar-lg { width: 68px; height: 68px; font-size: 1.6rem; }

.page { padding: 26px 30px 60px; max-width: 1200px; width: 100%; margin: 0 auto; outline: none; }

/* Modul kartalari */
.module-card { display: flex; flex-direction: column; gap: 8px; transition: transform .1s, box-shadow .2s; }
.module-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.module-card p { color: var(--ink-soft); font-size: .9rem; flex: 1; }
.mod-icon { width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; font-size: 1.25rem; color: #fff; }
.mod-icon.i-critical { background: var(--critical); }
.mod-icon.i-creative { background: var(--creative); }
.mod-meta { display: flex; align-items: center; justify-content: space-between; font-size: .82rem; color: var(--ink-soft); }

/* Stat kartalar */
.stat-card { display: flex; flex-direction: column; gap: 4px; }
.stat-value { font-family: var(--font-display); font-size: 1.9rem; font-weight: 800; }
.stat-label { font-size: .82rem; color: var(--ink-soft); }
.tint-critical { border-top: 3px solid var(--critical); }
.tint-creative { border-top: 3px solid var(--creative); }
.tint-accent { border-top: 3px solid var(--accent); }
.stat-line { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--line); }

/* Dars */
.lesson-layout { display: grid; grid-template-columns: 200px 1fr; gap: 20px; align-items: start; }
.lesson-toc { position: sticky; top: 76px; display: flex; flex-direction: column; gap: 2px; }
.lesson-toc a { padding: 6px 10px; border-radius: 8px; color: var(--ink-soft); font-size: .88rem; }
.lesson-toc a:hover { background: var(--paper); color: var(--ink); text-decoration: none; }
.lesson-section { margin-bottom: 16px; scroll-margin-top: 76px; }

/* Test */
.quiz-option {
  display: block; width: 100%; text-align: left; padding: 12px 16px; margin: 6px 0;
  border: 1.5px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); color: var(--ink);
  cursor: pointer; font-family: var(--font-body); font-size: .95rem; min-height: 44px;
}
.quiz-option:hover:not(:disabled) { border-color: var(--accent); }
.quiz-option:disabled { cursor: default; }
.quiz-option.is-correct { border-color: var(--success); background: var(--success-soft); color: var(--success); font-weight: 600; }
.quiz-option.is-wrong { border-color: var(--danger); background: var(--danger-soft); color: var(--danger); }

/* Chat */
.chat-box { max-height: 300px; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; padding: 12px 0; margin: 10px 0; }
.chat-msg { max-width: 85%; padding: 10px 14px; border-radius: 14px; font-size: .92rem; white-space: pre-line; }
.chat-msg.from-user { align-self: flex-end; background: var(--critical); color: #fff; border-bottom-right-radius: 4px; }
.chat-msg.from-ai { align-self: flex-start; background: var(--paper); color: var(--ink); border-bottom-left-radius: 4px; }
.chat-input-row { display: flex; gap: 8px; align-items: flex-end; }
.chat-input-row input, .chat-input-row textarea { flex: 1; padding: 11px 14px; border: 1.5px solid var(--line); border-radius: var(--radius-sm); font-family: var(--font-body); background: var(--surface); color: var(--ink); }
.chat-input-row textarea { resize: vertical; min-height: 44px; }

/* Sticky board */
.sticky-board { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 14px; }
.sticky { position: relative; padding: 16px; border-radius: 6px; min-height: 110px; font-size: .9rem; box-shadow: var(--shadow); color: #3a2f00; transform: rotate(-1deg); }
.sticky:nth-child(even) { transform: rotate(1deg); }
.sticky.s-yellow { background: #FEF08A; } .sticky.s-blue { background: #BFDBFE; }
.sticky.s-green { background: #BBF7D0; } .sticky.s-pink { background: #FBCFE8; }
.sticky-del { position: absolute; top: 4px; right: 6px; border: none; background: rgba(0,0,0,.08); border-radius: 50%; width: 22px; height: 22px; cursor: pointer; color: #333; }

/* Reyting */
.rank-row { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.rank-me { background: var(--accent-soft); border-radius: var(--radius-sm); padding-left: 10px; padding-right: 10px; }
.rank-num { width: 30px; height: 30px; border-radius: 50%; background: var(--paper); display: grid; place-items: center; font-weight: 700; flex-shrink: 0; }
.rank-num.rank-top { background: var(--creative); color: #fff; }

/* Yutuqlar */
.badge-card { text-align: center; }
.badge-card .badge-icon { width: 60px; height: 60px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-size: 1.6rem; margin: 0 auto; }
.badge-locked { opacity: .5; }
.badge-locked .badge-icon { background: var(--paper); color: var(--ink-soft); }

/* Toast */
.toast-wrap { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--ink); color: var(--paper); padding: 12px 18px; border-radius: 999px; box-shadow: var(--shadow-lg); font-size: .9rem; display: flex; align-items: center; gap: 8px; animation: toastIn .3s; }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } }

code { background: var(--paper); padding: 2px 6px; border-radius: 4px; font-size: .85em; }

/* ---------- Responsive ---------- */
@media (max-width: 920px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .hero { grid-template-columns: 1fr; text-align: center; padding: 30px 0; }
  .hero-visual { height: 300px; }
  .hero-cta, .hero-stats { justify-content: center; }
  .feature-grid, .method-steps { grid-template-columns: 1fr; }
  .lesson-layout { grid-template-columns: 1fr; }
  .lesson-toc { position: static; flex-direction: row; flex-wrap: wrap; }
  .sidebar {
    position: fixed; left: 0; top: 0; z-index: 60; transform: translateX(-100%);
    transition: transform .25s; box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: translateX(0); }
  .menu-toggle { display: grid; }
  .topbar-search { flex: 1; }
  .page { padding: 18px 16px 50px; }
  .hero-copy h1 { font-size: 2.1rem; }
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
}

@media print {
  .sidebar, .topbar, .a11y-fab, .lesson-toc, #btn-complete, .btn { display: none !important; }
  .page { max-width: 100%; padding: 0; }
  .card { box-shadow: none; border: 1px solid #ccc; break-inside: avoid; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
