/* ========================================
   Portfolio Dark Theme
   Catppuccin-inspired dark theme for documentation
   ======================================== */

:root {
  --bg-primary: #1e1e2e;
  --bg-secondary: #252536;
  --bg-surface: #2a2a3d;
  --bg-code: #1a1a2e;
  --text-primary: #cdd6f4;
  --text-secondary: #a6adc8;
  --text-muted: #9399b2;
  --accent: #6c7bda;
  --accent-light: #8992e8;
  --border: #363650;
  --link: #89b4fa;
  --link-hover: #b4d0fb;
  --success: #a6e3a1;
  --warning: #fab387;
  --danger: #f38ba8;
  --highlight-bg: #313244;
  --sidebar-width: 280px;
}

/* === Reset === */
* { margin: 0; padding: 0; box-sizing: border-box; }

/* === Layout === */
body {
  font-family: 'Roboto', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.7;
  font-size: 16px;
}

.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  z-index: 100;
  padding: 0;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.sidebar-header {
  padding: 1.2rem 1.2rem 1rem;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--bg-secondary);
  z-index: 1;
}

.sidebar-header a {
  color: var(--text-primary);
  font-weight: 500;
  font-size: 0.85rem;
  text-decoration: none;
  line-height: 1.4;
  display: block;
}

.sidebar-header a:hover {
  color: var(--accent-light);
}

.sidebar-content {
  padding: 0.5rem 0 2rem;
}

.content {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
}

.container {
  max-width: 900px;
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
}

/* === Sidebar Navigation === */
.nav-tree {
  list-style: none;
  padding: 0;
  margin: 0;
}

.nav-tree ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.nav-link {
  display: block;
  padding: 0.3rem 1.2rem 0.3rem 1.5rem;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.84rem;
  border-left: 2px solid transparent;
  transition: all 0.15s;
  line-height: 1.4;
}

.nav-link:hover {
  color: var(--text-primary);
  background: var(--highlight-bg);
  text-decoration: none;
}

.nav-link.active {
  color: var(--accent-light);
  border-left-color: var(--accent);
  background: var(--highlight-bg);
}

/* Indent levels */
.nav-depth-1 > .nav-link,
.nav-depth-1 > .nav-section-btn { padding-left: 1.2rem; }
.nav-depth-2 > .nav-link,
.nav-depth-2 > .nav-section-btn { padding-left: 2rem; }
.nav-depth-3 > .nav-link,
.nav-depth-3 > .nav-section-btn { padding-left: 2.8rem; }
.nav-depth-4 > .nav-link,
.nav-depth-4 > .nav-section-btn { padding-left: 3.6rem; }

.nav-section-btn {
  display: block;
  width: 100%;
  padding: 0.3rem 1.2rem;
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 0.84rem;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
  line-height: 1.4;
}

.nav-section-btn:hover {
  background: var(--highlight-bg);
}

.nav-section-btn::before {
  content: '\25B6';
  display: inline-block;
  margin-right: 0.4rem;
  font-size: 0.55rem;
  transition: transform 0.2s;
  vertical-align: middle;
}

.nav-section-btn.expanded::before {
  transform: rotate(90deg);
}

.nav-children {
  display: none;
}

.nav-section-btn.expanded + .nav-children {
  display: block;
}

/* === Mobile Responsive === */
.nav-toggle {
  display: none;
  position: fixed;
  top: 0.8rem;
  left: 0.8rem;
  z-index: 200;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.5rem;
  cursor: pointer;
  flex-direction: column;
  gap: 4px;
  width: 36px;
  height: 36px;
  align-items: center;
  justify-content: center;
}

.nav-toggle span {
  display: block;
  width: 18px;
  height: 2px;
  background: var(--text-primary);
  border-radius: 1px;
  transition: all 0.2s;
}

.nav-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 99;
}

.nav-overlay.active {
  display: block;
}

@media (max-width: 900px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.3s ease;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .content {
    margin-left: 0;
  }

  .nav-toggle {
    display: flex;
  }

  .container {
    padding-top: 3.5rem;
  }
}

/* === Typography === */
h1 {
  font-size: 2rem;
  font-weight: 700;
  margin: 0 0 1.5rem;
  line-height: 1.3;
  color: var(--text-primary);
}

h2 {
  font-size: 1.5rem;
  font-weight: 500;
  margin: 2.5rem 0 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
}

h3 {
  font-size: 1.25rem;
  font-weight: 500;
  margin: 1.8rem 0 0.8rem;
  color: var(--accent-light);
}

h4 {
  font-size: 1.1rem;
  font-weight: 500;
  margin: 1.5rem 0 0.6rem;
  color: var(--text-primary);
}

h5 {
  font-size: 1rem;
  font-weight: 500;
  margin: 1.2rem 0 0.5rem;
  color: var(--text-secondary);
}

p {
  margin-bottom: 0.8rem;
  color: var(--text-secondary);
}

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

/* === Links === */
a {
  color: var(--link);
  text-decoration: none;
}

a:hover {
  color: var(--link-hover);
  text-decoration: underline;
}

/* === Tables === */
table {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0 1.5rem;
  font-size: 0.95rem;
}

th, td {
  padding: 0.6rem 0.8rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

th {
  background: var(--bg-surface);
  color: var(--text-primary);
  font-weight: 500;
  font-size: 0.88rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

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

tr:hover td {
  background: var(--highlight-bg);
}

/* Table overflow for wide tables */
.table-wrapper {
  overflow-x: auto;
  margin: 1rem 0 1.5rem;
}

.table-wrapper table {
  margin: 0;
}

/* === Blockquotes === */
blockquote {
  background: var(--bg-secondary);
  border-left: 3px solid var(--accent);
  border-radius: 0 6px 6px 0;
  padding: 0.8rem 1.2rem;
  margin: 1rem 0;
  font-size: 0.95rem;
  color: var(--text-secondary);
}

blockquote p {
  color: var(--text-secondary);
  margin-bottom: 0.4rem;
}

blockquote p:last-child {
  margin-bottom: 0;
}

blockquote a {
  color: var(--link);
}

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

blockquote blockquote {
  margin: 0.5rem 0;
  border-left-color: var(--border);
}

/* === Lists === */
ul, ol {
  margin: 0.5rem 0 1rem 1.5rem;
  color: var(--text-secondary);
}

li {
  margin-bottom: 0.3rem;
  font-size: 1rem;
}

li > ul, li > ol {
  margin-top: 0.2rem;
  margin-bottom: 0.2rem;
}

/* === Code === */
code {
  font-family: 'Roboto Mono', monospace;
  font-size: 0.88em;
  background: var(--bg-code);
  padding: 0.15rem 0.4rem;
  border-radius: 3px;
  color: var(--accent-light);
}

pre {
  background: var(--bg-code) !important;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1rem;
  margin: 1rem 0;
  overflow-x: auto;
  font-size: 0.9rem;
  line-height: 1.5;
}

pre code {
  background: none;
  padding: 0;
  border-radius: 0;
  color: var(--text-secondary);
  font-size: inherit;
}

/* Prism.js overrides */
pre[class*="language-"] {
  background: var(--bg-code) !important;
  border: 1px solid var(--border);
  border-radius: 6px;
  margin: 1rem 0;
}

code[class*="language-"],
pre[class*="language-"] {
  text-shadow: none !important;
}

.token.comment,
.token.prolog,
.token.doctype,
.token.cdata {
  color: var(--text-muted) !important;
}

.token.property,
.token.tag,
.token.constant,
.token.symbol,
.token.deleted {
  color: var(--danger) !important;
}

.token.boolean,
.token.number {
  color: var(--warning) !important;
}

.token.selector,
.token.attr-name,
.token.string,
.token.char,
.token.builtin,
.token.inserted {
  color: var(--success) !important;
}

.token.operator,
.token.entity,
.token.url {
  color: var(--text-secondary) !important;
}

.token.atrule,
.token.attr-value,
.token.keyword {
  color: var(--accent-light) !important;
}

.token.function,
.token.class-name {
  color: #89b4fa !important;
}

.token.regex,
.token.important,
.token.variable {
  color: var(--warning) !important;
}

/* === HR === */
hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2rem 0;
}

/* === Details / Summary === */
details {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 6px;
  margin: 1rem 0;
  overflow: hidden;
}

details > summary {
  padding: 0.7rem 1rem;
  cursor: pointer;
  color: var(--text-primary);
  font-weight: 500;
  font-size: 1rem;
  user-select: none;
}

details > summary:hover {
  background: var(--highlight-bg);
}

details[open] > summary {
  border-bottom: 1px solid var(--border);
}

details > :not(summary) {
  padding: 0 1rem;
}

details > p:first-of-type {
  margin-top: 0.8rem;
}

details > table {
  margin: 0.8rem 1rem 1rem;
  width: calc(100% - 2rem);
}

details > ul, details > ol {
  margin-left: 2.5rem;
}

/* === Mermaid Diagrams === */
.mermaid {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.5rem 1rem;
  margin: 1.5rem 0;
  text-align: center;
  overflow-x: auto;
}

/* === Images === */
img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  border: 1px solid var(--border);
  margin: 1rem 0;
}

/* === Iframe (PDF embed) === */
iframe {
  border: 1px solid var(--border);
  border-radius: 6px;
  width: 100%;
  min-height: 600px;
  margin: 1rem 0;
}

/* === Document tree (code blocks without syntax) === */
pre:not([class*="language-"]) code {
  color: var(--text-secondary);
}

/* === Breadcrumb nav at top of pages === */
.breadcrumb-nav {
  font-size: 0.82rem;
  margin-bottom: 1.5rem;
  color: var(--text-muted);
}

.breadcrumb-nav a {
  color: var(--link);
}

/* === Emoji in headings === */
h2 .emoji, h3 .emoji {
  margin-right: 0.3rem;
}

/* === Checkmarks in table cells === */
td:has(only-child) {
  text-align: center;
}
