/* ==========================================================================
   Python String Methods — style.css
   Minimalistik, professional, yengil dizayn. Dark/Light Mode CSS
   custom-property'lar orqali boshqariladi (data-theme atributi).
   ========================================================================== */

/* ============================================================
   0. RESET
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
img, svg { display: block; max-width: 100%; }
button { font: inherit; cursor: pointer; }
a { text-decoration: none; color: inherit; }
ul, ol { list-style: none; }
input { font: inherit; }

/* ============================================================
   1. RANG O'ZGARUVCHILARI (THEME TOKENS)
   ============================================================ */
:root,
:root[data-theme="light"] {
  --bg: #f7f8fa;
  --bg-alt: #ffffff;
  --surface: #ffffff;
  --surface-2: #f1f3f6;
  --border: #e3e6eb;
  --text: #1c2230;
  --text-dim: #5b6472;
  --text-faint: #8891a0;

  --brand: #3b6fd6;
  --brand-dark: #2f5cc0;
  --brand-soft: #eaf0fd;

  --ok: #1f9d55;
  --ok-soft: #e6f7ec;
  --bad: #d64545;
  --bad-soft: #fbe9e9;
  --warn: #b8860b;

  --code-bg: #1e2430;
  --code-text: #d8dde5;

  --tok-kw: #ff7ab8;
  --tok-str: #98d982;
  --tok-num: #d9a24b;
  --tok-com: #7b8494;
  --tok-fn: #6cb6ff;

  --shadow: 0 2px 10px rgba(20, 25, 40, .06);
  --shadow-md: 0 6px 24px rgba(20, 25, 40, .10);
  --radius: 12px;
  --radius-sm: 8px;
}

:root[data-theme="dark"] {
  --bg: #10131a;
  --bg-alt: #161a23;
  --surface: #181c26;
  --surface-2: #1f2430;
  --border: #2a2f3d;
  --text: #e8ebf1;
  --text-dim: #a4acbb;
  --text-faint: #6b7386;

  --brand: #5b8cf0;
  --brand-dark: #4a78dd;
  --brand-soft: #1c2740;

  --ok: #3ec97f;
  --ok-soft: #133223;
  --bad: #f26666;
  --bad-soft: #3a1f22;
  --warn: #d9a83a;

  --code-bg: #0d0f14;
  --code-text: #d8dde5;

  --tok-kw: #ff8fc4;
  --tok-str: #a3e08a;
  --tok-num: #e0b064;
  --tok-com: #6b7386;
  --tok-fn: #7ec2ff;

  --shadow: 0 2px 12px rgba(0, 0, 0, .30);
  --shadow-md: 0 8px 28px rgba(0, 0, 0, .40);
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", -apple-system, BlinkMacSystemFont, "Inter", Roboto, Arial, sans-serif;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  transition: background .25s ease, color .25s ease;
}

.container { max-width: 900px; margin: 0 auto; padding: 0 24px; }
.container-wide { max-width: 1200px; }

.dim { color: var(--text-dim); }

h1, h2, h3 { line-height: 1.25; font-weight: 700; letter-spacing: -.01em; }
h1 { font-size: 2.1rem; }
h2 { font-size: 1.4rem; margin-bottom: 14px; }
h3 { font-size: 1.05rem; }
p { color: var(--text-dim); }

/* ============================================================
   2. TUGMALAR
   ============================================================ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 20px; border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text);
  font-weight: 600; font-size: .92rem;
  transition: transform .15s ease, background .15s ease, border-color .15s ease, box-shadow .15s ease;
  white-space: nowrap;
}
.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
.btn:active { transform: translateY(0); }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); }
.btn-ghost { background: transparent; }
.btn-lg { padding: 13px 26px; font-size: 1rem; border-radius: var(--radius); }
.btn-sm { padding: 6px 12px; font-size: .82rem; border-radius: 6px; }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; box-shadow: none; }

.icon-btn {
  width: 38px; height: 38px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--surface-2); border: 1px solid var(--border);
  font-size: 1.05rem; transition: background .15s ease, transform .15s ease;
}
.icon-btn:hover { transform: scale(1.06); }

/* ============================================================
   3. NAVBAR
   ============================================================ */
.navbar {
  position: sticky; top: 0; z-index: 40;
  background: var(--bg-alt); border-bottom: 1px solid var(--border);
  backdrop-filter: blur(6px);
}
.navbar-inner {
  max-width: 1200px; margin: 0 auto; padding: 12px 24px;
  display: flex; align-items: center; gap: 20px;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 1.15rem; flex-shrink: 0; }
.brand-icon { font-size: 1.3rem; }

.nav-search-wrap { flex: 1; max-width: 340px; }
.nav-search {
  width: 100%; padding: 9px 14px; border-radius: 20px;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text);
  font-size: .9rem; outline: none; transition: border-color .15s ease;
}
.nav-search:focus { border-color: var(--brand); }

.nav-links { display: flex; gap: 4px; margin-left: auto; }
.nav-link {
  padding: 8px 14px; border-radius: var(--radius-sm); font-weight: 600; font-size: .92rem;
  color: var(--text-dim); transition: background .15s ease, color .15s ease;
}
.nav-link:hover { background: var(--surface-2); color: var(--text); }

.navbar-actions { display: flex; align-items: center; gap: 10px; }
.progress-chip {
  background: var(--brand-soft); color: var(--brand); font-weight: 700; font-size: .82rem;
  padding: 6px 12px; border-radius: 20px;
}

/* ============================================================
   4. VIEWS (SPA)
   ============================================================ */
.view { display: none; padding: 40px 0 80px; animation: fadeIn .3s ease; }
.view.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

/* ============================================================
   5. BOSH SAHIFA / HERO
   ============================================================ */
.hero { text-align: center; padding: 20px 0 40px; }
.hero-title {
  font-size: 2.6rem; font-weight: 800; margin-bottom: 16px;
  background: linear-gradient(90deg, var(--brand), var(--tok-fn));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.hero-desc { max-width: 640px; margin: 0 auto 28px; font-size: 1.02rem; }
.hero-actions { display: flex; justify-content: center; gap: 14px; flex-wrap: wrap; margin-bottom: 28px; }

.home-progress { max-width: 420px; margin: 0 auto; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.home-progress-bar { width: 100%; height: 8px; border-radius: 6px; background: var(--surface-2); overflow: hidden; }
.home-progress-fill { height: 100%; width: 0%; background: var(--brand); border-radius: 6px; transition: width .4s ease; }
#home-progress-text { font-size: .85rem; color: var(--text-dim); font-weight: 600; }

.home-section { margin-top: 50px; }
.home-section > p { margin-bottom: 20px; }

/* ============================================================
   6. MAVZULAR RO'YXATI
   ============================================================ */
.topics-list { display: flex; flex-direction: column; gap: 8px; }
.topic-row {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 16px; border-radius: var(--radius-sm);
  background: var(--surface); border: 1px solid var(--border);
  transition: border-color .15s ease, transform .15s ease, box-shadow .15s ease;
}
.topic-row:hover { border-color: var(--brand); transform: translateX(2px); box-shadow: var(--shadow); }
.topic-row.done { background: var(--ok-soft); }
.topic-row-num {
  width: 26px; height: 26px; border-radius: 50%; background: var(--surface-2);
  display: flex; align-items: center; justify-content: center;
  font-size: .78rem; font-weight: 700; color: var(--text-dim); flex-shrink: 0;
}
.topic-row-icon { font-size: 1.2rem; flex-shrink: 0; }
.topic-row-title { flex: 1; font-weight: 600; }
.topic-row-check { color: var(--ok); font-weight: 800; }
.bookmark-btn {
  background: none; border: none; font-size: 1.15rem; color: var(--text-faint);
  padding: 4px; line-height: 1; transition: transform .15s ease, color .15s ease;
}
.bookmark-btn:hover { transform: scale(1.15); }
.bookmark-btn.active { color: var(--warn); }

/* ============================================================
   7. MAVZU SAHIFASI
   ============================================================ */
.topic-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.crumb { font-weight: 600; color: var(--brand); font-size: .92rem; }
.topic-progress-label { color: var(--text-faint); font-size: .85rem; font-weight: 600; }

.topic-head { display: flex; align-items: center; gap: 12px; margin-bottom: 32px; }
.topic-head-icon { font-size: 2rem; }
.topic-head h1 { flex: 1; font-size: 1.7rem; }
.topic-head .bookmark-btn { font-size: 1.5rem; }

.block { margin-bottom: 44px; padding-bottom: 44px; border-bottom: 1px solid var(--border); }
.block:last-of-type { border-bottom: none; }
.explain-text { font-size: 1.02rem; white-space: pre-line; }

/* ---- Misollar tabs ---- */
.ex-tabs { display: flex; gap: 6px; margin-bottom: 16px; flex-wrap: wrap; }
.ex-tab {
  padding: 8px 16px; border-radius: 20px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text-dim); font-weight: 600; font-size: .88rem;
  transition: all .15s ease;
}
.ex-tab.active, .ex-tab:hover { background: var(--brand); border-color: var(--brand); color: #fff; }
.ex-panel { display: none; }
.ex-panel.active { display: block; animation: fadeIn .25s ease; }

.code-block {
  background: var(--code-bg); color: var(--code-text);
  border-radius: var(--radius-sm); padding: 16px 18px;
  font-family: "SFMono-Regular", Consolas, "Courier New", monospace;
  font-size: .88rem; overflow-x: auto; white-space: pre;
  margin-bottom: 10px;
}
.ex-note { font-size: .92rem; }

/* ---- Muhim eslatmalar ---- */
.notes-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.note-col {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 18px;
}
.note-col h3 { margin-bottom: 10px; font-size: .95rem; }
.note-col ul { display: flex; flex-direction: column; gap: 8px; }
.note-col li { font-size: .88rem; color: var(--text-dim); padding-left: 14px; position: relative; }
.note-col li::before { content: "•"; position: absolute; left: 0; color: var(--text-faint); }
.note-col.do { border-color: var(--ok); background: var(--ok-soft); }
.note-col.dont { border-color: var(--bad); background: var(--bad-soft); }

.topic-bottom {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  margin-top: 20px;
}

/* ============================================================
   8. KOD MUHARRIRI (EDITOR)
   ============================================================ */
.editor {
  background: var(--code-bg); border-radius: var(--radius); overflow: hidden;
  border: 1px solid var(--border); box-shadow: var(--shadow);
}
.editor-toolbar {
  display: flex; align-items: center; gap: 6px; padding: 10px 14px;
  background: rgba(255,255,255,.03); border-bottom: 1px solid rgba(255,255,255,.06);
}
.editor-dot { width: 10px; height: 10px; border-radius: 50%; background: rgba(255,255,255,.15); }
.editor-toolbar-btns { margin-left: auto; display: flex; gap: 8px; }
.editor-toolbar .btn { background: rgba(255,255,255,.08); border-color: rgba(255,255,255,.12); color: #fff; }
.editor-toolbar .btn-primary { background: var(--brand); border-color: var(--brand); }
.editor-toolbar .btn:hover { background: rgba(255,255,255,.16); }
.editor-toolbar .btn-primary:hover { background: var(--brand-dark); }

.editor-body { display: flex; min-height: 140px; max-height: 360px; overflow: hidden; }
.editor-gutter {
  flex-shrink: 0; padding: 14px 10px; text-align: right;
  color: rgba(255,255,255,.25); font-family: "SFMono-Regular", Consolas, monospace;
  font-size: .88rem; line-height: 1.55; user-select: none; overflow: hidden;
  white-space: pre;
}
.editor-code { position: relative; flex: 1; overflow: hidden; }
.editor-pre, .editor-code textarea {
  margin: 0; padding: 14px 16px; font-family: "SFMono-Regular", Consolas, "Courier New", monospace;
  font-size: .88rem; line-height: 1.55; white-space: pre; word-wrap: normal;
  position: absolute; top: 0; left: 0; right: 0; bottom: 0; overflow: auto;
}
.editor-pre { color: var(--code-text); pointer-events: none; }
.editor-code textarea {
  background: transparent; color: transparent; caret-color: #fff;
  border: none; outline: none; resize: none; -webkit-text-fill-color: transparent;
}
.editor-code textarea::selection { background: rgba(91,140,240,.35); -webkit-text-fill-color: transparent; }

.tok-kw { color: var(--tok-kw); font-weight: 600; }
.tok-str { color: var(--tok-str); }
.tok-num { color: var(--tok-num); }
.tok-com { color: var(--tok-com); font-style: italic; }
.tok-fn { color: var(--tok-fn); }

.editor-output {
  border-top: 1px solid rgba(255,255,255,.08); background: rgba(0,0,0,.18);
  color: var(--code-text); font-family: "SFMono-Regular", Consolas, monospace;
  font-size: .86rem; padding: 14px 16px; min-height: 60px; max-height: 220px; overflow-y: auto;
}
.out-line { padding: 2px 0; white-space: pre-wrap; word-break: break-word; }
.out-error { color: var(--bad); }
.out-ok { color: var(--ok); margin-top: 6px; font-weight: 600; }

/* ============================================================
   9. QUIZ
   ============================================================ */
.quiz-box {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 24px; box-shadow: var(--shadow);
}
.quiz-top { display: flex; justify-content: space-between; font-size: .82rem; color: var(--text-faint); font-weight: 700; margin-bottom: 14px; }
.quiz-q { font-size: 1.08rem; font-weight: 700; margin-bottom: 18px; }
.quiz-opts { display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px; }
.quiz-opt {
  text-align: left; padding: 13px 16px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text);
  font-size: .95rem; transition: border-color .15s ease, background .15s ease, transform .1s ease;
}
.quiz-opt:hover:not(:disabled) { border-color: var(--brand); transform: translateX(2px); }
.quiz-opt:disabled { cursor: default; }
.quiz-opt.correct { background: var(--ok-soft); border-color: var(--ok); font-weight: 700; }
.quiz-opt.wrong { background: var(--bad-soft); border-color: var(--bad); font-weight: 700; }
.quiz-why {
  display: none; padding: 14px 16px; border-radius: var(--radius-sm);
  background: var(--surface-2); font-size: .9rem; margin-bottom: 16px;
}
.quiz-why.show { display: block; animation: fadeIn .25s ease; }
.quiz-actions { display: flex; justify-content: flex-end; }

.quiz-result { text-align: center; }
.quiz-result-num { font-size: 2.4rem; font-weight: 800; color: var(--brand); margin-bottom: 10px; }
.quiz-result p { margin-bottom: 18px; }

/* ============================================================
   10. CODING SAHIFASI (ONLINE COMPILER)
   ============================================================ */
.coding-head { margin-bottom: 24px; }
.coding-head h1 { margin-bottom: 8px; }
#coding-editor .editor-body { min-height: 380px; max-height: none; }
#coding-editor .editor-output { min-height: 140px; max-height: 300px; }

/* ============================================================
   11. FOOTER
   ============================================================ */
.footer { border-top: 1px solid var(--border); padding: 24px 0; margin-top: 40px; }
.footer p { text-align: center; font-size: .85rem; }
