/* Qonda Reports — Documentation Viewer Styles */

/* ── Light mode (default) ────────────────────────────── */
:root {
  --nav-bg:         #1b2d3e;
  --nav-text:       #e4edf5;
  --accent:         #29ABE2;
  --accent-dark:    #1a8bbf;
  --accent-faint:   #e8f5fb;
  --sidebar-bg:     #f4f6f8;
  --sidebar-border: #dde3ea;
  --content-bg:     #ffffff;
  --text:           #2c3e50;
  --text-muted:     #6b7c8f;
  --border:         #e0e6ec;
  --code-bg:        #f0f4f8;
  --code-color:     #c0392b;
  --heading:        #1b2d3e;
  --table-head-bg:  #1b2d3e;
  --blockquote-bg:  #f0f8fd;
  --toggle-icon:    "☀";
}

/* ── Dark mode ───────────────────────────────────────── */
html.dark {
  --nav-bg:         #0c1825;
  --nav-text:       #c8daea;
  --accent-faint:   #082336;
  --sidebar-bg:     #101f2d;
  --sidebar-border: #1c3147;
  --content-bg:     #0d1b28;
  --text:           #b8cedf;
  --text-muted:     #5a7a8f;
  --border:         #1c3147;
  --code-bg:        #071420;
  --code-color:     #e06c75;
  --heading:        #d8eaf6;
  --table-head-bg:  #071420;
  --blockquote-bg:  #071e2e;
  --toggle-icon:    "☽";
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
  color: var(--text);
  background: var(--content-bg);
}

body {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ── Top nav ─────────────────────────────────────────── */

.topnav {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 52px;
  padding: 0 20px;
  background: var(--nav-bg);
  flex-shrink: 0;
}

.topnav-brand {
  display: flex;
  align-items: center;
  gap: 9px;
  text-decoration: none;
}

.topnav-brand img {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: block;
}

.topnav-brand-name {
  color: #fff;
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.topnav-divider {
  color: var(--nav-text);
  opacity: 0.35;
  font-size: 1.1rem;
  font-weight: 300;
}

.topnav-section {
  color: var(--nav-text);
  opacity: 0.65;
  font-size: 0.85rem;
}

.topnav-spacer {
  flex: 1;
}

.theme-toggle {
  background: none;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 6px;
  color: var(--nav-text);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  font-size: 0.8rem;
  opacity: 0.8;
  transition: opacity 0.15s, border-color 0.15s;
  white-space: nowrap;
}

.theme-toggle:hover {
  opacity: 1;
  border-color: rgba(255, 255, 255, 0.4);
}

.theme-toggle svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

/* ── Layout ──────────────────────────────────────────── */

.layout {
  display: flex;
  flex: 1;
  min-height: 0;
}

/* ── Sidebar ─────────────────────────────────────────── */

.sidebar {
  width: 248px;
  flex-shrink: 0;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  overflow-y: auto;
  padding: 14px 0 24px;
}

.sidebar-group {
  margin-top: 6px;
}

.sidebar-group-label {
  padding: 10px 18px 4px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.sidebar a {
  display: block;
  padding: 7px 18px;
  font-size: 0.875rem;
  color: var(--text);
  text-decoration: none;
  border-left: 3px solid transparent;
  transition: background 0.12s, color 0.12s;
  line-height: 1.3;
}

.sidebar a:hover {
  background: rgba(41, 171, 226, 0.09);
  color: var(--accent-dark);
}

.sidebar a.active {
  color: var(--accent-dark);
  background: var(--accent-faint);
  border-left-color: var(--accent);
  font-weight: 500;
}

/* ── Content ─────────────────────────────────────────── */

.content {
  flex: 1;
  overflow-y: auto;
  padding: 40px 52px 60px;
}

.md-body {
  max-width: 800px;
}

/* ── Markdown rendering ──────────────────────────────── */

.md-body h1 {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--heading);
  padding-bottom: 12px;
  border-bottom: 2px solid var(--accent);
  margin-bottom: 20px;
}

.md-body h2 {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--heading);
  margin: 36px 0 12px;
  padding-bottom: 7px;
  border-bottom: 1px solid var(--border);
}

.md-body h3 {
  font-size: 0.975rem;
  font-weight: 600;
  color: var(--heading);
  margin: 24px 0 8px;
}

.md-body h4 {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-muted);
  margin: 16px 0 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.md-body p {
  font-size: 0.925rem;
  line-height: 1.75;
  margin-bottom: 14px;
}

.md-body ul,
.md-body ol {
  padding-left: 22px;
  margin-bottom: 14px;
}

.md-body li {
  font-size: 0.925rem;
  line-height: 1.7;
  margin-bottom: 4px;
}

.md-body li > ul,
.md-body li > ol {
  margin-top: 4px;
  margin-bottom: 4px;
}

.md-body strong {
  font-weight: 600;
  color: var(--heading);
}

.md-body code {
  font-family: 'Cascadia Code', 'Fira Code', 'Consolas', 'Courier New', monospace;
  font-size: 0.83em;
  background: var(--code-bg);
  color: var(--code-color);
  padding: 2px 6px;
  border-radius: 3px;
  border: 1px solid var(--border);
}

.md-body pre {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 16px 18px;
  overflow-x: auto;
  margin-bottom: 18px;
}

.md-body pre code {
  background: none;
  color: inherit;
  padding: 0;
  border: none;
  font-size: 0.85rem;
}

.md-body blockquote {
  border-left: 3px solid var(--accent);
  background: var(--blockquote-bg);
  padding: 10px 16px;
  margin-bottom: 16px;
  border-radius: 0 4px 4px 0;
  color: var(--text-muted);
  font-size: 0.9rem;
  font-style: italic;
}

.md-body blockquote p {
  margin-bottom: 0;
}

.md-body blockquote.blockquote-warning {
  border-left-color: #e67e22;
  background: #fff8f0;
  color: var(--text);
  font-style: normal;
}

.dark .md-body blockquote.blockquote-warning {
  border-left-color: #e67e22;
  background: #261a08;
  color: var(--text);
}

.md-body table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
  margin-bottom: 18px;
}

.md-body thead th {
  background: var(--table-head-bg);
  color: #fff;
  padding: 9px 12px;
  text-align: left;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.md-body tbody td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

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

.md-body tbody tr:hover td {
  background: var(--accent-faint);
}

.md-body a {
  color: var(--accent-dark);
  text-decoration: none;
}

.md-body a:hover {
  text-decoration: underline;
}

.md-body hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 32px 0;
}

/* ── States ──────────────────────────────────────────── */

.state-msg {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9rem;
  padding: 60px 0;
}

.state-error {
  background: #fdf3f2;
  border: 1px solid #f5c6c2;
  border-radius: 5px;
  color: #a93226;
  font-size: 0.875rem;
  line-height: 1.6;
  padding: 14px 18px;
}

.state-error code {
  background: rgba(0, 0, 0, 0.06);
  color: inherit;
  border: none;
}

/* ── Dark mode overrides ─────────────────────────────── */

/* Tone down the highlight.js github theme in dark mode */
html.dark .hljs {
  background: var(--code-bg);
  color: #abb2bf;
}

html.dark .state-error {
  background: #1f0e0e;
  border-color: #5c2020;
  color: #e07070;
}

html.dark .state-error code {
  background: rgba(255, 255, 255, 0.06);
}
