/* ==========================================================================
   DASHBOARD DE TESIS & PROYECTO DE GRADO - UMSA INFORMÁTICA
   Vanilla CSS Design System & Theme Engine (Ultra Dark & Glassmorphic)
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. CSS Custom Properties & Design Tokens
   -------------------------------------------------------------------------- */
:root {
  /* Dark Palette (Obsidian & Deep Slate) */
  --bg-app: #090c15;
  --bg-sidebar: #0e121d;
  --bg-card: rgba(18, 24, 38, 0.7);
  --bg-card-hover: rgba(26, 34, 52, 0.85);
  --bg-input: rgba(13, 17, 27, 0.8);
  --bg-hover: rgba(255, 255, 255, 0.04);
  --bg-active: rgba(99, 102, 241, 0.12);

  /* Borders & Dividers */
  --border-subtle: rgba(255, 255, 255, 0.06);
  --border-focus: rgba(99, 102, 241, 0.4);
  --border-glow: rgba(6, 182, 212, 0.3);

  /* Primary Accent & Gradients */
  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --primary-light: #818cf8;
  --cyan: #06b6d4;
  --cyan-glow: rgba(6, 182, 212, 0.25);
  --gradient-primary: linear-gradient(135deg, #6366f1 0%, #06b6d4 100%);
  --gradient-accent: linear-gradient(135deg, #ec4899 0%, #8b5cf6 100%);

  /* Status Colors */
  --emerald: #10b981;
  --emerald-bg: rgba(16, 185, 129, 0.12);
  --amber: #f59e0b;
  --amber-bg: rgba(245, 158, 11, 0.12);
  --rose: #f43f5e;
  --rose-bg: rgba(244, 63, 94, 0.12);
  --blue: #3b82f6;
  --blue-bg: rgba(59, 130, 246, 0.12);

  /* Text Hierarchies */
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --text-disabled: #475569;

  /* Typography Scale */
  --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --doc-font-size: 15.5px;

  /* Dimensions */
  --sidebar-w: 280px;
  --header-h: 60px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;

  /* Transitions & Shadows */
  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 20px rgba(99, 102, 241, 0.25);
  --transition-fast: 0.18s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html, body {
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  font-family: var(--font-sans);
  background-color: var(--bg-app);
  color: var(--text-primary);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Custom Scrollbars */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.12);
  border-radius: 99px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.22);
}

/* Reading Progress Bar on Top */
.reading-progress-bar {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  width: 0%;
  background: var(--gradient-primary);
  z-index: 1000;
  box-shadow: 0 0 8px rgba(6, 182, 212, 0.6);
  transition: width 0.1s linear;
}

/* --------------------------------------------------------------------------
   3. Main Application Flex Layout (Sidebar Lado a Lado con Contenido)
   -------------------------------------------------------------------------- */
.app-layout {
  display: flex;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  background-color: var(--bg-app);
  position: relative;
}

/* --------------------------------------------------------------------------
   4. Left Sidebar (Navigation & Docs)
   -------------------------------------------------------------------------- */
.sidebar-left {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  max-width: var(--sidebar-w);
  height: 100vh;
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: margin-left var(--transition-normal);
  position: relative;
  z-index: 40;
}

/* Al colapsar en escritorio se desliza hacia la izquierda */
.app-layout.sidebar-left-collapsed .sidebar-left {
  margin-left: calc(-1 * var(--sidebar-w));
}

.sidebar-header {
  height: var(--header-h);
  padding: 0 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-subtle);
  background: rgba(14, 18, 29, 0.95);
  backdrop-filter: blur(10px);
}

.brand-container {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.brand-logo {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  background: var(--gradient-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.35);
  flex-shrink: 0;
}

.brand-title {
  font-size: 1.12rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: #fff;
  line-height: 1.2;
}

.gradient-text {
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-subtitle {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* Sidebar Search */
.sidebar-search {
  padding: 0.85rem 1.15rem 0.4rem;
}

.search-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 10px;
  color: var(--text-muted);
  pointer-events: none;
}

.search-input-wrapper input {
  width: 100%;
  padding: 0.55rem 2rem 0.55rem 2.1rem;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 0.82rem;
  font-family: var(--font-sans);
  outline: none;
  transition: var(--transition-fast);
}

.search-input-wrapper input:focus {
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
  background: rgba(18, 24, 38, 0.95);
}

.clear-btn {
  position: absolute;
  right: 8px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
}
.clear-btn:hover {
  color: var(--text-primary);
}

/* Navigation List */
.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem 0.85rem;
}

.nav-section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.4rem 0.5rem;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  text-transform: uppercase;
}

.badge-pill {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  padding: 1px 7px;
  border-radius: 99px;
  font-size: 0.68rem;
  color: var(--primary-light);
  font-weight: 600;
}

.doc-nav-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-top: 0.25rem;
}

.doc-nav-item {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.65rem 0.75rem;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  text-decoration: none;
  cursor: pointer;
  border: 1px solid transparent;
  transition: var(--transition-fast);
}

.doc-nav-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.doc-nav-item.active {
  background: var(--bg-active);
  color: #fff;
  border-color: var(--border-focus);
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.15);
}

.doc-nav-item.active .doc-item-icon {
  color: var(--cyan);
}

.doc-item-icon {
  color: var(--text-muted);
  margin-top: 2px;
  flex-shrink: 0;
  transition: color var(--transition-fast);
}

.doc-item-content {
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow: hidden;
}

.doc-item-title {
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.doc-item-meta {
  font-size: 0.7rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Quick Link Cards */
.quick-links {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  margin-top: 0.35rem;
}

.quick-link-card {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.55rem 0.65rem;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  text-decoration: none;
  color: var(--text-secondary);
  transition: var(--transition-fast);
}

.quick-link-card:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-focus);
  color: var(--text-primary);
  transform: translateY(-1px);
}

.quick-icon {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.icon-blue { background: var(--blue-bg); color: var(--blue); }
.icon-rose { background: var(--rose-bg); color: var(--rose); }
.icon-emerald { background: var(--emerald-bg); color: var(--emerald); }
.icon-purple { background: rgba(168, 85, 247, 0.15); color: #c084fc; }

.quick-info {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.quick-title {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-primary);
}

.quick-desc {
  font-size: 0.68rem;
  color: var(--text-muted);
}

.sidebar-footer {
  padding: 0.85rem 1.15rem;
  border-top: 1px solid var(--border-subtle);
  background: rgba(14, 18, 29, 0.7);
}

.academic-badge {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.75rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--emerald);
  box-shadow: 0 0 6px rgba(16, 185, 129, 0.6);
}

/* --------------------------------------------------------------------------
   5. Central Area (Markdown Reader & Header)
   -------------------------------------------------------------------------- */
.main-content {
  flex: 1 1 0%;
  min-width: 0; /* Crucial para evitar desbordes en Flexbox */
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background-color: var(--bg-app);
  position: relative;
}

/* Top Navbar */
.top-navbar {
  height: var(--header-h);
  padding: 0 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(9, 12, 21, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-subtle);
  z-index: 30;
  flex-shrink: 0;
}

.navbar-left {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

/* Botón Toggle del Sidebar en el Navbar */
.sidebar-toggle-btn {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  transition: var(--transition-fast);
}

.sidebar-toggle-btn:hover {
  background: var(--bg-card-hover);
  color: var(--primary-light);
  border-color: var(--border-focus);
}

.breadcrumbs {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.82rem;
}

.breadcrumb-root {
  color: var(--text-muted);
  font-weight: 500;
}
.breadcrumb-separator {
  color: var(--text-disabled);
}
.breadcrumb-active {
  color: var(--text-primary);
  font-weight: 600;
}

.navbar-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.reading-meta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.meta-item {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  background: var(--bg-card);
  padding: 4px 10px;
  border-radius: 99px;
  border: 1px solid var(--border-subtle);
}

.action-btn-group {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.icon-btn, .icon-btn-sm {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-fast);
}

.icon-btn {
  width: 32px;
  height: 32px;
}
.icon-btn-sm {
  width: 30px;
  height: 30px;
  font-size: 0.75rem;
  font-weight: 600;
}

.icon-btn:hover, .icon-btn-sm:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
  border-color: var(--border-focus);
}

/* Scroll Area */
.content-scroll-area {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 2.5rem 3.5rem 5rem;
  scroll-behavior: smooth;
  width: 100%;
}

/* Table of Contents Floating Bar */
.toc-container {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  margin: 0 auto 2rem;
  max-width: 900px;
  padding: 0.65rem 1rem;
  background: var(--bg-card);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  overflow-x: auto;
  white-space: nowrap;
}

.toc-label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--primary-light);
  flex-shrink: 0;
}

.toc-chips-list {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.toc-chip {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-subtle);
  padding: 4px 10px;
  border-radius: 99px;
  font-size: 0.74rem;
  color: var(--text-secondary);
  text-decoration: none;
  cursor: pointer;
  transition: var(--transition-fast);
  flex-shrink: 0;
}

.toc-chip:hover {
  background: var(--bg-active);
  color: var(--cyan);
  border-color: var(--cyan);
}

/* --------------------------------------------------------------------------
   6. Rendered Markdown Typography & Centered Component Styles
   -------------------------------------------------------------------------- */
.markdown-body {
  max-width: 900px;
  margin: 0 auto;
  width: 100%;
  font-size: var(--doc-font-size);
  color: var(--text-primary);
  line-height: 1.75;
}

.markdown-body h1 {
  font-size: 2.1rem;
  font-weight: 800;
  letter-spacing: -0.025em;
  color: #fff;
  margin-top: 0;
  margin-bottom: 0.8rem;
  line-height: 1.25;
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 0.8rem;
}

.markdown-body h2 {
  font-size: 1.45rem;
  font-weight: 700;
  color: #f8fafc;
  margin-top: 2.2rem;
  margin-bottom: 0.8rem;
  line-height: 1.35;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.markdown-body h2::before {
  content: "";
  display: inline-block;
  width: 4px;
  height: 1.1em;
  background: var(--gradient-primary);
  border-radius: 2px;
}

.markdown-body h3 {
  font-size: 1.18rem;
  font-weight: 600;
  color: #cbd5e1;
  margin-top: 1.6rem;
  margin-bottom: 0.6rem;
}

.markdown-body h4 {
  font-size: 1.02rem;
  font-weight: 600;
  color: #94a3b8;
  margin-top: 1.2rem;
  margin-bottom: 0.4rem;
}

.markdown-body p {
  margin-bottom: 1.15rem;
  color: #cbd5e1;
}

.markdown-body strong {
  color: #fff;
  font-weight: 600;
}

.markdown-body em {
  color: var(--cyan);
  font-style: italic;
}

.markdown-body hr {
  border: none;
  height: 1px;
  background: var(--border-subtle);
  margin: 2.2rem 0;
}

.markdown-body ul, .markdown-body ol {
  margin-bottom: 1.25rem;
  padding-left: 1.5rem;
}

.markdown-body li {
  margin-bottom: 0.45rem;
  color: #cbd5e1;
}

.markdown-body li > strong:first-child {
  color: #e2e8f0;
}

/* Academic Tables */
.markdown-body table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  margin: 1.5rem 0 2rem;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: rgba(14, 18, 29, 0.6);
  font-size: 0.88rem;
}

.markdown-body th {
  background: rgba(30, 41, 59, 0.85);
  color: #f1f5f9;
  font-weight: 700;
  text-align: left;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-subtle);
  letter-spacing: 0.02em;
}

.markdown-body td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  color: #cbd5e1;
  vertical-align: top;
}

.markdown-body tr:last-child td {
  border-bottom: none;
}

.markdown-body tr:hover td {
  background: rgba(255, 255, 255, 0.025);
}

/* Toolbar de Tablas & Botón Copiar APA */
.table-responsive-wrapper {
  margin: 2rem 0;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.25rem 1rem;
  overflow-x: auto;
  box-shadow: var(--shadow-sm);
}

.table-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.85rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border-subtle);
}

.table-badge {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--amber);
  letter-spacing: 0.05em;
}

.btn-copy-table-apa {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.4rem 0.85rem;
  font-size: 0.8rem;
  font-weight: 600;
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.3);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-copy-table-apa:hover {
  background: var(--amber);
  color: #000000;
  border-color: var(--amber);
  box-shadow: 0 0 12px rgba(245, 158, 11, 0.4);
}

/* Code & Pre */
.markdown-body code {
  font-family: var(--font-mono);
  font-size: 0.86em;
  background: rgba(30, 41, 59, 0.6);
  color: #38bdf8;
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.markdown-body pre {
  margin: 1.5rem 0;
  background: #0d1117 !important;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1.1rem 1.25rem;
  overflow-x: auto;
  position: relative;
}

.markdown-body pre code {
  background: transparent !important;
  border: none;
  padding: 0;
  color: #e2e8f0;
  font-size: 0.86rem;
  line-height: 1.6;
}

/* Mermaid Interactive Diagrams & APA Toolbar */
.mermaid-diagram-wrapper {
  position: relative;
  margin: 2.5rem auto;
  padding: 1.25rem 1.5rem 2rem;
  background: rgba(14, 18, 29, 0.95);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow-x: auto;
  box-shadow: var(--shadow-md);
  width: 100%;
  max-width: 900px;
}

.mermaid-toolbar {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.25rem;
  padding-bottom: 0.65rem;
  border-bottom: 1px solid var(--border-subtle);
}

.mermaid-badge {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--cyan);
  letter-spacing: 0.05em;
}

.btn-download-apa {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.4rem 0.85rem;
  font-size: 0.8rem;
  font-weight: 600;
  background: rgba(99, 102, 241, 0.15);
  color: #818cf8;
  border: 1px solid rgba(99, 102, 241, 0.3);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-download-apa:hover:not(:disabled) {
  background: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
  box-shadow: 0 0 12px rgba(99, 102, 241, 0.4);
}

.btn-download-apa:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

.spin-icon {
  animation: spin 1s linear infinite;
}

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

.mermaid {
  width: 100%;
  display: flex;
  justify-content: center;
  font-family: var(--font-sans) !important;
}

.mermaid svg {
  width: 100% !important;
  max-width: 100% !important;
  height: auto !important;
  font-family: var(--font-sans) !important;
}

.mermaid svg .node rect,
.mermaid svg .node circle,
.mermaid svg .node polygon {
  stroke-width: 1.5px !important;
}

.mermaid svg .node .label {
  font-size: 14px !important;
  font-weight: 500 !important;
  line-height: 1.4 !important;
}

.mermaid svg .cluster rect {
  fill: rgba(30, 41, 59, 0.5) !important;
  stroke: rgba(99, 102, 241, 0.3) !important;
  stroke-width: 1.5px !important;
  rx: 8px !important;
  ry: 8px !important;
}

/* Alerts and Callouts */
.markdown-body blockquote {
  margin: 1.4rem 0;
  padding: 1rem 1.25rem;
  background: rgba(30, 41, 59, 0.4);
  border-left: 4px solid var(--primary);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  color: #cbd5e1;
}

.markdown-body .alert-box {
  margin: 1.5rem 0;
  padding: 1rem 1.25rem;
  border-radius: var(--radius-md);
  border-left: 4px solid;
  background: var(--bg-card);
}

.markdown-body .alert-box.alert-note {
  border-color: var(--blue);
  background: rgba(59, 130, 246, 0.08);
}
.markdown-body .alert-box.alert-important {
  border-color: var(--primary);
  background: rgba(99, 102, 241, 0.08);
}
.markdown-body .alert-box.alert-warning {
  border-color: var(--amber);
  background: rgba(245, 158, 11, 0.08);
}
.markdown-body .alert-box.alert-caution {
  border-color: var(--rose);
  background: rgba(244, 63, 94, 0.08);
}

.alert-title {
  font-size: 0.85rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.alert-note .alert-title { color: #60a5fa; }
.alert-important .alert-title { color: #a5b4fc; }
.alert-warning .alert-title { color: #fcd34d; }
.alert-caution .alert-title { color: #fda4af; }

/* Document Bottom Navigation Buttons */
.doc-footer {
  margin: 4rem auto 0;
  max-width: 900px;
  padding-top: 2rem;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 2rem;
  width: 100%;
}

.doc-nav-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
}

.doc-nav-btn {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1.1rem 1.25rem;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition-fast);
  text-align: left;
}

.doc-nav-btn:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-focus);
  color: var(--text-primary);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.doc-nav-btn.next-btn {
  text-align: right;
  justify-content: flex-end;
}

.nav-direction {
  display: block;
  font-size: 0.72rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.nav-title {
  display: block;
  font-size: 0.92rem;
  font-weight: 600;
  color: #fff;
}

.footer-legal {
  text-align: center;
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* --------------------------------------------------------------------------
   7. Toast System & Loading States
   -------------------------------------------------------------------------- */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 1000;
  pointer-events: none;
}

.toast {
  background: rgba(18, 24, 38, 0.95);
  border: 1px solid var(--border-focus);
  backdrop-filter: blur(12px);
  color: #fff;
  padding: 10px 16px;
  border-radius: var(--radius-md);
  font-size: 0.82rem;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 8px;
  animation: slideUp 0.25s ease-out;
  pointer-events: auto;
}

@keyframes slideUp {
  from { transform: translateY(12px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 6rem 1rem;
  color: var(--text-muted);
  gap: 1rem;
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid rgba(255, 255, 255, 0.08);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* --------------------------------------------------------------------------
   8. Media Queries & Mobile Responsiveness
   -------------------------------------------------------------------------- */
@media (max-width: 992px) {
  .sidebar-left {
    position: fixed;
    left: 0;
    top: 0;
    margin-left: 0 !important;
    transform: translateX(-100%);
    box-shadow: var(--shadow-lg);
    z-index: 100;
    transition: transform var(--transition-normal);
  }

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

  .sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 90;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-normal);
  }

  .sidebar-overlay.active {
    opacity: 1;
    pointer-events: auto;
  }

  .content-scroll-area {
    padding: 1.5rem 1.25rem 3rem;
  }

  .doc-nav-buttons {
    grid-template-columns: 1fr;
  }
}