/* ===========================
   K8S Lab – styles.css
   Author: HuyLN
   =========================== */

/* ── TOKENS & RESET ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* Light theme – main */
  --bg-page:       #f4f6fa;
  --bg-sidebar:    #0f172a;
  --bg-card:       #ffffff;
  --bg-hero:       linear-gradient(135deg, #e8f0fe 0%, #f0fdf4 100%);
  --bg-table-head: #f1f5f9;
  --bg-info-box:   #eff6ff;

  --text-primary:   #0f172a;
  --text-secondary: #475569;
  --text-muted:     #94a3b8;
  --text-sidebar:   #cbd5e1;
  --text-sidebar-active: #ffffff;

  --accent:         #2563eb;
  --accent-light:   #dbeafe;
  --accent-green:   #16a34a;
  --accent-green-light: #dcfce7;

  --border:         #e2e8f0;
  --border-sidebar: #1e293b;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 24px;

  --shadow-sm:   0 1px 3px rgba(0,0,0,.08);
  --shadow-md:   0 4px 16px rgba(0,0,0,.10);
  --shadow-lg:   0 8px 32px rgba(0,0,0,.14);

  --sidebar-w: 280px;
  --topbar-h: 60px;
  --bottom-nav-h: 56px;

  /* Dark theme – code blocks */
  --code-bg:        #0d1117;
  --code-bg-header: #161b22;
  --code-text:      #e6edf3;
  --code-comment:   #8b949e;
  --code-keyword:   #ff7b72;
  --code-string:    #a5d6ff;
  --code-accent:    #79c0ff;
  --code-border:    #30363d;
  --code-copy-btn:  #21262d;
  --code-copy-hover: #30363d;
}

html { scroll-behavior: smooth; }

body {
  font-family: 'Sora', 'Segoe UI', sans-serif;
  background: var(--bg-page);
  color: var(--text-primary);
  display: flex;
  min-height: 100vh;
  overflow-x: hidden;
}

/* ── SIDEBAR ── */
.sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--bg-sidebar);
  display: flex;
  flex-direction: column;
  z-index: 200;
  transform: translateX(0);
  transition: transform .3s cubic-bezier(.4,0,.2,1);
  border-right: 1px solid var(--border-sidebar);
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border-sidebar);
  flex-shrink: 0;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
}
.logo-icon {
  font-size: 24px;
  filter: drop-shadow(0 0 8px #3b82f6aa);
}
.logo-text {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 20px;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.5px;
}
.logo-accent { color: #60a5fa; }

.sidebar-close {
  display: none;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 18px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  transition: color .2s, background .2s;
}
.sidebar-close:hover { color: #fff; background: var(--border-sidebar); }

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 16px 12px;
  scrollbar-width: thin;
  scrollbar-color: #334155 transparent;
}

.nav-section-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 1.5px;
  color: #475569;
  padding: 0 8px 10px;
}

.lesson-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.lesson-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background .2s, color .2s;
  color: var(--text-sidebar);
  position: relative;
}
.lesson-item:hover:not(.coming-soon) {
  background: #1e293b;
  color: #fff;
}
.lesson-item.active {
  background: var(--accent);
  color: #fff;
}
.lesson-item.coming-soon {
  opacity: .5;
  cursor: not-allowed;
}
.lesson-num {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  font-weight: 600;
  color: #60a5fa;
  min-width: 22px;
}
.lesson-item.active .lesson-num { color: #bfdbfe; }
.lesson-title {
  font-size: 13px;
  font-weight: 500;
  line-height: 1.4;
  flex: 1;
}
.badge-soon {
  font-size: 9px;
  font-weight: 600;
  background: #1e293b;
  color: #64748b;
  padding: 2px 6px;
  border-radius: 99px;
  letter-spacing: .5px;
  text-transform: uppercase;
}

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--border-sidebar);
  flex-shrink: 0;
}
.author-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: #1e293b;
  border-radius: var(--radius-md);
}
.author-avatar {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, #3b82f6, #8b5cf6);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 15px;
  flex-shrink: 0;
}
.author-name {
  font-weight: 600;
  color: #e2e8f0;
  font-size: 14px;
}
.author-role {
  font-size: 11px;
  color: #64748b;
  margin-top: 1px;
}

/* ── OVERLAY ── */
.overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.4);
  z-index: 150;
  backdrop-filter: blur(2px);
}
.overlay.active { display: block; }

/* ── MAIN WRAPPER ── */
.main-wrapper {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: margin-left .3s;
}

/* ── TOPBAR ── */
.topbar {
  position: sticky;
  top: 0;
  height: var(--topbar-h);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}

.hamburger {
  display: none;
  flex-direction: column;
  gap: 4px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  flex-shrink: 0;
}
.hamburger span {
  display: block;
  width: 20px; height: 2px;
  background: var(--text-primary);
  border-radius: 2px;
  transition: .2s;
}

.topbar-breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
}
.breadcrumb-home {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 500;
  white-space: nowrap;
}
.breadcrumb-sep { color: var(--text-muted); font-size: 12px; }
.breadcrumb-current {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-meta {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}
.meta-tag {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  font-weight: 600;
  background: var(--accent-light);
  color: var(--accent);
  padding: 3px 10px;
  border-radius: 99px;
  border: 1px solid #bfdbfe;
}

/* ── CONTENT AREA ── */
.content-area {
  flex: 1;
  padding: 32px 48px 24px;
  max-width: 960px;
  width: 100%;
  margin: 0 auto;
  padding-bottom: calc(var(--bottom-nav-h) + 40px);
}

/* ── LESSON VISIBILITY ── */
.lesson-content { display: none; }
.lesson-content.active { display: block; }
.coming-soon-page { display: none; }
.coming-soon-page.visible { display: flex; align-items: center; justify-content: center; min-height: 60vh; }

.coming-soon-content {
  text-align: center;
  padding: 60px 40px;
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  border: 2px dashed var(--border);
}
.coming-soon-icon { font-size: 64px; margin-bottom: 16px; }
.coming-soon-content h2 { font-size: 24px; color: var(--text-primary); margin-bottom: 10px; }
.coming-soon-content p { color: var(--text-secondary); }

/* ── LESSON HERO ── */
.lesson-hero {
  background: var(--bg-hero);
  border-radius: var(--radius-xl);
  padding: 36px 40px;
  margin-bottom: 40px;
  border: 1px solid #dbeafe;
  position: relative;
  overflow: hidden;
}
.lesson-hero::before {
  content: '⎈';
  position: absolute;
  right: 32px; top: 50%;
  transform: translateY(-50%);
  font-size: 100px;
  opacity: .06;
  pointer-events: none;
  line-height: 1;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-light);
  padding: 4px 12px;
  border-radius: 99px;
  margin-bottom: 14px;
  border: 1px solid #bfdbfe;
  letter-spacing: .5px;
}

.lesson-h1 {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 32px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
  margin-bottom: 10px;
  letter-spacing: -0.5px;
}

.lesson-subtitle {
  font-size: 15px;
  color: var(--text-secondary);
  margin-bottom: 24px;
  line-height: 1.6;
}

.lesson-info-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.info-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255,255,255,.8);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  font-size: 13px;
}
.chip-label {
  color: var(--text-muted);
  font-weight: 500;
}
.chip-val {
  color: var(--text-primary);
  font-weight: 600;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
}

/* ── NODE TABLE ── */
.node-table-wrap {
  margin-top: 24px;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border);
}
.node-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  background: var(--bg-card);
}
.node-table th {
  background: var(--bg-table-head);
  font-weight: 600;
  color: var(--text-secondary);
  padding: 10px 16px;
  text-align: left;
  font-size: 12px;
  letter-spacing: .3px;
  text-transform: uppercase;
}
.node-table td {
  padding: 10px 16px;
  border-top: 1px solid var(--border);
  color: var(--text-primary);
  vertical-align: middle;
}
.node-table tr:hover td { background: #fafbfc; }

.role-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 99px;
  letter-spacing: .3px;
}
.role-badge.control {
  background: #ede9fe;
  color: #7c3aed;
  border: 1px solid #ddd6fe;
}
.role-badge.worker {
  background: var(--accent-green-light);
  color: var(--accent-green);
  border: 1px solid #bbf7d0;
}

/* ── LESSON SECTIONS ── */
.lesson-section {
  margin-bottom: 40px;
}

.lesson-section h2 {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--border);
  letter-spacing: -0.3px;
}

.lesson-section h3 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 24px 0 10px;
}

.lesson-section p {
  font-size: 14.5px;
  color: var(--text-secondary);
  line-height: 1.75;
  margin-bottom: 12px;
}

.lesson-section ul,
.lesson-section ol {
  padding-left: 20px;
  margin-bottom: 12px;
}

.lesson-section li {
  font-size: 14.5px;
  color: var(--text-secondary);
  line-height: 1.7;
  margin-bottom: 4px;
}

.goal-list {
  list-style: none;
  padding-left: 0;
}
.goal-list li {
  padding: 8px 12px 8px 32px;
  position: relative;
  border-radius: var(--radius-sm);
  margin-bottom: 4px;
}
.goal-list li:hover { background: #f8fafc; }
.goal-list li::before {
  content: '✓';
  position: absolute;
  left: 10px;
  color: var(--accent-green);
  font-weight: 700;
  font-size: 13px;
}

code {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12.5px;
  background: #f1f5f9;
  color: #c026d3;
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid #e2e8f0;
}

strong { color: var(--text-primary); }

/* ── CODE DESCRIPTION ── */
.code-desc {
  font-size: 13.5px !important;
  color: var(--text-secondary) !important;
  margin-bottom: 8px !important;
  padding: 8px 12px;
  background: #f8fafc;
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  line-height: 1.65 !important;
}
.code-desc code {
  background: rgba(37,99,235,.1);
  color: var(--accent);
  border-color: #bfdbfe;
}

/* ── CODE BLOCKS (DARK THEME) ── */
.code-block {
  background: var(--code-bg);
  border: 1px solid var(--code-border);
  border-radius: var(--radius-md);
  overflow: hidden;
  margin-bottom: 20px;
  box-shadow: var(--shadow-md);
}

.code-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  background: var(--code-bg-header);
  border-bottom: 1px solid var(--code-border);
}

.code-lang {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  font-weight: 600;
  color: #7ee787;
  letter-spacing: .5px;
  text-transform: uppercase;
}

.copy-btn {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  font-weight: 500;
  color: #8b949e;
  background: var(--code-copy-btn);
  border: 1px solid var(--code-border);
  padding: 3px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all .2s;
  letter-spacing: .3px;
}
.copy-btn:hover {
  background: var(--code-copy-hover);
  color: #e6edf3;
  border-color: #484f58;
}
.copy-btn.copied {
  background: #1a4731;
  color: #3fb950;
  border-color: #2ea043;
}

.code-block pre {
  margin: 0;
  padding: 18px 20px;
  overflow-x: auto;
  scrollbar-width: thin;
  scrollbar-color: #30363d transparent;
}

.code-block code {
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  line-height: 1.65;
  color: var(--code-text);
  background: none;
  border: none;
  padding: 0;
  white-space: pre;
  display: block;
}

/* ── COMPONENT GRID ── */
.component-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
  margin: 20px 0;
}

.component-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  transition: box-shadow .2s, transform .2s, border-color .2s;
}
.component-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
  border-color: #bfdbfe;
}
.comp-icon { font-size: 28px; margin-bottom: 10px; }
.comp-name {
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 8px;
}
.comp-desc {
  font-size: 12.5px;
  color: var(--text-secondary);
  line-height: 1.6;
}

/* ── INFO BOX ── */
.info-box {
  background: var(--bg-info-box);
  border: 1px solid #bfdbfe;
  border-radius: var(--radius-md);
  padding: 16px 20px;
  margin: 16px 0;
}
.info-box-title {
  font-weight: 700;
  font-size: 14px;
  color: var(--accent);
  margin-bottom: 12px;
}
.info-box .node-table-wrap {
  margin-top: 0;
  border-color: #bfdbfe;
}
.info-box .node-table th { background: #dbeafe; }

/* ── QUIZ ── */
.quiz-container {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.quiz-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  transition: box-shadow .2s;
}
.quiz-item:hover { box-shadow: var(--shadow-sm); }

.quiz-q {
  font-size: 14.5px !important;
  font-weight: 600 !important;
  color: var(--text-primary) !important;
  margin-bottom: 14px !important;
  background: none !important;
  border: none !important;
  border-radius: 0 !important;
  padding: 0 !important;
  line-height: 1.5 !important;
}

.quiz-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.quiz-opt {
  font-family: 'Sora', sans-serif;
  font-size: 13px;
  font-weight: 500;
  padding: 8px 16px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  background: #f8fafc;
  color: var(--text-primary);
  cursor: pointer;
  transition: all .2s;
  text-align: left;
}
.quiz-opt:hover:not(:disabled) {
  border-color: var(--accent);
  background: var(--accent-light);
  color: var(--accent);
}
.quiz-opt.correct {
  background: var(--accent-green-light);
  border-color: var(--accent-green);
  color: var(--accent-green);
  font-weight: 700;
}
.quiz-opt.incorrect {
  background: #fef2f2;
  border-color: #ef4444;
  color: #dc2626;
  text-decoration: line-through;
}
.quiz-opt:disabled { cursor: default; }

.quiz-explain {
  margin-top: 12px;
  padding: 10px 14px;
  background: var(--accent-green-light);
  border: 1px solid #bbf7d0;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  color: #166534;
  line-height: 1.6;
}
.quiz-explain.hidden { display: none; }

/* ── BOTTOM NAV ── */
.bottom-nav {
  position: sticky;
  bottom: 0;
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 48px;
  height: var(--bottom-nav-h);
  box-shadow: 0 -2px 12px rgba(0,0,0,.06);
  z-index: 50;
}

.nav-btn {
  font-family: 'Sora', sans-serif;
  font-size: 13px;
  font-weight: 600;
  padding: 8px 20px;
  border-radius: var(--radius-md);
  border: 1.5px solid var(--border);
  background: var(--bg-card);
  color: var(--text-primary);
  cursor: pointer;
  transition: all .2s;
}
.nav-btn:hover:not(:disabled) {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.nav-btn:disabled {
  opacity: .35;
  cursor: not-allowed;
}

.nav-indicator {
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
}

/* ── COPY TOAST ── */
.copy-toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #166534;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  padding: 10px 24px;
  border-radius: 99px;
  opacity: 0;
  transition: all .3s;
  z-index: 9999;
  pointer-events: none;
  box-shadow: var(--shadow-md);
}
.copy-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ── RESPONSIVE ── */
@media (max-width: 900px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .sidebar-close { display: flex; }
  .hamburger { display: flex; }
  .main-wrapper { margin-left: 0; }
  .content-area { padding: 20px 20px; }
  .bottom-nav { padding: 0 20px; }
  .lesson-hero { padding: 24px 20px; }
  .lesson-h1 { font-size: 24px; }
  .topbar { padding: 0 16px; }
  .topbar-meta { display: none; }
  .component-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 600px) {
  .component-grid { grid-template-columns: 1fr; }
  .lesson-info-grid { flex-direction: column; }
  .quiz-opt { width: 100%; }
}
