/* ── Variables ── */
:root {
  --sidebar-bg: #0f172a;
  --sidebar-border: #1e293b;
  --sidebar-text: #94a3b8;
  --sidebar-text-active: #f1f5f9;
  --sidebar-hover: #1e293b;
  --sidebar-width: 260px;
  --topbar-h: 60px;

  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --accent-light: #eff6ff;
  --success: #16a34a;
  --success-light: #f0fdf4;
  --danger: #dc2626;
  --danger-light: #fef2f2;
  --warning: #d97706;
  --warning-light: #fffbeb;
  --info-light: #f0f9ff;

  --bg: #f1f5f9;
  --surface: #ffffff;
  --border: #e2e8f0;
  --text: #0f172a;
  --text-muted: #64748b;
  --text-light: #94a3b8;

  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md: 0 4px 6px rgba(0,0,0,.05), 0 2px 4px rgba(0,0,0,.04);

  --font: 'Inter', system-ui, -apple-system, sans-serif;
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }
body { font-family: var(--font); color: var(--text); background: var(--bg); line-height: 1.6; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
ul, ol { padding-left: 1.25rem; }

/* ── Layout ── */
.layout {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  min-height: 100vh;
}

/* ── Sidebar ── */
.sidebar {
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.sidebar__logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 16px;
  border-bottom: 1px solid var(--sidebar-border);
  flex-shrink: 0;
}
.sidebar__logo-icon { width: 28px; height: 28px; }
.sidebar__logo-text { color: #f1f5f9; font-weight: 700; font-size: 15px; letter-spacing: .3px; }
.sidebar__nav { padding: 12px 8px; flex: 1; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: var(--sidebar-text);
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 2px;
  transition: background .15s, color .15s;
}
.nav-item:hover { background: var(--sidebar-hover); color: var(--sidebar-text-active); text-decoration: none; }
.nav-item--active { background: var(--accent); color: #fff; }
.nav-item--active:hover { background: var(--accent-hover); color: #fff; }
.nav-item__icon { font-size: 16px; flex-shrink: 0; }
.nav-item__label { flex: 1; }
.nav-item__check { margin-left: auto; color: #4ade80; font-weight: 700; font-size: 13px; }
.nav-divider { height: 1px; background: var(--sidebar-border); margin: 8px 4px; }

/* ── Main wrap ── */
.main-wrap { display: flex; flex-direction: column; min-height: 100vh; overflow: hidden; }

/* ── Top bar ── */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--topbar-h);
  padding: 0 28px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 10;
}
.top-bar__right { display: flex; align-items: center; gap: 16px; }

/* ── Content ── */
.content { padding: 32px 28px; flex: 1; max-width: 1000px; }

/* ── Breadcrumb ── */
.breadcrumb { font-size: 14px; color: var(--text-muted); display: flex; align-items: center; gap: 6px; }
.breadcrumb__link { color: var(--text-muted); }
.breadcrumb__link:hover { color: var(--accent); }
.breadcrumb__sep { color: var(--text-light); }

/* ── Language switcher ── */
.lang-switcher { display: flex; gap: 4px; }
.lang-btn {
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  background: transparent;
  border: 1px solid var(--border);
  cursor: pointer;
  text-decoration: none;
  transition: all .15s;
}
.lang-btn:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }
.lang-btn--active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ── Buttons ── */
.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background .15s;
  font-family: var(--font);
}
.btn-primary:hover { background: var(--accent-hover); text-decoration: none; color: #fff; }
.btn-primary.btn-block { width: 100%; justify-content: center; }
.btn-primary.btn-lg { padding: 12px 28px; font-size: 15px; }
.btn-outline {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  color: var(--text);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: all .15s;
  font-family: var(--font);
}
.btn-outline:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }
.btn-ghost {
  background: transparent;
  border: 1.5px solid var(--border);
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all .15s;
  font-family: var(--font);
}
.btn-ghost:hover { border-color: var(--danger); color: var(--danger); }
.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn-link { color: var(--accent); font-weight: 500; font-size: 14px; }

/* ── Badges ── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .3px;
}
.badge--success { background: var(--success-light); color: var(--success); }
.badge--danger  { background: var(--danger-light);  color: var(--danger); }
.badge--warning { background: var(--warning-light); color: var(--warning); }
.badge--lg { font-size: 13px; padding: 4px 12px; }

/* ── Alerts ── */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  margin-bottom: 16px;
}
.alert--error   { background: var(--danger-light);  color: var(--danger);  border: 1px solid #fca5a5; }
.alert--success { background: var(--success-light); color: var(--success); border: 1px solid #86efac; }
.alert--info    { background: var(--info-light);    color: #0369a1;        border: 1px solid #bae6fd; }

/* ── Forms ── */
.form-group { margin-bottom: 18px; }
.form-label { display: block; font-size: 14px; font-weight: 500; color: var(--text); margin-bottom: 6px; }
.form-hint  { display: block; font-size: 12px; margin-top: 4px; color: var(--text-muted); }
.form-input {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: var(--font);
  color: var(--text);
  background: var(--surface);
  transition: border-color .15s;
  outline: none;
}
.form-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(59,130,246,.1); }
.form-textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: var(--font);
  color: var(--text);
  background: var(--surface);
  resize: vertical;
  min-height: 140px;
  transition: border-color .15s;
  outline: none;
  line-height: 1.6;
}
.form-textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(59,130,246,.1); }

/* ── Auth pages ── */
.auth-body { background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%); }
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.auth-card {
  background: var(--surface);
  border-radius: 16px;
  padding: 40px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 20px 40px rgba(0,0,0,.25);
}
.auth-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: center;
  margin-bottom: 28px;
}
.auth-logo__icon { width: 32px; height: 32px; }
.auth-logo__text { font-size: 18px; font-weight: 700; color: var(--text); }
.auth-title { font-size: 20px; font-weight: 700; text-align: center; margin-bottom: 24px; color: var(--text); }
.auth-form { margin-bottom: 0; }
.auth-links { text-align: center; margin-top: 16px; font-size: 13px; }
.auth-note {
  margin-top: 20px;
  padding: 12px;
  background: var(--info-light);
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: #0369a1;
  display: flex;
  gap: 8px;
  align-items: flex-start;
}

/* ── Home page ── */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 20px;
}
.page-title { font-size: 22px; font-weight: 700; color: var(--text); }
.page-subtitle { font-size: 14px; color: var(--text-muted); margin-top: 4px; }
.progress-summary {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}
.progress-circle {
  display: flex;
  align-items: baseline;
  gap: 2px;
  font-weight: 700;
}
.progress-circle__num { font-size: 28px; color: var(--accent); }
.progress-circle__sep { font-size: 18px; color: var(--text-muted); }
.progress-circle__total { font-size: 18px; color: var(--text-muted); }
.progress-label { font-size: 11px; color: var(--text-muted); text-align: center; }

.progress-bar-wrap {
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  margin-bottom: 28px;
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #60a5fa);
  border-radius: 3px;
  transition: width .4s ease;
  min-width: 4px;
}

/* ── Module cards ── */
.module-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 18px;
}
.module-card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  text-decoration: none;
  color: inherit;
  transition: transform .15s, box-shadow .15s, border-color .15s;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.module-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--accent);
  text-decoration: none;
}
.module-card--completed { border-left: 3px solid var(--success); }
.module-card--locked { opacity: 0.55; cursor: default; pointer-events: none; }
.module-card--locked:hover { box-shadow: var(--shadow-sm); border-color: var(--border); }
.module-card__header { display: flex; align-items: center; justify-content: space-between; }
.module-card__icon { font-size: 28px; }
.module-card__title { font-size: 16px; font-weight: 700; color: var(--text); }
.module-card__desc { font-size: 13px; color: var(--text-muted); line-height: 1.5; flex: 1; }
.module-card__footer { display: flex; align-items: center; justify-content: space-between; margin-top: 4px; }
.module-card__tag { font-size: 11px; color: var(--text-light); }
.btn-link--muted { color: var(--text-light); font-size: 13px; }
.badge--locked { background: var(--bg-subtle, #f1f5f9); color: var(--text-muted); font-size: 12px; padding: 2px 8px; border-radius: 99px; }

/* ── Module page ── */
.module-wrap { max-width: 780px; }
.module-header {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 28px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}
.module-header__top {
  display: flex;
  align-items: center;
  gap: 12px;
}
.module-header__icon { font-size: 36px; flex-shrink: 0; line-height: 1; }
.module-header__title { font-size: 22px; font-weight: 700; line-height: 1.3; margin: 0; }
.module-header__desc { font-size: 14px; color: var(--text-muted); margin: 0; }

.module-content { display: flex; flex-direction: column; gap: 0; }
.content-section {
  padding: 24px 0;
  border-bottom: 1px solid var(--border);
}
.content-section:last-child { border-bottom: none; }
.content-section__heading {
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 14px;
}
.prose {
  font-size: 14.5px;
  line-height: 1.75;
  color: #334155;
}
.prose ul, .prose ol { margin-top: 8px; }
.prose li { margin-bottom: 4px; }
.prose strong { color: var(--text); font-weight: 600; }
.prose table { width: 100%; border-collapse: collapse; font-size: 13px; margin-top: 8px; }
.prose td, .prose th { padding: 8px 12px; border: 1px solid var(--border); }
.prose th { background: #f8fafc; font-weight: 600; }

.module-actions { margin-top: 32px; display: flex; flex-direction: column; gap: 12px; }
.module-actions__row { display: flex; gap: 12px; flex-wrap: wrap; }
.module-actions__hint { font-size: 13px; color: var(--text-muted); }

.quiz-passed-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  background: var(--success-light);
  border: 1px solid #86efac;
  border-radius: var(--radius-sm);
  font-weight: 600;
  color: var(--success);
  font-size: 15px;
}
.score-badge {
  background: var(--success);
  color: #fff;
  padding: 2px 10px;
  border-radius: 20px;
  font-size: 13px;
}

/* ── Quiz page ── */
.quiz-wrap { max-width: 760px; }
.quiz-header { margin-bottom: 28px; }
.quiz-header__title { font-size: 20px; font-weight: 700; }
.quiz-header__note { font-size: 13px; color: var(--text-muted); margin-top: 6px; }

.question-block {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
}
.question-block--open { border-color: #bfdbfe; background: var(--info-light); }
.question-number {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .6px;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 10px;
}
.question-text { font-size: 15px; font-weight: 400; color: var(--text); margin-bottom: 18px; line-height: 1.5; }

.options-list { display: flex; flex-direction: column; gap: 10px; }
.option-label {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.option-label:hover { border-color: var(--accent); background: var(--accent-light); }
.option-label:has(input:checked) { border-color: var(--accent); background: var(--accent-light); }
.option-label input[type="radio"] { display: none; }
.option-label__letter {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--bg);
  border: 1.5px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
  transition: background .15s, border-color .15s, color .15s;
}
.option-label:has(input:checked) .option-label__letter {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.option-label__text { font-size: 14px; }
.option-text { font-size: 14px; }

.option-result { padding: 8px 12px; border-radius: 8px; margin-bottom: 4px; font-size: 14px; }
.option-result--correct { background: #dcfce7; color: #166534; }
.option-result--wrong { background: #fee2e2; color: #991b1b; }

.char-counter { font-size: 13px; color: var(--text-muted); text-align: right; margin-top: 4px; }
.char-counter--warn { color: #dc2626; }
.char-counter--ok { color: #16a34a; }

.video-section { margin: 2rem 0; }
.video-container { position: relative; border-radius: 12px; overflow: hidden; background: #000; }
.video-container iframe { width: 100%; aspect-ratio: 16/9; display: block; border: none; }
.video-blocked-notice { margin-top: 1rem; padding: 1rem; background: #fef3c7; border: 1px solid #f59e0b; border-radius: 8px; text-align: center; color: #92400e; font-weight: 500; }

.open-question-sample { margin-bottom: 16px; }
.open-question-sample__label { font-size: 12px; font-weight: 600; color: var(--text-muted); margin-bottom: 8px; }
.open-question-sample__text {
  border-left: 3px solid var(--accent);
  padding: 12px 16px;
  background: #fff;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 14px;
  line-height: 1.65;
  color: var(--text);
  font-style: italic;
}
.open-question-note { font-size: 12px; color: #0369a1; margin-top: 10px; }

.quiz-submit-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 8px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

/* ── Quiz result ── */
.result-wrap { max-width: 760px; }
.result-hero {
  border-radius: var(--radius);
  padding: 36px;
  text-align: center;
  margin-bottom: 32px;
}
.result-hero--passed { background: linear-gradient(135deg, #f0fdf4, #dcfce7); border: 1px solid #86efac; }
.result-hero--failed { background: linear-gradient(135deg, #fef2f2, #fee2e2); border: 1px solid #fca5a5; }
.result-hero__score {
  font-size: 72px;
  font-weight: 800;
  line-height: 1;
  margin-bottom: 8px;
}
.result-hero--passed .result-hero__score { color: var(--success); }
.result-hero--failed .result-hero__score { color: var(--danger); }
.result-hero__label { font-size: 18px; font-weight: 700; margin-bottom: 24px; }
.result-hero--passed .result-hero__label { color: var(--success); }
.result-hero--failed .result-hero__label { color: var(--danger); }
.result-hero__actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

.result-breakdown__title { font-size: 16px; font-weight: 700; margin-bottom: 16px; }
.result-question {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px 20px;
  margin-bottom: 12px;
  border-left-width: 4px;
}
.result-question--correct { border-left-color: var(--success); }
.result-question--wrong   { border-left-color: var(--danger); }
.result-question--open    { border-left-color: var(--accent); }
.result-question__header { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 10px; }
.result-question__icon { font-size: 16px; flex-shrink: 0; margin-top: 2px; }
.result-question__text { font-size: 14px; font-weight: 600; line-height: 1.4; }
.result-question__label { font-size: 14px; font-weight: 600; }
.result-question__answers { display: flex; flex-wrap: wrap; gap: 8px; }
.result-question__open-answer { background: var(--bg); border-radius: var(--radius-sm); padding: 10px 14px; font-size: 13px; margin-bottom: 8px; }
.result-question__pending { font-size: 12px; color: #0369a1; }

.answer-chip {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 500;
}
.answer-chip--correct { background: var(--success-light); color: var(--success); }
.answer-chip--wrong   { background: var(--danger-light);  color: var(--danger); }

/* ── Messenger buttons ── */
.btn-messenger {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  color: #fff;
  text-decoration: none;
  width: fit-content;
  transition: opacity 0.2s;
}
.btn-messenger:hover { opacity: 0.85; color: #fff; text-decoration: none; }
.btn-telegram { background: #2AABEE; }
.btn-whatsapp { background: #25D366; }

/* ── Mobile menu ── */
.menu-toggle {
  display: none;
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 1100;
  width: 40px;
  height: 40px;
  padding: 8px;
  background: var(--sidebar-bg);
  border: 1px solid var(--sidebar-border);
  border-radius: 8px;
  cursor: pointer;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 5px;
}
.menu-toggle__bar {
  display: block;
  width: 20px;
  height: 2px;
  background: #f1f5f9;
  border-radius: 1px;
  transition: transform 0.25s, opacity 0.25s;
}
.menu-toggle--active .menu-toggle__bar:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.menu-toggle--active .menu-toggle__bar:nth-child(2) { opacity: 0; }
.menu-toggle--active .menu-toggle__bar:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 999;
}
.sidebar-overlay--visible { display: block; }

/* ── Responsive ── */
@media (max-width: 768px) {
  .layout { grid-template-columns: 1fr; }
  .menu-toggle { display: flex; }
  .sidebar {
    display: flex;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 1000;
    width: var(--sidebar-width);
    transform: translateX(-100%);
    transition: transform 0.25s ease;
  }
  .sidebar--open { transform: translateX(0); }
  .top-bar__left { padding-left: 44px; }
  .breadcrumb { display: none; }
  .content { padding: 20px 16px; }
  .module-grid { grid-template-columns: 1fr; }
  .auth-card { padding: 28px 20px; }
  .page-header { flex-direction: column; gap: 16px; }
  .quiz-submit-row { flex-direction: column; gap: 12px; }
  .result-hero { padding: 24px 20px; }
  .result-hero__score { font-size: 56px; }
}
