/* ════════════════════════════════════════════════════════════════════════
   AWS DVA Security Notes — styles.css
   Modern Enterprise UI · Dark default · Light mode support
   ════════════════════════════════════════════════════════════════════════ */

/* ── CSS Tokens ── */
:root {
  --bg:           #09090b;
  --surface:      #111113;
  --card:         #18181b;
  --border:       #27272a;
  --border-light: #3f3f46;
  --text:         #fafafa;
  --muted:        #a1a1aa;
  --dim:          #52525b;
  --shadow:       0 1px 3px rgba(0,0,0,0.4);
  --shadow-md:    0 4px 12px rgba(0,0,0,0.5);
  --accent:       #6366f1;
  --accent2:      #818cf8;
  --accent3:      #a5b4fc;
  --green:        #22c55e;
  --amber:        #f59e0b;
  --coral:        #f97316;
  --pink:         #ec4899;
  --teal:         #14b8a6;
  --topbar-height: 40px;
}

.light, [data-theme="light"] {
  --bg:           #fafaf9;
  --surface:      #f4f4f5;
  --card:         #ffffff;
  --border:       #e4e4e7;
  --border-light: #d4d4d8;
  --text:         #09090b;
  --muted:        #52525b;
  --dim:          #a1a1aa;
  --shadow:       0 1px 3px rgba(0,0,0,0.06);
  --shadow-md:    0 4px 12px rgba(0,0,0,0.08);
  --green-text:   #15803d;
  --amber-text:   #b45309;
  --coral-text:   #c2410c;
  --pink-text:    #be185d;
  --teal-text:    #0f766e;
}

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

html { font-size: 14px; }

body {
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  transition: background-color 0.2s ease, color 0.2s ease;
  overflow-x: hidden;
}

/* ── Topbar ── */
.site-topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--topbar-height);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  z-index: 100;
}

.topbar-inner {
  display: flex;
  align-items: center;
  height: 100%;
  padding: 0 16px;
  gap: 12px;
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  flex-shrink: 0;
}

.topbar-logo-mark {
  background: var(--accent);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 5px;
  border-radius: 3px;
  letter-spacing: 0.04em;
}

.topbar-logo-text {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  display: none;
}

@media (min-width: 640px) { .topbar-logo-text { display: inline; } }

.topbar-breadcrumb {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1;
  overflow: hidden;
}

.topbar-bc-link {
  font-size: 12px;
  color: var(--muted);
  text-decoration: none;
  white-space: nowrap;
}
.topbar-bc-link:hover { color: var(--text); }

.topbar-bc-sep { font-size: 12px; color: var(--dim); }

.topbar-bc-current {
  font-size: 12px;
  color: var(--text);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-theme-toggle {
  background: none;
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 5px;
  padding: 4px 8px;
  cursor: pointer;
  font-size: 13px;
  transition: border-color .15s, color .15s;
  flex-shrink: 0;
}
.topbar-theme-toggle:hover { border-color: var(--accent); color: var(--text); }

.icon-light { display: none; }
.icon-dark  { display: inline; }
.light .icon-dark  { display: none; }
.light .icon-light { display: inline; }

.topbar-request {
  font-size: 11px;
  background: var(--accent);
  color: #fff;
  padding: 4px 10px;
  border-radius: 4px;
  text-decoration: none;
  flex-shrink: 0;
  font-weight: 500;
  transition: opacity .15s;
}
.topbar-request:hover { opacity: 0.85; }

/* ── App Layout ── */
.app-layout {
  display: flex;
  height: calc(100vh - var(--topbar-height));
  margin-top: var(--topbar-height);
}

/* ── Sidebar ── */
.sidebar {
  width: 260px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  height: calc(100vh - var(--topbar-height));
  position: sticky;
  top: var(--topbar-height);
}

.sidebar-label {
  padding: 12px 14px 8px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--dim);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

#toc-nav {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 6px 0;
}

#toc-nav::-webkit-scrollbar { width: 3px; }
#toc-nav::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 2px; }
#toc-nav::-webkit-scrollbar-track { background: transparent; }

/* Sidebar links — neutralise <a> defaults */
a.toc-header, a.toc-sub {
  text-decoration: none;
  color: inherit;
  display: flex;
}

.toc-item { border-bottom: 1px solid var(--border); }

.toc-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  transition: color .15s, background .15s;
  user-select: none;
}
.toc-header:hover { color: var(--text); background: rgba(255,255,255,.03); }
.toc-header.active { color: var(--accent2); background: rgba(99,102,241,.08); border-left: 2px solid var(--accent); }

.toc-icon  { font-size: 13px; flex-shrink: 0; }
.toc-label { flex: 1; }

.toc-chevron {
  font-size: 8px;
  color: var(--dim);
  transition: transform .2s ease;
  flex-shrink: 0;
}
.toc-item.open > .toc-header .toc-chevron { transform: rotate(90deg); }

.toc-subs {
  display: none;
  background: var(--bg);
}
.toc-item.open > .toc-subs { display: block; }

.toc-sub {
  display: block;
  padding: 7px 12px 7px 32px;
  font-size: 12px;
  color: var(--dim);
  text-decoration: none;
  transition: color .15s, background .15s;
}
.toc-sub:hover { color: var(--text); background: rgba(255,255,255,.02); }
.toc-sub.active { color: var(--accent2); background: rgba(99,102,241,.06); border-left: 2px solid var(--accent); font-weight: 500; }

/* Sidebar Progress Footer */
.sidebar-footer {
  padding: 10px 14px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.progress-meta {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--dim);
  margin-bottom: 5px;
}

.progress-bar { height: 2px; background: var(--border); border-radius: 2px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--accent); border-radius: 2px; width: 0%; transition: width .4s ease; }

/* ── Main Content ── */
.main-content {
  flex: 1;
  overflow-y: auto;
  height: calc(100vh - var(--topbar-height));
  padding: 0;
}

.main-header {
  padding: 16px 48px 0;
  max-width: 960px;
  margin: 0 auto;
}

.breadcrumb {
  font-size: 12px;
  color: var(--dim);
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
}
.breadcrumb .bc-active { color: var(--muted); }

#content-area {
  max-width: 960px;
  margin: 0 auto;
  padding: 24px 48px 64px;
}

/* ── Content Container ── */
.content-container { padding: 0; }

/* ── Typography ── */
h1, h2, h3, h4, h5 { font-weight: 600; line-height: 1.3; color: var(--text); }
h1 { font-size: 1.8rem; margin-bottom: 8px; }
h2 { font-size: 1.35rem; margin: 28px 0 12px; }
h3 { font-size: 1.1rem; margin: 22px 0 10px; color: var(--accent3); }
h4 { font-size: 0.95rem; margin: 18px 0 8px; color: var(--muted); }

.body-text { font-size: 14px; color: var(--muted); line-height: 1.75; margin-bottom: 14px; }
.lead-text  { font-size: 15px; color: var(--muted); line-height: 1.8; margin-bottom: 18px; }

/* ── Difficulty Badge ── */
.difficulty-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 20px;
  margin-bottom: 18px;
  margin-top: 4px;
}
.difficulty-badge.beginner     { background: rgba(34,197,94,.12);  color: var(--green); border: 1px solid rgba(34,197,94,.25); }
.difficulty-badge.intermediate { background: rgba(245,158,11,.12); color: var(--amber); border: 1px solid rgba(245,158,11,.25); }
.difficulty-badge.advanced     { background: rgba(249,115,22,.12); color: var(--coral); border: 1px solid rgba(249,115,22,.25); }
.difficulty-badge.expert       { background: rgba(236,72,153,.12); color: var(--pink);  border: 1px solid rgba(236,72,153,.25); }

/* ── Stat Cards ── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin: 20px 0 28px;
}

.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  border-top: 3px solid var(--accent);
}

.stat-value {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--sv-color, var(--accent2));
  line-height: 1.2;
  margin-bottom: 4px;
}

.stat-label {
  font-size: 11px;
  color: var(--muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ── Code Blocks ── */
.code-block {
  background: #111113;
  border: 1px solid #27272a;
  border-radius: 6px;
  margin: 16px 0;
  overflow: hidden;
}

.code-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 12px;
  background: #0d0d0f;
  border-bottom: 1px solid #27272a;
}

.code-lang { font-size: 11px; color: #52525b; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; }

.code-block pre {
  padding: 14px 16px;
  overflow-x: auto;
  margin: 0;
}

.code-block code {
  font-family: 'Cascadia Code', 'Fira Code', 'Consolas', monospace;
  font-size: 12.5px;
  color: #e2e8f0;
  line-height: 1.65;
}

/* Keep code dark in light mode */
.light .code-block              { background: #18181b; border-color: #27272a; }
.light .code-block .code-header { background: #111113; border-color: #27272a; }
.light .code-block code         { color: #fafafa; }

/* ── Callout Boxes ── */
.callout {
  padding: 14px 16px;
  border-radius: 6px;
  border-left: 3px solid;
  margin: 16px 0;
  font-size: 13.5px;
  line-height: 1.7;
}
.callout-info    { background: rgba(99,102,241,.08);  border-color: var(--accent);  color: var(--text); }
.callout-success { background: rgba(34,197,94,.08);   border-color: var(--green);   color: var(--text); }
.callout-warning { background: rgba(245,158,11,.08);  border-color: var(--amber);   color: var(--text); }
.callout-danger  { background: rgba(249,115,22,.08);  border-color: var(--coral);   color: var(--text); }
.callout-tip     { background: rgba(20,184,166,.08);  border-color: var(--teal);    color: var(--text); }

.callout strong { color: var(--text); }
.callout-title  { font-weight: 700; display: block; margin-bottom: 4px; font-size: 12px; letter-spacing: .05em; text-transform: uppercase; }

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

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th {
  background: var(--surface);
  color: var(--muted);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .06em;
  padding: 8px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  vertical-align: top;
}

tr:hover td { background: rgba(255,255,255,.02); }
.light tr:hover td { background: rgba(0,0,0,.02); }

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

/* ── Accordion ── */
.accordion { margin: 16px 0; }

.accordion-item {
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-bottom: 6px;
  overflow: hidden;
}

.accordion-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--surface);
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text);
  user-select: none;
  transition: background .15s;
}
.accordion-header:hover { background: var(--card); }

.accordion-arrow {
  font-size: 10px;
  color: var(--dim);
  transition: transform .2s ease;
}
.accordion-item.open .accordion-arrow { transform: rotate(90deg); }

.accordion-body {
  display: none;
  padding: 14px 16px;
  background: var(--bg);
  border-top: 1px solid var(--border);
  font-size: 13.5px;
  color: var(--muted);
  line-height: 1.7;
}
.accordion-item.open .accordion-body { display: block; }

/* ── Expandable ── */
.expandable { border: 1px solid var(--border); border-radius: 6px; margin: 16px 0; }

.expand-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--surface);
  border: none;
  width: 100%;
  text-align: left;
  cursor: pointer;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  transition: background .15s;
}
.expand-toggle:hover { background: var(--card); color: var(--text); }

.expand-icon { font-size: 10px; transition: transform .2s; }
.expandable.open .expand-icon { transform: rotate(90deg); }

.expand-content {
  display: none;
  padding: 14px;
  border-top: 1px solid var(--border);
}
.expandable.open .expand-content { display: block; }

/* ── Tabs ── */
.tabs-container { margin: 16px 0; }

.tab-bar {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.tab-btn {
  padding: 8px 14px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: color .15s, border-color .15s;
  margin-bottom: -1px;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--accent2); border-bottom-color: var(--accent); }

.tab-panel { display: none; padding: 16px 0; }
.tab-panel.active { display: block; }

/* ── Subtopic Nav ── */
.subtopic-nav {
  margin-top: 36px;
  padding: 14px 0 10px;
  border-top: 1px solid var(--border);
}

.subtopic-nav-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--dim);
  margin-bottom: 8px;
}

.subtopic-nav-links { display: flex; flex-wrap: wrap; gap: 6px; }

.subtopic-nav-link {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 12px;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--border);
  text-decoration: none;
  transition: color .15s, border-color .15s;
  cursor: pointer;
}
.subtopic-nav-link:hover { color: var(--text); border-color: var(--accent); }
.subtopic-nav-link.active {
  color: var(--accent);
  border-color: var(--accent);
  background: rgba(99,102,241,.07);
  font-weight: 500;
  pointer-events: none;
}

/* ── Prev/Next Footer ── */
.topic-nav-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
  gap: 8px;
}

.topic-nav-prev, .topic-nav-next {
  font-size: 13px;
  color: var(--accent2);
  text-decoration: none;
  transition: color .15s;
}
.topic-nav-prev:hover, .topic-nav-next:hover { color: var(--accent); }
.topic-nav-next { margin-left: auto; }

/* ── Step List ── */
.step-list { list-style: none; padding: 0; margin: 16px 0; counter-reset: step-count; }
.step-list li {
  display: flex;
  gap: 14px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13.5px;
  color: var(--muted);
  counter-increment: step-count;
}
.step-list li::before {
  content: counter(step-count);
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
  margin-top: 1px;
}

/* ── Diagram / ASCII Box ── */
.diagram {
  background: #111113;
  border: 1px solid #27272a;
  border-radius: 6px;
  padding: 16px;
  margin: 16px 0;
  overflow-x: auto;
}
.diagram pre { color: #a1a1aa; font-family: 'Cascadia Code', 'Fira Code', 'Consolas', monospace; font-size: 12px; line-height: 1.6; }
.light .diagram { background: #18181b; border-color: #27272a; }
.light .diagram pre { color: #a1a1aa; }

/* ── Topic Section Header ── */
.section-title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 28px 0 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.section-title h2 { margin: 0; }
.section-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 3px;
  background: rgba(99,102,241,.12);
  color: var(--accent2);
  letter-spacing: .04em;
  text-transform: uppercase;
}

/* ── Info Grid ── */
.info-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; margin: 16px 0; }
.info-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 14px;
}
.info-card-title { font-size: 11px; font-weight: 700; color: var(--accent2); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 6px; }
.info-card p { font-size: 13px; color: var(--muted); line-height: 1.6; }

/* ── Flow Diagram ── */
.flow-row { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin: 16px 0; }
.flow-box {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 14px;
  font-size: 12.5px;
  color: var(--text);
  font-weight: 500;
  text-align: center;
}
.flow-box.accent { border-color: var(--accent); background: rgba(99,102,241,.08); color: var(--accent2); }
.flow-box.green  { border-color: var(--green);  background: rgba(34,197,94,.08);  color: var(--green); }
.flow-box.amber  { border-color: var(--amber);  background: rgba(245,158,11,.08); color: var(--amber); }
.flow-box.teal   { border-color: var(--teal);   background: rgba(20,184,166,.08); color: var(--teal); }
.flow-arrow { color: var(--dim); font-size: 14px; }

/* ── Badges / Tags ── */
.tag {
  display: inline-block;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 3px;
  font-weight: 500;
  margin-right: 4px;
}
.tag-green  { background: rgba(34,197,94,.12);  color: var(--green); }
.tag-amber  { background: rgba(245,158,11,.12); color: var(--amber); }
.tag-red    { background: rgba(249,115,22,.12); color: var(--coral); }
.tag-blue   { background: rgba(99,102,241,.12); color: var(--accent2); }
.tag-teal   { background: rgba(20,184,166,.12); color: var(--teal); }

/* ── Quiz Block ── */
.quiz-block { margin: 24px 0; }
.quiz-section-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--accent2);
  text-transform: uppercase;
  letter-spacing: .07em;
  padding: 10px 0 6px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 12px;
}

.quiz-question {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 12px;
}

.quiz-q-text {
  font-size: 14px;
  color: var(--text);
  font-weight: 500;
  margin-bottom: 12px;
  line-height: 1.6;
}

.quiz-options { display: flex; flex-direction: column; gap: 7px; }

.quiz-option {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 9px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 5px;
  cursor: pointer;
  font-size: 13px;
  color: var(--muted);
  transition: border-color .15s, background .15s;
  text-align: left;
}
.quiz-option:hover:not(.disabled) { border-color: var(--accent); color: var(--text); }
.quiz-option.disabled { cursor: not-allowed; }
.quiz-option.correct  { border-color: var(--green); background: rgba(34,197,94,.08); color: var(--green); }
.quiz-option.wrong    { border-color: var(--coral); background: rgba(249,115,22,.08); color: var(--coral); }

.quiz-key { font-weight: 700; flex-shrink: 0; width: 18px; }

.quiz-explanation {
  display: none;
  margin-top: 10px;
  padding: 10px 12px;
  background: rgba(99,102,241,.07);
  border-left: 3px solid var(--accent);
  border-radius: 4px;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.65;
}

/* ── Comparison Card ── */
.compare-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 16px 0; }
.compare-card { background: var(--card); border: 1px solid var(--border); border-radius: 6px; padding: 14px; }
.compare-card-title { font-size: 13px; font-weight: 700; margin-bottom: 10px; padding-bottom: 6px; border-bottom: 1px solid var(--border); }
.compare-card ul { padding-left: 18px; }
.compare-card li { font-size: 13px; color: var(--muted); line-height: 1.7; margin-bottom: 3px; }
@media (max-width: 600px) { .compare-grid { grid-template-columns: 1fr; } }

/* ── Highlight Box ── */
.highlight-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 16px 18px;
  margin: 16px 0;
}
.highlight-box h4 { font-size: 13px; margin: 0 0 8px; color: var(--accent3); }
.highlight-box p, .highlight-box li { font-size: 13.5px; color: var(--muted); line-height: 1.7; }

/* ── Key Point ── */
.key-point {
  background: rgba(99,102,241,.08);
  border: 1px solid rgba(99,102,241,.25);
  border-radius: 6px;
  padding: 12px 16px;
  margin: 14px 0;
  font-size: 13.5px;
  color: var(--text);
  line-height: 1.65;
}
.key-point strong { color: var(--accent2); }

/* ── Divider ── */
.section-divider { border: none; border-top: 1px solid var(--border); margin: 28px 0; }

/* ── Mobile ── */
@media (max-width: 768px) {
  .sidebar { width: 220px; }
  #content-area { padding: 16px 20px 48px; }
  .main-header { padding: 12px 20px 0; }
  h1 { font-size: 1.5rem; }
  h2 { font-size: 1.2rem; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 600px) {
  .sidebar { display: none; }
  .app-layout { flex-direction: column; }
  .main-content { height: auto; }
  #content-area { padding: 12px 16px 48px; }
}
