/* ============================================================
   MERIK ACADEMY — LESSON PAGE
   ============================================================ */
:root {
  --primary:     #00bcd4;
  --navy:        #0d1b2a;
  --surface:     #ffffff;
  --border:      #e5e7eb;
  --text:        #1a1a2e;
  --text-muted:  #6b7280;
  --radius:      10px;
  --header-h:    52px;
  --mob-tabs-h:  48px;
}

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

body.lesson-body {
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: #0d1117;
  overflow: hidden;
  height: 100vh;
  color: var(--text);
}

/* ── Header ──────────────────────────────────────────────── */
.lesson-header {
  position: fixed; top: 0; left: 0; right: 0;
  height: var(--header-h);
  background: #11111b;
  border-bottom: 1px solid rgba(255,255,255,.07);
  display: flex; align-items: center;
  justify-content: space-between;
  padding: 0 14px; gap: 10px;
  z-index: 100;
}

.lesson-header-left {
  display: flex; align-items: center;
  gap: 10px; min-width: 0; flex: 1;
}

.lesson-back {
  width: 32px; height: 32px;
  border-radius: 8px;
  background: rgba(255,255,255,.07);
  border: 1px solid rgba(255,255,255,.1);
  color: rgba(255,255,255,.7);
  display: flex; align-items: center; justify-content: center;
  text-decoration: none; font-size: .85rem;
  transition: all .2s; flex-shrink: 0;
}
.lesson-back:hover { background: rgba(255,255,255,.14); color: #fff; }

.lesson-course-info { min-width: 0; }
.lesson-course-name {
  display: block; font-size: .7rem;
  color: rgba(255,255,255,.4);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.lesson-title-small {
  display: block; font-size: .85rem; font-weight: 600;
  color: #fff;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 220px;
}

.lesson-header-center {
  display: flex; flex-direction: column;
  align-items: center; gap: 4px; flex-shrink: 0;
}

.lesson-dots {
  display: flex; gap: 5px; align-items: center;
  max-width: 200px; overflow-x: auto; scrollbar-width: none;
}
.lesson-dots::-webkit-scrollbar { display: none; }

.lesson-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: rgba(255,255,255,.2);
  flex-shrink: 0; transition: all .2s;
  text-decoration: none;
}
.lesson-dot:hover  { background: rgba(255,255,255,.5); transform: scale(1.2); }
.lesson-dot.current { background: var(--primary); transform: scale(1.3); }

.lesson-counter {
  font-size: .68rem; color: rgba(255,255,255,.35);
  white-space: nowrap;
}

.lesson-header-right {
  display: flex; align-items: center;
  gap: 8px; flex-shrink: 0;
}

.lesson-completed-badge {
  display: flex; align-items: center; gap: 6px;
  font-size: .75rem; font-weight: 700; color: #10b981;
  background: rgba(16,185,129,.12);
  padding: 4px 10px; border-radius: 50px;
}

.lesson-nav-btn {
  display: flex; align-items: center; gap: 5px;
  padding: 7px 12px; border-radius: 8px;
  background: rgba(255,255,255,.07);
  border: 1px solid rgba(255,255,255,.1);
  color: rgba(255,255,255,.7);
  text-decoration: none; font-size: .8rem; font-weight: 600;
  transition: all .2s; white-space: nowrap;
}
.lesson-nav-btn:hover { background: rgba(255,255,255,.14); color: #fff; }
.lesson-nav-next {
  background: rgba(0,188,212,.15);
  border-color: rgba(0,188,212,.3);
  color: var(--primary);
}
.lesson-nav-next:hover { background: var(--primary); color: #fff; }

/* ── Main Layout ─────────────────────────────────────────── */
.lesson-layout {
  display: grid;
  grid-template-columns: 42% 6px 1fr;
  height: calc(100vh - var(--header-h));
  margin-top: var(--header-h);
  overflow: hidden;
}

/* ── Theory Panel ────────────────────────────────────────── */
.lesson-theory-panel {
  background: var(--surface);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

/* Lesson sidebar (drawer) */
.lesson-sidebar {
  position: absolute; top: 0; left: -280px;
  width: 280px; height: 100%;
  background: var(--navy);
  z-index: 50;
  transition: left .25s ease;
  display: flex; flex-direction: column;
  overflow-y: auto;
  box-shadow: 4px 0 20px rgba(0,0,0,.3);
}
.lesson-sidebar.open { left: 0; }

.lesson-sidebar-header {
  display: flex; align-items: center;
  justify-content: space-between;
  padding: 16px;
  border-bottom: 1px solid rgba(255,255,255,.07);
  font-size: .82rem; font-weight: 700; color: rgba(255,255,255,.7);
  flex-shrink: 0;
}
.sidebar-close-btn {
  background: none; border: none; color: rgba(255,255,255,.5);
  cursor: pointer; font-size: .9rem; transition: color .2s;
}
.sidebar-close-btn:hover { color: #fff; }

.lesson-nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px;
  text-decoration: none; color: rgba(255,255,255,.6);
  font-size: .83rem; transition: all .2s;
  border-bottom: 1px solid rgba(255,255,255,.04);
}
.lesson-nav-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.lesson-nav-item.active {
  background: rgba(0,188,212,.12);
  color: var(--primary);
  border-left: 3px solid var(--primary);
}
.lesson-nav-num {
  width: 22px; height: 22px; border-radius: 50%;
  background: rgba(255,255,255,.08);
  display: flex; align-items: center; justify-content: center;
  font-size: .72rem; font-weight: 700; flex-shrink: 0;
}
.lesson-nav-item.active .lesson-nav-num { background: var(--primary); color: #fff; }
.lesson-nav-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Theory content */
.lesson-theory-content {
  flex: 1; overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.theory-toolbar {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky; top: 0; z-index: 10;
}
.theory-tool-btn {
  width: 30px; height: 30px; border-radius: 7px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-muted); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: .8rem; transition: all .2s; flex-shrink: 0;
}
.theory-tool-btn:hover { border-color: var(--primary); color: var(--primary); }
.theory-lesson-title {
  font-weight: 700; font-size: .92rem; color: var(--text);
  flex: 1; min-width: 0; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap;
}
.theory-duration {
  font-size: .75rem; color: var(--text-muted);
  display: flex; align-items: center; gap: 4px;
  white-space: nowrap;
}

.theory-body {
  padding: 24px 28px 32px;
  font-size: .95rem;
  line-height: 1.75;
  color: var(--text);
}
.theory-body h2 { font-size: 1.3rem; font-weight: 700; margin: 24px 0 10px; color: var(--text); }
.theory-body h3 { font-size: 1.05rem; font-weight: 700; margin: 20px 0 8px; color: var(--text); }
.theory-body p  { margin-bottom: 14px; }
.theory-body pre {
  background: #1e1e2e; color: #cdd6f4;
  padding: 16px 20px; border-radius: var(--radius);
  font-family: 'Courier New', monospace;
  font-size: .85rem; overflow-x: auto;
  margin: 14px 0; border-left: 3px solid var(--primary);
}
.theory-body code {
  background: rgba(0,188,212,.1); color: var(--primary);
  padding: 2px 6px; border-radius: 4px;
  font-family: 'Courier New', monospace; font-size: .88em;
}
.theory-body pre code { background: none; color: inherit; padding: 0; }
.theory-body ul, .theory-body ol { padding-left: 20px; margin-bottom: 14px; }
.theory-body li { margin-bottom: 6px; }
.theory-body strong { font-weight: 700; color: var(--text); }
.theory-body em { font-style: italic; }
.theory-body blockquote {
  border-left: 4px solid var(--primary);
  padding: 12px 16px;
  background: rgba(0,188,212,.04);
  border-radius: 0 var(--radius) var(--radius) 0;
  margin: 14px 0; color: var(--text-muted);
}

/* Hint */
.lesson-hint-section { padding: 16px 28px 20px; }
.hint-btn {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 16px; border-radius: var(--radius);
  background: rgba(245,158,11,.08);
  border: 1.5px solid rgba(245,158,11,.3);
  color: #d97706; font-size: .85rem; font-weight: 600;
  cursor: pointer; transition: all .2s; font-family: inherit;
}
.hint-btn:hover { background: rgba(245,158,11,.14); }
.hint-content {
  margin-top: 10px; padding: 14px 16px;
  background: #fffbeb; border: 1px solid #fde68a;
  border-radius: var(--radius); font-size: .88rem;
  color: #92400e; line-height: 1.6;
  display: flex; gap: 10px; align-items: flex-start;
}

/* Bottom nav */
.theory-nav-bottom {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 28px 24px; gap: 12px;
  border-top: 1px solid var(--border); margin-top: 12px;
}

/* ── Divider ─────────────────────────────────────────────── */
.lesson-divider {
  background: rgba(255,255,255,.06);
  cursor: col-resize;
  transition: background .2s;
  position: relative;
}
.lesson-divider:hover { background: var(--primary); }
.lesson-divider::after {
  content: '⋮⋮';
  position: absolute; top: 50%; left: 50%;
  transform: translate(-50%,-50%);
  color: rgba(255,255,255,.3);
  font-size: .7rem; letter-spacing: -2px;
  pointer-events: none;
}

/* ── Code Panel ──────────────────────────────────────────── */
.lesson-code-panel {
  background: #1e1e2e;
  display: flex; flex-direction: column;
  overflow: hidden;
}

.lesson-code-tabs {
  display: flex; align-items: center;
  background: #11111b;
  border-bottom: 1px solid rgba(255,255,255,.07);
  flex-shrink: 0; overflow-x: auto; scrollbar-width: none;
}
.lesson-code-tabs::-webkit-scrollbar { display: none; }

.lesson-tab {
  display: flex; align-items: center; gap: 6px;
  padding: 10px 16px;
  background: none; border: none;
  border-bottom: 2px solid transparent;
  color: rgba(255,255,255,.4);
  font-size: .8rem; font-weight: 600; cursor: pointer;
  transition: all .2s; white-space: nowrap;
  font-family: inherit;
}
.lesson-tab:hover { color: rgba(255,255,255,.8); }
.lesson-tab.active { color: #fff; border-bottom-color: var(--primary); }

.lang-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }

.lesson-tab-spacer { flex: 1; }

.lesson-tab-action {
  width: 32px; height: 32px;
  margin: 6px 4px;
  border-radius: 7px;
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.1);
  color: rgba(255,255,255,.55); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: .8rem; transition: all .2s; flex-shrink: 0;
}
.lesson-tab-action:hover { background: rgba(255,255,255,.14); color: #fff; }

/* Editors */
.lesson-editors {
  flex: 1; display: flex; flex-direction: column;
  overflow: hidden; min-height: 0;
}
.lesson-editor-wrap { display: none; flex: 1; overflow: hidden; }
.lesson-editor-wrap.active { display: flex; flex-direction: column; }
.lesson-editor-wrap .CodeMirror {
  flex: 1; height: 100% !important;
  font-family: 'Courier New', monospace !important;
  font-size: 13px !important; line-height: 1.6 !important;
}

/* Preview */
.lesson-preview-wrap {
  display: flex; flex-direction: column;
  flex: 0 0 200px;
  border-top: 2px solid rgba(0,188,212,.3);
  background: #fff;
  min-height: 0;
}
.lesson-preview-bar {
  display: flex; align-items: center;
  justify-content: space-between;
  padding: 6px 10px;
  background: #11111b;
  border-bottom: 1px solid rgba(255,255,255,.07);
  font-size: .75rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .05em;
  color: rgba(255,255,255,.5); flex-shrink: 0;
}
.lesson-iframe {
  flex: 1; border: none; width: 100%; background: #fff;
}

/* Check / Mark buttons */
.check-btn, .mark-btn {
  display: flex; align-items: center; gap: 6px;
  padding: 5px 12px; border-radius: 7px;
  font-size: .78rem; font-weight: 700; cursor: pointer;
  border: none; transition: all .2s; font-family: inherit;
}
.check-btn { background: var(--primary); color: #fff; }
.check-btn:hover { background: #0097a7; }
.mark-btn { background: #10b981; color: #fff; }
.mark-btn:hover { background: #059669; }

/* Check result banner */
.check-result {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px;
  font-size: .85rem; font-weight: 600;
  border-top: 1px solid rgba(255,255,255,.07);
  flex-shrink: 0;
}
.check-success { background: rgba(16,185,129,.15); color: #10b981; }
.check-error   { background: rgba(239,68,68,.12);  color: #ef4444; }
.check-result code {
  background: rgba(255,255,255,.1); padding: 2px 6px;
  border-radius: 4px; font-size: .8rem;
}

/* ── Mobile ──────────────────────────────────────────────── */
.lesson-mobile-tabs {
  display: none;
  position: fixed; bottom: 0; left: 0; right: 0;
  height: var(--mob-tabs-h);
  background: #11111b;
  border-top: 1px solid rgba(255,255,255,.07);
  z-index: 100;
}
.lesson-mobile-tabs.visible { display: flex; }

.lm-tab {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 2px; padding: 6px 4px;
  font-size: .68rem; font-weight: 600;
  color: rgba(255,255,255,.4);
  background: none; border: none;
  border-top: 2px solid transparent;
  cursor: pointer; transition: all .2s; font-family: inherit;
}
.lm-tab.active { color: #fff; border-top-color: var(--primary); }
.lm-tab i { font-size: .9rem; }

@media (max-width: 768px) {
  body.lesson-body { overflow-y: auto; height: auto; }

  .lesson-title-small { max-width: 100px; }
  .lesson-dots { display: none; }
  .lesson-counter { display: none; }

  .lesson-layout {
    display: block;
    height: auto;
    margin-top: var(--header-h);
    padding-bottom: var(--mob-tabs-h);
  }

  .lesson-theory-panel {
    height: auto; min-height: 60vh;
  }
  .lesson-theory-panel.mobile-hidden { display: none; }

  .lesson-divider { display: none; }

  .lesson-code-panel {
    height: 100vh;
    display: none;
  }
  .lesson-code-panel.mobile-hidden { display: none !important; }
  .lesson-code-panel:not(.mobile-hidden) { display: flex; }

  .lesson-editors { flex: 0 0 50vh; }
  .lesson-preview-wrap { flex: 1; }

  .theory-body { padding: 16px 18px 24px; font-size: .9rem; }
  .theory-nav-bottom { padding: 12px 18px 20px; }
  .lesson-mobile-tabs.visible { display: flex; }
}

@media (max-width: 480px) {
  .lesson-header { padding: 0 8px; gap: 6px; }
  .lesson-nav-btn span { display: none; }
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── Task Panel ──────────────────────────────────────────────── */
.task-panel {
  border-top: 2px solid var(--primary);
  background: #f0fafa;
  flex-shrink: 0;
}

.task-panel-header {
  display: flex; align-items: center;
  justify-content: space-between;
  padding: 10px 20px 8px;
  border-bottom: 1px solid rgba(0,188,212,.15);
}

.task-panel-label {
  font-size: .75rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .07em;
  color: var(--primary); display: flex; align-items: center; gap: 6px;
}

.task-dot-nav {
  display: flex; gap: 6px; align-items: center;
  flex-wrap: wrap;
}

.task-dot-btn {
  width: 26px; height: 26px; border-radius: 50%;
  background: rgba(0,188,212,.12);
  border: 1.5px solid rgba(0,188,212,.3);
  color: var(--primary); font-size: .72rem; font-weight: 700;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: all .2s; flex-shrink: 0; font-family: inherit;
}
.task-dot-btn:hover { background: rgba(0,188,212,.22); }
.task-dot-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.task-dot-btn.passed { background: #10b981; border-color: #10b981; color: #fff; }
.task-dot-btn.passed.active { outline: 2px solid var(--primary); outline-offset: 2px; }

.task-body { padding: 16px 20px 18px; }

.task-item { display: flex; flex-direction: column; gap: 10px; }
.task-item.passed { opacity: .85; }

.task-num {
  font-size: .7rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .06em;
  color: var(--primary);
}
.task-num span { color: var(--text-muted); font-weight: 400; }

.task-instruction {
  font-size: .9rem; line-height: 1.65; color: var(--text);
}
.task-instruction code {
  background: rgba(0,188,212,.1); color: var(--primary);
  padding: 2px 6px; border-radius: 4px;
  font-family: 'Courier New', monospace; font-size: .85em;
}

.task-hint-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: var(--radius);
  background: rgba(245,158,11,.08);
  border: 1.5px solid rgba(245,158,11,.3);
  color: #d97706; font-size: .8rem; font-weight: 600;
  cursor: pointer; transition: all .2s; font-family: inherit;
  align-self: flex-start;
}
.task-hint-btn:hover { background: rgba(245,158,11,.16); }

.task-hint-content {
  padding: 12px 14px;
  background: #fffbeb; border: 1px solid #fde68a;
  border-radius: var(--radius); font-size: .85rem;
  color: #92400e; line-height: 1.6;
}

.task-fill-row {
  display: flex; gap: 8px; align-items: center;
}
.task-fill-input {
  flex: 1; padding: 8px 12px;
  border: 1.5px solid rgba(0,188,212,.35);
  border-radius: var(--radius);
  font-size: .9rem; font-family: inherit;
  background: #fff; color: var(--text);
  outline: none; transition: border-color .2s;
}
.task-fill-input:focus { border-color: var(--primary); }
.task-inline-check { padding: 8px 14px; flex-shrink: 0; }

.task-passed-badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: .8rem; font-weight: 700; color: #10b981;
  background: rgba(16,185,129,.1);
  padding: 5px 12px; border-radius: 50px;
  align-self: flex-start;
}

.task-next-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px; border-radius: var(--radius);
  background: var(--primary); color: #fff;
  border: none; font-size: .82rem; font-weight: 700;
  cursor: pointer; transition: background .2s; font-family: inherit;
  align-self: flex-start;
}
.task-next-btn:hover { background: #0097a7; }

@media (max-width: 768px) {
  .task-panel { border-top-width: 1px; }
  .task-body { padding: 12px 16px 16px; }
  .task-panel-header { padding: 8px 16px 6px; }
}
