/* Dark Theme for Quarto HTML Documents */
:root {
  --bs-body-bg: #212529;
  --bs-body-color: #e9ecef;
  --bs-primary: #0d6efd;
  --bs-secondary: #6c757d;
  --bs-success: #198754;
  --bs-info: #0dcaf0;
  --bs-warning: #ffc107;
  --bs-danger: #dc3545;
  --bs-light: #f8f9fa;
  --bs-dark: #212529;
}

/* Add theme toggle button */
.theme-toggle {
  position: fixed !important;
  top: 20px !important;
  right: 20px !important;
  z-index: 1000 !important;
  background-color: #495057 !important;
  color: #e9ecef !important;
  border: none !important;
  padding: 10px !important;
  border-radius: 50% !important;
  cursor: pointer !important;
  font-size: 16px !important;
  width: 40px !important;
  height: 40px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
}

/* Light mode base styles - explicit */
html[data-bs-theme="light"],
html[data-theme="light"],
html:not([data-bs-theme="dark"]),
html:not([data-theme="dark"]) {
  background-color: #ffffff !important;
  color: #000000 !important;
}

body[data-bs-theme="light"],
body[data-theme="light"],
body:not([data-bs-theme="dark"]),
body:not([data-theme="dark"]) {
  background-color: #ffffff !important;
  color: #000000 !important;
}

/* Dark mode base styles */
html[data-bs-theme="dark"],
html[data-theme="dark"] {
  background-color: #212529 !important;
  color: #e9ecef !important;
}

body[data-bs-theme="dark"],
body[data-theme="dark"] {
  background-color: #212529 !important;
  color: #e9ecef !important;
}

/* Main content containers - Dark mode */
html[data-bs-theme="dark"] main,
html[data-bs-theme="dark"] .main,
html[data-bs-theme="dark"] .container,
html[data-bs-theme="dark"] .container-fluid,
html[data-bs-theme="dark"] #quarto-content,
html[data-theme="dark"] main,
html[data-theme="dark"] .main,
html[data-theme="dark"] .container,
html[data-theme="dark"] .container-fluid,
html[data-theme="dark"] #quarto-content {
  background-color: #212529 !important;
  color: #e9ecef !important;
}

/* Main content containers - Light mode */
html[data-bs-theme="light"] main,
html[data-bs-theme="light"] .main,
html[data-bs-theme="light"] .container,
html[data-bs-theme="light"] .container-fluid,
html[data-bs-theme="light"] #quarto-content,
html[data-theme="light"] main,
html[data-theme="light"] .main,
html[data-theme="light"] .container,
html[data-theme="light"] .container-fluid,
html[data-theme="light"] #quarto-content,
html:not([data-bs-theme="dark"]) main,
html:not([data-bs-theme="dark"]) .main,
html:not([data-bs-theme="dark"]) .container,
html:not([data-bs-theme="dark"]) .container-fluid,
html:not([data-bs-theme="dark"]) #quarto-content {
  background-color: #ffffff !important;
  color: #000000 !important;
}

/* Code blocks - Light mode (explicit) */
html[data-bs-theme="light"] pre,
html[data-theme="light"] pre,
html:not([data-bs-theme="dark"]) pre,
html:not([data-theme="dark"]) pre {
  background-color: #f8f9fa !important;
  color: #212529 !important;
  border: 1px solid #dee2e6 !important;
  border-radius: 4px !important;
  padding: 8px !important;
}
html[data-bs-theme="light"] code,
html[data-theme="light"] code,
html:not([data-bs-theme="dark"]) code,
html:not([data-theme="dark"]) code {
  background: none !important;
  color: inherit !important;
  border: none !important;
  border-radius: 0 !important;
  padding: 0 !important;
}

html[data-bs-theme="light"] .sourceCode,
html[data-theme="light"] .sourceCode,
html:not([data-bs-theme="dark"]) .sourceCode,
html:not([data-theme="dark"]) .sourceCode {
  background-color: #f8f9fa !important;
}

/* Code blocks - Dark mode with Idle Fingers theme */
html[data-bs-theme="dark"] pre,
html[data-theme="dark"] pre {
  background-color: #323232 !important;
  color: #FFFFFF !important;
  border: 1px solid #555555 !important;
  border-radius: 4px !important;
  padding: 8px !important;
}
html[data-bs-theme="dark"] pre,
html[data-theme="dark"] pre {
  background-color: #323232 !important;
  color: #FFFFFF !important;
  border: 1px solid #555555 !important;
  border-radius: 4px !important;
  padding: 8px !important;
}
html[data-bs-theme="dark"] code,
html[data-theme="dark"] code {
  background: none !important;
  color: inherit !important;
  border: none !important;
  border-radius: 0 !important;
  padding: 0 !important;
}
html[data-theme="dark"] .sourceCode {
  background-color: #323232 !important;
  color: #FFFFFF !important;
  border-radius: 4px !important;
  padding: 12px !important;
  overflow-x: auto !important;
  font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace !important;
  font-size: 0.9em !important;
  line-height: 1.4 !important;
}

/* Code block container styling */
html[data-bs-theme="dark"] pre.sourceCode,
html[data-theme="dark"] pre.sourceCode {
  background-color: #323232 !important;
  border: 1px solid #555555 !important;
  border-radius: 6px !important;
  padding: 16px !important;
  margin: 16px 0 !important;
  box-shadow: none !important;
}
html[data-bs-theme="light"] pre.sourceCode,
html[data-theme="light"] pre.sourceCode,
html:not([data-bs-theme="dark"]) pre.sourceCode,
html:not([data-theme="dark"]) pre.sourceCode {
  background-color: #f8f9fa !important;
  border: 1px solid #dee2e6 !important;
  border-radius: 6px !important;
  padding: 16px !important;
  margin: 16px 0 !important;
  box-shadow: none !important;
}

/* Line numbers in code blocks */
html[data-bs-theme="dark"] .sourceCode .nu,
html[data-theme="dark"] .sourceCode .nu {
  color: #6C7B7F !important;
  user-select: none !important;
  margin-right: 8px !important;
}

/* Inline code styling */
html[data-bs-theme="dark"] code:not(.sourceCode),
html[data-theme="dark"] code:not(.sourceCode) {
  background-color: #424242 !important;
  color: #FFFFFF !important; /* White for consistency */
  padding: 2px 4px !important;
  border-radius: 3px !important;
  font-size: 0.9em !important;
}

/* Simple and Clean Syntax Highlighting for Dark Mode */

/* Default text color - WHITE for everything */
html[data-bs-theme="dark"] .sourceCode,
html[data-theme="dark"] .sourceCode {
  color: #FFFFFF !important;
}

/* All code elements default to WHITE */
html[data-bs-theme="dark"] .sourceCode *,
html[data-theme="dark"] .sourceCode * {
  color: #FFFFFF !important;
}

/* STRINGS - GREEN */
html[data-bs-theme="dark"] .sourceCode .st,
html[data-theme="dark"] .sourceCode .st {
  color: #A5C261 !important;
}

/* COMMENTS - ORANGE */
html[data-bs-theme="dark"] .sourceCode .co,
html[data-theme="dark"] .sourceCode .co {
  color: #C9A14A !important; /* Ochre */
  font-style: italic;
}

/* SYMBOLS and OPERATORS - LIGHT BLUE */
html[data-bs-theme="dark"] .sourceCode .op,
html[data-bs-theme="dark"] .sourceCode .sc,
html[data-bs-theme="dark"] .sourceCode .pp,
html[data-bs-theme="dark"] .sourceCode .ch,
html[data-theme="dark"] .sourceCode .op,
html[data-theme="dark"] .sourceCode .sc,
html[data-theme="dark"] .sourceCode .pp,
html[data-theme="dark"] .sourceCode .ch {
  color: #7CC7FF !important;
}

/* Line numbers - Gray */
html[data-bs-theme="dark"] .sourceCode .nu,
html[data-theme="dark"] .sourceCode .nu {
  color: #858585 !important;
  user-select: none !important;
  margin-right: 8px !important;
}

/* Headers - Light mode (explicit) */
html[data-bs-theme="light"] h1,
html[data-bs-theme="light"] h2,
html[data-bs-theme="light"] h3,
html[data-bs-theme="light"] h4,
html[data-bs-theme="light"] h5,
html[data-bs-theme="light"] h6,
html[data-theme="light"] h1,
html[data-theme="light"] h2,
html[data-theme="light"] h3,
html[data-theme="light"] h4,
html[data-theme="light"] h5,
html[data-theme="light"] h6,
html:not([data-bs-theme="dark"]) h1,
html:not([data-bs-theme="dark"]) h2,
html:not([data-bs-theme="dark"]) h3,
html:not([data-bs-theme="dark"]) h4,
html:not([data-bs-theme="dark"]) h5,
html:not([data-bs-theme="dark"]) h6,
html:not([data-theme="dark"]) h1,
html:not([data-theme="dark"]) h2,
html:not([data-theme="dark"]) h3,
html:not([data-theme="dark"]) h4,
html:not([data-theme="dark"]) h5,
html:not([data-theme="dark"]) h6 {
  color: #212529 !important;
}

/* Headers - Dark mode */
html[data-bs-theme="dark"] h1,
html[data-bs-theme="dark"] h2,
html[data-bs-theme="dark"] h3,
html[data-bs-theme="dark"] h4,
html[data-bs-theme="dark"] h5,
html[data-bs-theme="dark"] h6,
html[data-theme="dark"] h1,
html[data-theme="dark"] h2,
html[data-theme="dark"] h3,
html[data-theme="dark"] h4,
html[data-theme="dark"] h5,
html[data-theme="dark"] h6 {
  color: #f8f9fa !important;
}

/* Tables - ONLY in dark mode */
html[data-bs-theme="dark"] table,
html[data-theme="dark"] table {
  background-color: #2d3339 !important;
  color: #e9ecef !important;
  border-color: #495057 !important;
}

html[data-bs-theme="dark"] th,
html[data-theme="dark"] th {
  background-color: #495057 !important;
  color: #f8f9fa !important;
  border-color: #6c757d !important;
}

html[data-bs-theme="dark"] td,
html[data-theme="dark"] td {
  border-color: #495057 !important;
}

/* Blockquotes - ONLY in dark mode */
html[data-bs-theme="dark"] blockquote,
html[data-theme="dark"] blockquote {
  background-color: #2d3339 !important;
  border-left: 4px solid #0d6efd !important;
  color: #e9ecef !important;
}

/* Links - Light mode (explicit) */
html[data-bs-theme="light"] a,
html[data-theme="light"] a,
html:not([data-bs-theme="dark"]) a,
html:not([data-theme="dark"]) a {
  color: #0d6efd !important;
}

html[data-bs-theme="light"] a:hover,
html[data-theme="light"] a:hover,
html:not([data-bs-theme="dark"]) a:hover,
html:not([data-theme="dark"]) a:hover {
  color: #0a58ca !important;
}

/* Links - Dark mode */
html[data-bs-theme="dark"] a,
html[data-theme="dark"] a {
  color: #79c0ff !important;
}

html[data-bs-theme="dark"] a:hover,
html[data-theme="dark"] a:hover {
  color: #a5d6ff !important;
}

/* Horizontal rules - ONLY in dark mode */
html[data-bs-theme="dark"] hr,
html[data-theme="dark"] hr {
  border-color: #495057 !important;
}

/* Callout boxes and alerts - ONLY in dark mode */
html[data-bs-theme="dark"] .callout,
html[data-theme="dark"] .callout {
  background-color: #2d3339 !important;
  border-color: #495057 !important;
}

html[data-bs-theme="dark"] .alert,
html[data-theme="dark"] .alert {
  background-color: #2d3339 !important;
  border-color: #495057 !important;
  color: #e9ecef !important;
}

/* Navigation and UI elements - ONLY in dark mode */
html[data-bs-theme="dark"] .navbar,
html[data-theme="dark"] .navbar {
  background-color: #1a1d20 !important;
}

html[data-bs-theme="dark"] .navbar-light .navbar-nav .nav-link,
html[data-theme="dark"] .navbar-light .navbar-nav .nav-link {
  color: #e9ecef !important;
}

/* Dropdown menus - ONLY in dark mode */
html[data-bs-theme="dark"] .dropdown-menu,
html[data-theme="dark"] .dropdown-menu {
  background-color: #2d3339 !important;
  border-color: #495057 !important;
}

html[data-bs-theme="dark"] .dropdown-item,
html[data-theme="dark"] .dropdown-item {
  color: #e9ecef !important;
}

html[data-bs-theme="dark"] .dropdown-item:hover,
html[data-theme="dark"] .dropdown-item:hover {
  background-color: #495057 !important;
}

/* Print media - keep light theme for printing */
@media print {
  html, body {
    background-color: white !important;
    color: black !important;
  }

  pre, code {
    background-color: #f8f9fa !important;
    color: black !important;
  }

  h1, h2, h3, h4, h5, h6 {
    color: black !important;
  }
}

/* Theme toggle button (if added to documents) */
.theme-toggle {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 1000;
  background-color: #495057;
  color: #e9ecef;
  border: none;
  padding: 10px;
  border-radius: 50%;
  cursor: pointer;
  transition: background-color 0.3s;
}

.theme-toggle:hover {
  background-color: #6c757d;
}

/* Auto-detection script for smooth transitions */
.theme-transition {
  transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

/* --- SINGLE BORDER FOR CODE SNIPPETS: ONLY pre.sourceCode --- */

html[data-bs-theme="light"] pre,
html[data-theme="light"] pre,
html:not([data-bs-theme="dark"]) pre,
html:not([data-theme="dark"]) pre,
html[data-bs-theme="light"] .sourceCode,
html[data-theme="light"] .sourceCode,
html:not([data-bs-theme="dark"]) .sourceCode,
html:not([data-theme="dark"]) .sourceCode,
html[data-bs-theme="dark"] pre,
html[data-theme="dark"] pre,
html[data-bs-theme="dark"] .sourceCode,
html[data-theme="dark"] .sourceCode {
  background: none !important;
  border: none !important;
  box-shadow: none !important;
  padding: 0 !important;
  margin: 0 !important;
}

html[data-bs-theme="light"] pre.sourceCode,
html[data-theme="light"] pre.sourceCode,
html:not([data-bs-theme="dark"]) pre.sourceCode,
html:not([data-theme="dark"]) pre.sourceCode {
  background-color: #f8f9fa !important;
  color: #212529 !important;
  border: 1px solid #dee2e6 !important;
  border-radius: 4px !important;
  box-shadow: none !important;
  padding: 12px !important;
  margin: 16px 0 !important;
}

html[data-bs-theme="dark"] pre.sourceCode,
html[data-theme="dark"] pre.sourceCode {
  background-color: #23272b !important;
  color: #FFFFFF !important;
  border: 1px solid #555555 !important;
  border-radius: 4px !important;
  box-shadow: none !important;
  padding: 12px !important;
  margin: 16px 0 !important;
}

html[data-bs-theme="light"] code,
html[data-theme="light"] code,
html:not([data-bs-theme="dark"]) code,
html:not([data-theme="dark"]) code,
html[data-bs-theme="dark"] code,
html[data-theme="dark"] code {
  background: none !important;
  color: inherit !important;
  border: none !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  padding: 0 !important;
  margin: 0 !important;
}

/* --- END SINGLE BORDER FOR CODE SNIPPETS --- */

/* --- DARK MODE CODE FONT SIZE AND FAMILY --- */
html[data-bs-theme="dark"] pre.sourceCode,
html[data-theme="dark"] pre.sourceCode {
  font-size: 1.08em !important;
  font-family: 'Fira Mono', 'JetBrains Mono', 'Menlo', 'Monaco', 'Consolas', 'Liberation Mono', 'Courier New', monospace !important;
}
/* --- END DARK MODE CODE FONT SIZE AND FAMILY --- */
