/* =========================================================
   Java OOPs Mastery - Global Stylesheet
   Clean, responsive, light/dark themed educational UI
   ========================================================= */

:root {
  --bg: #f6f8fc;
  --surface: #ffffff;
  --surface-alt: #eef2f9;
  --text: #161e2e;
  --text-muted: #526077;
  --border: #dce3f0;
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-soft: rgba(79, 70, 229, 0.1);
  --accent: #0ea5e9;
  --success: #10b981;
  --success-soft: rgba(16, 185, 129, 0.12);
  --warning: #f59e0b;
  --warning-soft: rgba(245, 158, 11, 0.12);
  --danger: #ef4444;
  --code-bg: #0f172a;
  --code-header: #1e293b;
  --code-text: #e2e8f0;
  --shadow-sm: 0 2px 8px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 10px 28px rgba(15, 23, 42, 0.08);
  --radius: 14px;
  --radius-sm: 8px;
  --sidebar-w: 270px;
  --header-h: 64px;
  --transition: 0.2s ease;
}

[data-theme="dark"] {
  --bg: #0b1120;
  --surface: #111827;
  --surface-alt: #1e293b;
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --border: #273449;
  --primary: #818cf8;
  --primary-hover: #6366f1;
  --primary-soft: rgba(129, 140, 248, 0.14);
  --accent: #38bdf8;
  --success: #34d399;
  --success-soft: rgba(52, 211, 153, 0.14);
  --warning: #fbbf24;
  --warning-soft: rgba(251, 191, 36, 0.14);
  --code-bg: #070b14;
  --code-header: #111827;
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.28);
  --shadow-md: 0 12px 30px rgba(0, 0, 0, 0.4);
}

*, *::before, *::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.65;
  transition: background var(--transition), color var(--transition);
}

a {
  color: var(--primary);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

code {
  font-family: "Cascadia Code", "Fira Code", Consolas, monospace;
  font-size: 0.9em;
  background: var(--primary-soft);
  color: var(--primary);
  padding: 2px 6px;
  border-radius: 5px;
}

/* ---------- Top Header ---------- */
.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}

.brand-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
}

.menu-btn {
  display: none;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  font-size: 1.15rem;
  cursor: pointer;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text);
  text-decoration: none;
}

.brand:hover {
  text-decoration: none;
}

.brand-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff;
  font-weight: 800;
  font-size: 0.95rem;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.lang-toggle {
  display: inline-flex;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 3px;
  gap: 2px;
}

.lang-btn {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 5px 10px;
  border-radius: 6px;
  cursor: pointer;
  transition: all var(--transition);
}

.lang-btn.active {
  background: var(--primary);
  color: #fff;
}

.theme-btn {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 7px 12px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
}

.theme-btn:hover {
  border-color: var(--primary);
}

/* ---------- Layout ---------- */
.app-layout {
  display: flex;
  padding-top: var(--header-h);
  min-height: 100vh;
}

.sidebar {
  position: fixed;
  top: var(--header-h);
  left: 0;
  bottom: 0;
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 20px 14px;
  overflow-y: auto;
  z-index: 90;
  transition: transform 0.25s ease;
}

.sidebar-title {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  font-weight: 700;
  margin: 0 10px 10px;
}

.nav-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 10px;
  color: var(--text-muted);
  font-weight: 500;
  font-size: 0.92rem;
  transition: all var(--transition);
}

.nav-link:hover {
  background: var(--surface-alt);
  color: var(--text);
  text-decoration: none;
}

.nav-link.active {
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 700;
}

.nav-left {
  display: flex;
  align-items: center;
  gap: 9px;
}

.nav-num {
  font-size: 0.75rem;
  font-weight: 700;
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  background: var(--surface-alt);
  color: var(--text-muted);
}

.nav-link.active .nav-num {
  background: var(--primary);
  color: #fff;
}

.done-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--border);
  flex-shrink: 0;
}

.done-dot.completed {
  background: var(--success);
  box-shadow: 0 0 0 3px var(--success-soft);
}

.sidebar-progress {
  margin-top: 24px;
  padding: 14px;
  background: var(--surface-alt);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.progress-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: 8px;
}

.progress-track {
  width: 100%;
  height: 8px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--primary), var(--success));
  border-radius: 999px;
  transition: width 0.35s ease;
}

.main-content {
  flex: 1;
  margin-left: var(--sidebar-w);
  padding: 32px 28px 60px;
  max-width: 1080px;
}

/* ---------- Hero / Page Headers ---------- */
.hero {
  background: linear-gradient(135deg, var(--primary), #0284c7);
  color: #fff;
  padding: 36px 32px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  margin-bottom: 28px;
}

.hero-tag {
  display: inline-block;
  background: rgba(255, 255, 255, 0.18);
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  margin-bottom: 12px;
}

.hero h1 {
  margin: 0 0 10px;
  font-size: 2rem;
  line-height: 1.2;
}

.hero p {
  margin: 0 0 20px;
  opacity: 0.94;
  max-width: 680px;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.92rem;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
}

.btn:hover {
  text-decoration: none;
  transform: translateY(-1px);
}

.btn-white {
  background: #fff;
  color: #1e1b4b;
}

.btn-outline-white {
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.35);
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
}

.btn-secondary:hover {
  border-color: var(--primary);
}

.btn-success {
  background: var(--success);
  color: #fff;
}

.page-header {
  margin-bottom: 24px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--border);
}

.breadcrumb {
  font-size: 0.84rem;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.page-header h1 {
  margin: 0 0 8px;
  font-size: 1.9rem;
}

.page-header p {
  margin: 0;
  color: var(--text-muted);
}

/* ---------- Cards & Grid ---------- */
.search-bar-wrap {
  margin-bottom: 22px;
}

.search-input {
  width: 100%;
  padding: 13px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 0.96rem;
  outline: none;
  box-shadow: var(--shadow-sm);
}

.search-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
  gap: 18px;
  margin-bottom: 30px;
}

.topic-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition), border-color var(--transition), box-shadow var(--transition);
}

.topic-card:hover {
  transform: translateY(-3px);
  border-color: var(--primary);
  box-shadow: var(--shadow-md);
}

.topic-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.topic-badge {
  font-size: 0.74rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary);
}

.status-pill {
  font-size: 0.74rem;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--surface-alt);
  color: var(--text-muted);
}

.status-pill.done {
  background: var(--success-soft);
  color: var(--success);
}

.topic-card h3 {
  margin: 0 0 8px;
  font-size: 1.15rem;
}

.topic-card p {
  margin: 0 0 16px;
  font-size: 0.9rem;
  color: var(--text-muted);
}

/* ---------- Content Sections ---------- */
.section-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 22px;
  box-shadow: var(--shadow-sm);
}

.section-card h2 {
  margin: 0 0 12px;
  font-size: 1.35rem;
  display: flex;
  align-items: center;
  gap: 10px;
}

.section-card h3 {
  margin: 18px 0 8px;
  font-size: 1.08rem;
}

.note-box {
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  margin: 12px 0;
  border-left: 4px solid var(--primary);
  background: var(--surface-alt);
}

.note-box.hinglish {
  border-left-color: var(--warning);
  background: var(--warning-soft);
}

.note-box.tip {
  border-left-color: var(--success);
  background: var(--success-soft);
}

.note-label {
  font-size: 0.74rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  display: block;
  margin-bottom: 4px;
  color: var(--text-muted);
}

/* Language filter visibility */
body[data-lang="en"] .lang-hi { display: none; }
body[data-lang="hi"] .lang-en { display: none; }

.two-col {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
  margin-top: 14px;
}

.info-box {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
}

.info-box h4 {
  margin: 0 0 8px;
  font-size: 1rem;
  color: var(--primary);
}

.info-box ul {
  margin: 0;
  padding-left: 18px;
}

.info-box li {
  margin-bottom: 5px;
  font-size: 0.92rem;
}

/* ---------- Code Block + Simulated Console ---------- */
.code-card {
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid #1e293b;
  margin: 16px 0;
  background: var(--code-bg);
}

.code-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  background: var(--code-header);
  color: #cbd5e1;
  font-size: 0.82rem;
  font-weight: 600;
}

.code-actions {
  display: flex;
  gap: 8px;
}

.code-btn {
  background: rgba(255, 255, 255, 0.1);
  color: #f8fafc;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition);
}

.code-btn:hover {
  background: rgba(255, 255, 255, 0.2);
}

.code-btn.run-btn {
  background: var(--success);
  color: #052e16;
  border-color: transparent;
}

.code-btn.run-btn:hover {
  opacity: 0.9;
}

.code-card pre {
  margin: 0;
  padding: 16px;
  overflow-x: auto;
  color: var(--code-text);
  font-family: "Cascadia Code", "Fira Code", Consolas, monospace;
  font-size: 0.88rem;
  line-height: 1.55;
}

.code-card pre code {
  background: transparent;
  color: inherit;
  padding: 0;
  font-size: inherit;
}

/* Syntax tokens */
.tok-kw { color: #c084fc; font-weight: 600; }
.tok-type { color: #38bdf8; }
.tok-str { color: #86efac; }
.tok-num { color: #fbbf24; }
.tok-cmt { color: #64748b; font-style: italic; }

.console-output {
  display: none;
  border-top: 1px solid #334155;
  background: #020617;
  color: #4ade80;
  padding: 12px 16px;
  font-family: "Cascadia Code", Consolas, monospace;
  font-size: 0.85rem;
  white-space: pre-wrap;
}

.console-output.show {
  display: block;
}

.console-title {
  display: block;
  color: #94a3b8;
  font-size: 0.72rem;
  text-transform: uppercase;
  margin-bottom: 4px;
}

/* ---------- Tables ---------- */
.table-wrap {
  overflow-x: auto;
  margin: 14px 0;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

th, td {
  padding: 12px 14px;
  border: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

th {
  background: var(--surface-alt);
  font-weight: 700;
}

/* ---------- Visual Diagrams & Interactive Labs ---------- */
.diagram-box {
  background: var(--surface-alt);
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  padding: 20px;
  margin: 16px 0;
  text-align: center;
}

.tree-row {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.tree-node {
  background: var(--surface);
  border: 2px solid var(--primary);
  border-radius: 10px;
  padding: 8px 18px;
  font-weight: 700;
  font-size: 0.9rem;
  box-shadow: var(--shadow-sm);
}

.tree-node.iface {
  border-style: dashed;
  border-color: var(--accent);
}

.tree-arrow {
  font-size: 1.2rem;
  color: var(--text-muted);
  font-weight: 700;
  margin: 6px 0;
}

.lab-box {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 18px;
  margin-top: 16px;
}

.lab-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-top: 10px;
}

.lab-input {
  padding: 9px 12px;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 0.92rem;
}

.lab-result {
  margin-top: 12px;
  padding: 10px 14px;
  border-radius: 7px;
  background: var(--code-bg);
  color: #4ade80;
  font-family: Consolas, monospace;
  font-size: 0.88rem;
  min-height: 40px;
}

/* ---------- Quiz Styles ---------- */
.quiz-question {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
}

.quiz-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
}

.quiz-option {
  text-align: left;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-alt);
  color: var(--text);
  font-size: 0.93rem;
  cursor: pointer;
  transition: all var(--transition);
}

.quiz-option:hover:not(:disabled) {
  border-color: var(--primary);
}

.quiz-option.correct {
  background: var(--success-soft);
  border-color: var(--success);
  font-weight: 600;
}

.quiz-option.wrong {
  background: rgba(239, 68, 68, 0.14);
  border-color: var(--danger);
}

.quiz-feedback {
  margin-top: 10px;
  font-size: 0.88rem;
  font-weight: 600;
}

/* ---------- Page Footer Navigation ---------- */
.page-footer-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  margin-top: 32px;
  padding-top: 22px;
  border-top: 1px solid var(--border);
}

.backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 80;
}

.backdrop.show {
  display: block;
}

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .menu-btn {
    display: inline-flex;
  }

  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .main-content {
    margin-left: 0;
    padding: 22px 16px 50px;
  }

  .hero {
    padding: 26px 20px;
  }

  .hero h1 {
    font-size: 1.55rem;
  }

  .lang-toggle {
    display: none;
  }
}
