/* ═══════════════════════════════════════════════════════════════
   FORMATION SMTP — APP.CSS
   Sidebar, Quiz, IDE, Simulator, Sort Exercise, Progress
   ═══════════════════════════════════════════════════════════════ */

/* ─── HAMBURGER BUTTON ──────────────────────────────────── */
#sb-hamburger {
  position: fixed; top: 12px; left: 14px; z-index: 400;
  width: 38px; height: 38px; border-radius: 8px;
  background: rgba(20,20,30,.9); backdrop-filter: blur(8px);
  cursor: pointer; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 4px;
  border: 1px solid rgba(255,255,255,.08);
  transition: background .2s ease, border-color .2s ease;
}
#sb-hamburger:focus-visible { outline: 2px solid #00d4ff; outline-offset: 2px; }

/* Push topbar content right so the hamburger doesn't overlap */
nav.topbar { padding-left: 65px; }
#sb-hamburger:hover { border-color: #00d4ff; background: rgba(0,212,255,.1); }
#sb-hamburger span {
  display: block; width: 18px; height: 2px; background: #e2e8f0; border-radius: 2px;
  transition: background .2s ease;
}

/* ─── SIDEBAR ───────────────────────────────────────────── */
#smtp-sidebar {
  position: fixed; top: 0; left: 0; bottom: 0; width: 300px;
  background: #0d0d14; border-right: 1px solid #2a2a3e;
  z-index: 300; transform: translateX(-100%); transition: transform .3s ease;
  overflow-y: auto; display: flex; flex-direction: column;
}
#smtp-sidebar.open { transform: translateX(0); }

#sb-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,.5); z-index: 250;
  opacity: 0; pointer-events: none; transition: .3s;
}
#sb-overlay.open { opacity: 1; pointer-events: all; }

.sb-header {
  padding: 16px 20px; display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid #2a2a3e;
}
.sb-brand { font-weight: 800; font-size: 1rem; color: #fff; }
.sb-close {
  background: none; border: none; color: #94a3b8; font-size: 1.5rem;
  cursor: pointer; line-height: 1;
}
.sb-close:hover { color: #fff; }

.sb-progress { padding: 16px 20px; border-bottom: 1px solid #2a2a3e; }
.sb-progress-bar {
  height: 6px; background: #1a1a2e; border-radius: 3px; overflow: hidden;
}
.sb-progress-fill {
  height: 100%; background: linear-gradient(90deg, #00d4ff, #7c3aed);
  border-radius: 3px; transition: width .5s ease;
}
.sb-progress-text {
  font-size: .75rem; color: #94a3b8; margin-top: 6px; text-align: center;
}

.sb-nav-links { padding: 12px 20px; border-bottom: 1px solid #2a2a3e; }
.sb-nav-links a {
  display: block; padding: 6px 0; color: #94a3b8; font-size: .85rem;
  text-decoration: none; transition: .2s;
}
.sb-nav-links a:hover { color: #00d4ff; }
.sb-nav-links.sb-bottom { margin-top: auto; border-top: 1px solid #2a2a3e; border-bottom: none; }
.sb-nav-links a.current { color: #00d4ff; font-weight: 600; }
.sb-home { font-weight: 600; }

.sb-week { padding: 12px 20px; border-bottom: 1px solid rgba(255,255,255,.03); }
.sb-week-title {
  font-size: .7rem; text-transform: uppercase; letter-spacing: 2px;
  color: var(--wc, #00d4ff); font-weight: 700; margin-bottom: 6px;
}

.sb-ch {
  display: flex; align-items: center; gap: 10px; padding: 7px 8px;
  border-radius: 6px; font-size: .85rem; color: #94a3b8;
  text-decoration: none; transition: background .15s ease, color .15s ease;
}
.sb-ch:hover { background: rgba(255,255,255,.04); color: #e2e8f0; }
.sb-ch.current { background: rgba(0,212,255,.08); color: #00d4ff; }
.sb-ch:focus-visible { outline: 2px solid #00d4ff; outline-offset: 1px; }
.sb-ch.done .sb-ch-status { background: #10b981; color: #fff; }
.sb-ch-status {
  flex-shrink: 0;
  width: 24px; height: 24px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: .7rem; font-weight: 700;
  background: #1a1a2e; color: #94a3b8;
}
.sb-ch-title { flex: 1; min-width: 0; }

/* ─── CHAPTER COMPLETE BUTTON ───────────────────────────── */
.ch-complete-wrap { text-align: center; margin-top: 40px; padding-top: 30px; border-top: 1px dashed #2a2a3e; }
.ch-complete-btn {
  padding: 12px 28px; border-radius: 8px; border: 1px solid #2a2a3e;
  background: rgba(255,255,255,.04); color: #94a3b8;
  font-size: .95rem; cursor: pointer; transition: .3s;
  font-family: inherit;
}
.ch-complete-btn:hover { border-color: #10b981; color: #10b981; background: rgba(16,185,129,.05); }
.ch-complete-btn.done {
  background: rgba(16,185,129,.1); border-color: #10b981; color: #10b981; font-weight: 600;
}

/* ═══════════════════════════════════════════════════════════
   QUIZ STYLES
   ═══════════════════════════════════════════════════════════ */
.quiz-box {
  background: #12121a; border: 1px solid #2a2a3e; border-radius: 14px;
  padding: 30px; margin: 30px 0;
}
.quiz-header {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 10px; margin-bottom: 15px;
}
.quiz-title { font-weight: 700; color: #fff; font-size: 1.1rem; }
.quiz-counter { font-size: .85rem; color: #94a3b8; }
.quiz-prev-score { font-size: .75rem; color: #f59e0b; }

.quiz-progress-bar {
  height: 4px; background: #1a1a2e; border-radius: 2px; margin-bottom: 25px; overflow: hidden;
}
.quiz-progress-fill {
  height: 100%; background: linear-gradient(90deg, #00d4ff, #7c3aed); transition: width .3s;
  border-radius: 2px;
}

.quiz-question {
  font-size: 1.1rem; color: #e2e8f0; margin-bottom: 20px; line-height: 1.6;
}

.quiz-options { display: flex; flex-direction: column; gap: 10px; margin-bottom: 20px; }
.quiz-opt {
  display: flex; align-items: center; gap: 14px; padding: 14px 18px;
  background: #1a1a2e; border: 1px solid #2a2a3e; border-radius: 10px;
  color: #e2e8f0; cursor: pointer;
  transition: border-color .2s ease, background .2s ease;
  text-align: left; font-family: inherit; font-size: .95rem;
  width: 100%;
}
.quiz-opt:hover:not([disabled]) { border-color: #00d4ff; background: rgba(0,212,255,.05); }
.quiz-opt:focus-visible { outline: 2px solid #00d4ff; outline-offset: 2px; }
.quiz-opt[disabled] { cursor: default; }
.quiz-opt.correct { border-color: #10b981; background: rgba(16,185,129,.08); }
.quiz-opt.wrong { border-color: #ef4444; background: rgba(239,68,68,.08); }
.quiz-opt-letter {
  flex-shrink: 0;
  width: 28px; height: 28px; display: flex; align-items: center; justify-content: center;
  border-radius: 50%; background: rgba(255,255,255,.06); font-weight: 700; font-size: .8rem;
}
.quiz-opt-text { flex: 1; min-width: 0; }
.quiz-opt.correct .quiz-opt-letter { background: #10b981; color: #fff; }
.quiz-opt.wrong .quiz-opt-letter { background: #ef4444; color: #fff; }

.quiz-explanation {
  padding: 15px 20px; border-radius: 10px; margin-bottom: 20px;
  font-size: .9rem; line-height: 1.6;
}
.quiz-explanation.correct { background: rgba(16,185,129,.08); border-left: 3px solid #10b981; }
.quiz-explanation.wrong { background: rgba(239,68,68,.08); border-left: 3px solid #ef4444; }

.quiz-nav { display: flex; justify-content: space-between; gap: 12px; }
.quiz-nav-btn {
  padding: 10px 20px; border-radius: 8px; border: 1px solid #2a2a3e;
  background: rgba(255,255,255,.04); color: #94a3b8; cursor: pointer;
  font-family: inherit; font-size: .9rem; transition: .2s;
}
.quiz-nav-btn:hover:not([disabled]) { border-color: #00d4ff; color: #e2e8f0; }
.quiz-nav-btn[disabled] { opacity: .3; cursor: default; }
.quiz-nav-btn.primary { background: rgba(0,212,255,.1); color: #00d4ff; border-color: rgba(0,212,255,.3); }
.quiz-nav-btn.primary:hover:not([disabled]) { background: #00d4ff; color: #000; }

/* Quiz Results */
.quiz-results { text-align: center; }
.quiz-result-emoji { font-size: 3.5rem; margin-bottom: 10px; }
.quiz-result-score { font-size: 2.5rem; font-weight: 800; color: #fff; }
.quiz-result-pct { font-size: 1.2rem; color: #94a3b8; margin-bottom: 10px; }
.quiz-result-msg { color: #e2e8f0; margin-bottom: 25px; font-size: 1rem; }
.quiz-result-details { text-align: left; margin-bottom: 20px; }
.quiz-result-item {
  display: flex; align-items: center; gap: 10px; padding: 8px 12px;
  border-radius: 6px; margin-bottom: 4px; font-size: .85rem;
}
.quiz-result-item.correct { background: rgba(16,185,129,.06); color: #10b981; }
.quiz-result-item.wrong { background: rgba(239,68,68,.06); color: #ef4444; }
.quiz-result-icon { font-weight: 700; font-size: 1rem; min-width: 20px; }

/* ═══════════════════════════════════════════════════════════
   IDE / SANDBOX STYLES
   ═══════════════════════════════════════════════════════════ */
.ide-box {
  background: #0d1117; border: 1px solid #2a2a3e; border-radius: 14px;
  overflow: hidden; margin: 30px 0;
}
.ide-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px; background: rgba(255,255,255,.03);
  border-bottom: 1px solid #2a2a3e;
}
.ide-title { font-weight: 700; color: #fff; font-size: 1rem; }
.ide-lang {
  padding: 3px 10px; border-radius: 4px; font-size: .7rem;
  background: rgba(0,212,255,.1); color: #00d4ff; font-weight: 700;
  letter-spacing: 1px;
}

.ide-instructions {
  padding: 18px 20px; color: #e2e8f0; font-size: .92rem;
  line-height: 1.6; background: rgba(0,212,255,.03);
  border-bottom: 1px solid #2a2a3e;
}

.ide-editor-wrap {
  display: flex; position: relative;
}
.ide-line-numbers {
  flex-shrink: 0;
  width: 40px; padding: 12px 0; text-align: right;
  font-family: 'Cascadia Code','Fira Code',Consolas,monospace;
  font-size: .82rem; color: #4a4a5e; line-height: 1.7;
  background: rgba(0,0,0,.2); user-select: none;
  /* overflow:hidden breaks scroll sync; use overflow-y:auto and hide scrollbar instead */
  overflow-y: auto; scrollbar-width: none;
}
.ide-line-numbers::-webkit-scrollbar { display: none; }
.ide-line-numbers div { padding: 0 8px 0 0; }
.ide-editor {
  flex: 1; padding: 12px 16px; border: none; background: transparent;
  color: #e2e8f0; font-family: 'Cascadia Code','Fira Code',Consolas,monospace;
  font-size: .88rem; line-height: 1.7; resize: vertical;
  min-height: 200px; max-height: 600px;
  outline: none; tab-size: 2; width: 100%;
}
.ide-editor::placeholder { color: #3a3a4e; }
.ide-editor:focus-visible { outline: 1px solid rgba(0,212,255,.3); outline-offset: -1px; }

.ide-toolbar {
  display: flex; gap: 10px; padding: 12px 20px;
  border-top: 1px solid #2a2a3e; background: rgba(255,255,255,.02);
}
.ide-btn {
  padding: 8px 16px; border-radius: 6px; border: 1px solid #2a2a3e;
  font-family: inherit; font-size: .85rem; cursor: pointer;
  transition: background .2s ease, color .2s ease, border-color .2s ease;
}
.ide-btn:focus-visible { outline: 2px solid #00d4ff; outline-offset: 2px; }
.ide-btn.run { background: rgba(0,212,255,.1); color: #00d4ff; border-color: rgba(0,212,255,.3); }
.ide-btn.run:hover { background: #00d4ff; color: #000; }
.ide-btn.hint { background: rgba(245,158,11,.08); color: #f59e0b; border-color: rgba(245,158,11,.2); }
.ide-btn.hint:hover { background: rgba(245,158,11,.2); }
.ide-btn.reset { background: rgba(255,255,255,.04); color: #94a3b8; }
.ide-btn.reset:hover { color: #fff; border-color: #94a3b8; }

.ide-hint-area { padding: 0 20px; }
.ide-hint {
  padding: 10px 14px; margin: 8px 0; border-radius: 8px;
  background: rgba(245,158,11,.06); border-left: 3px solid #f59e0b;
  font-size: .88rem; color: #fbbf24;
}

.ide-results { padding: 20px; border-top: 1px solid #2a2a3e; }
.ide-score {
  font-size: 1.2rem; font-weight: 700; margin-bottom: 15px; padding: 12px 18px;
  border-radius: 8px; text-align: center;
}
.ide-score.good { background: rgba(16,185,129,.1); color: #10b981; }
.ide-score.ok { background: rgba(245,158,11,.1); color: #f59e0b; }
.ide-score.bad { background: rgba(239,68,68,.1); color: #ef4444; }

.ide-checks { display: flex; flex-direction: column; gap: 6px; }
.ide-check {
  display: flex; align-items: center; gap: 10px; padding: 8px 12px;
  border-radius: 6px; font-size: .85rem;
}
.ide-check.pass { background: rgba(16,185,129,.05); color: #10b981; }
.ide-check.fail { background: rgba(239,68,68,.05); color: #ef4444; }
.ide-check-icon { font-weight: 700; font-size: 1.1rem; min-width: 18px; }
.ide-check-pts { margin-left: auto; font-weight: 600; font-size: .8rem; opacity: .7; }

/* ═══════════════════════════════════════════════════════════
   SMTP SIMULATOR STYLES
   ═══════════════════════════════════════════════════════════ */
.sim-box {
  background: #0d1117; border: 1px solid #2a2a3e; border-radius: 14px;
  overflow: hidden; margin: 30px 0;
}
.sim-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px; background: rgba(16,185,129,.05);
  border-bottom: 1px solid #2a2a3e;
}
.sim-title { font-weight: 700; color: #fff; }
.sim-status { font-size: .8rem; color: #10b981; }

.sim-terminal {
  padding: 16px 20px; min-height: 200px; max-height: 400px;
  overflow-y: auto; font-family: 'Cascadia Code','Fira Code',Consolas,monospace;
  font-size: .84rem; line-height: 1.8;
}
.sim-line { padding: 2px 0; }
.sim-line.server { color: #10b981; }
.sim-line.client { color: #00d4ff; }
.sim-line.error { color: #ef4444; }
.sim-prefix { font-weight: 700; }

.sim-input-wrap {
  display: flex; align-items: center; gap: 8px; padding: 12px 20px;
  border-top: 1px solid #2a2a3e; background: rgba(0,0,0,.2);
  flex-wrap: wrap;
}
.sim-input-prefix {
  font-family: 'Cascadia Code','Fira Code',Consolas,monospace;
  color: #00d4ff; font-weight: 700; font-size: .84rem; white-space: nowrap;
}
.sim-input {
  flex: 1 1 200px; min-width: 0; padding: 8px 12px;
  border: 1px solid #2a2a3e; border-radius: 6px;
  background: #1a1a2e; color: #e2e8f0;
  font-family: 'Cascadia Code','Fira Code',Consolas,monospace;
  font-size: .88rem; outline: none;
}
.sim-input:focus { border-color: #00d4ff; }
.sim-submit {
  padding: 8px 16px; border: 1px solid rgba(0,212,255,.3); border-radius: 6px;
  background: rgba(0,212,255,.1); color: #00d4ff; cursor: pointer;
  font-family: inherit; font-size: .85rem;
  transition: background .2s ease, color .2s ease;
}
.sim-submit:hover { background: #00d4ff; color: #000; }
.sim-submit:focus-visible { outline: 2px solid #00d4ff; outline-offset: 2px; }

.sim-hint-btn { padding: 8px 20px; }
.sim-hint-btn button {
  background: none; border: none; color: #f59e0b; cursor: pointer;
  font-size: .85rem; font-family: inherit;
}
.sim-hint-area { padding: 0 20px 12px; }

.sim-complete {
  padding: 25px 20px; text-align: center; font-size: 1.1rem;
  color: #10b981; font-weight: 600;
}

/* ═══════════════════════════════════════════════════════════
   DRAG & DROP SORT STYLES
   ═══════════════════════════════════════════════════════════ */
.sort-box {
  background: #12121a; border: 1px solid #2a2a3e; border-radius: 14px;
  padding: 25px; margin: 30px 0;
}
.sort-title { font-weight: 700; color: #fff; font-size: 1.1rem; margin-bottom: 8px; }
.sort-instruction { color: #94a3b8; font-size: .9rem; margin-bottom: 18px; }

.sort-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 20px; }
.sort-item {
  display: flex; align-items: center; gap: 12px; padding: 12px 16px;
  background: #1a1a2e; border: 1px solid #2a2a3e; border-radius: 8px;
  cursor: grab; transition: opacity .15s ease, border-color .15s ease, background .15s ease;
  user-select: none;
}
.sort-item:active { cursor: grabbing; }
.sort-item:focus {
  outline: 2px solid #00d4ff;
  outline-offset: 2px;
}
.sort-item:focus:not(:focus-visible) { outline: none; }
.sort-item.dragging { opacity: .4; }
.sort-item.drop-target {
  border-color: #00d4ff;
  background: rgba(0,212,255,.08);
  box-shadow: 0 0 0 2px rgba(0,212,255,.25) inset;
}
.sort-item.selected {
  border-color: #f97316;
  background: rgba(249,115,22,.08);
  box-shadow: 0 0 0 2px rgba(249,115,22,.25) inset;
}
.sort-item.correct { border-color: #10b981; background: rgba(16,185,129,.06); }
.sort-item.wrong { border-color: #ef4444; background: rgba(239,68,68,.06); }
.sort-instruction kbd {
  display: inline-block;
  padding: 1px 6px;
  background: #2a2a3e;
  border: 1px solid #3a3a4e;
  border-radius: 4px;
  font-family: 'Consolas','Monaco',monospace;
  font-size: .8rem;
  color: #cbd5e1;
}
.sort-handle { flex-shrink: 0; color: #4a4a5e; font-size: 1.2rem; cursor: grab; }
.sort-num {
  flex-shrink: 0;
  width: 24px; height: 24px; display: flex; align-items: center; justify-content: center;
  border-radius: 50%; background: rgba(0,212,255,.1); color: #00d4ff;
  font-size: .75rem; font-weight: 700;
}
.sort-text {
  font-family: 'Cascadia Code','Fira Code',Consolas,monospace;
  font-size: .88rem; color: #e2e8f0;
}

.sort-actions { display: flex; gap: 10px; }
.sort-result {
  margin-top: 15px; padding: 15px 18px; border-radius: 10px;
  font-size: .95rem;
}
.sort-result.pass { background: rgba(16,185,129,.08); color: #10b981; border-left: 3px solid #10b981; }
.sort-result.fail { background: rgba(239,68,68,.08); color: #ef4444; border-left: 3px solid #ef4444; }
.sort-expl { margin-top: 10px; font-size: .85rem; color: #94a3b8; }

/* ─── RESPONSIVE ────────────────────────────────────────── */
@media (max-width: 900px) {
  .quiz-box { padding: 20px; }
  .sort-box { padding: 20px; }
  .ide-instructions, .ide-toolbar { padding-left: 14px; padding-right: 14px; }
  .sim-terminal, .sim-input-wrap { padding-left: 14px; padding-right: 14px; }
}

@media (max-width: 600px) {
  #smtp-sidebar { width: 85vw; }
  .quiz-box, .ide-box, .sim-box, .sort-box { margin: 20px 0; border-radius: 10px; }
  .quiz-box { padding: 18px; }
  .sort-box { padding: 16px; }
  .ide-editor { min-height: 150px; font-size: .82rem; }
  .ide-line-numbers { font-size: .78rem; }
  .sim-terminal { max-height: 250px; font-size: .78rem; }
  .quiz-opt { padding: 12px 14px; font-size: .88rem; }
  .quiz-opt-letter { width: 24px; height: 24px; font-size: .75rem; }
  .quiz-nav { flex-direction: column-reverse; }
  .quiz-nav-btn { width: 100%; }
  nav.topbar { padding-left: 60px; flex-wrap: wrap; }
  .ch-complete-btn { width: 100%; }
}

/* Reduced-motion users: disable animations entirely. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001s !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001s !important;
    scroll-behavior: auto !important;
  }
}
