/* ============================================================
   FlightPlan Dokumentation – Layout mit Sidebar & Suche
   ============================================================ */

:root {
  --doc-bg: #f7f9fc;
  --doc-surface: #ffffff;
  --doc-surface-raised: #ffffff;
  --doc-border: #e5e7eb;
  --doc-text: #1f2933;
  --doc-heading: #0f172a;
  --doc-muted: #5b6472;
  --doc-link: #2c5ef6;
  --doc-link-hover: #1d3fc7;
  --doc-accent: #2c5ef6;
  --doc-accent-soft: rgba(44, 94, 246, 0.1);
  --doc-active-bg: rgba(44, 94, 246, 0.12);
  --doc-shadow: 0 8px 30px rgba(15, 23, 42, 0.07);
  --doc-radius: 14px;
  --doc-sidebar-width: 272px;
}

/* ── Night-Mode Overrides ──────────────────────────────────────────────── */
body.night-mode {
  --doc-bg: #0b1220;
  --doc-surface: #131c2e;
  --doc-surface-raised: #17223a;
  --doc-border: rgba(120, 138, 168, 0.22);
  --doc-text: #e4e6ea;
  --doc-heading: #f4f5f7;
  --doc-muted: #a9b1c2;
  --doc-link: #7dd3fc;
  --doc-link-hover: #bae6fd;
  --doc-accent: #7dd3fc;
  --doc-accent-soft: rgba(125, 211, 252, 0.12);
  --doc-active-bg: rgba(125, 211, 252, 0.14);
  --doc-shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
}

body.night-mode code,
body.night-mode pre {
  background-color: rgba(15, 23, 42, 0.7);
  border-color: rgba(71, 85, 105, 0.5);
  color: #cbd5e1;
}

body.night-mode .info-box {
  background-color: rgba(14, 59, 109, 0.45);
  border-left-color: #7dd3fc;
  color: #e4e6ea;
}

body.night-mode .warning-box {
  background-color: rgba(100, 66, 0, 0.4);
  border-left-color: #fbbf24;
  color: #e4e6ea;
}
/* ─────────────────────────────────────────────────────────────────────── */

body.doc-page {
  background: var(--doc-bg);
  color: var(--doc-text);
}

body.doc-page main {
  padding: 0;
}

/* Outer wrapper coming from base.html (<main class="container">) */
.container {
  max-width: 1320px;
  margin: 0 auto;
  padding: 20px 20px 60px;
}

/* ============================================================
   Shell: Sidebar + Content grid
   ============================================================ */
.docs-shell {
  display: grid;
  grid-template-columns: var(--doc-sidebar-width) minmax(0, 1fr);
  gap: 28px;
  align-items: start;
}

/* ============================================================
   Sidebar
   ============================================================ */
.docs-sidebar {
  position: sticky;
  top: 16px;
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  background: var(--doc-surface);
  border: 1px solid var(--doc-border);
  border-radius: var(--doc-radius);
  padding: 18px 16px 22px;
  box-shadow: var(--doc-shadow);
  scrollbar-width: thin;
}

.docs-sidebar-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
  font-size: 1rem;
  color: var(--doc-heading);
  margin: 0 0 14px;
  padding: 0 2px;
}

.docs-sidebar-title a {
  color: inherit;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ── Search ─────────────────────────────────────────────────── */
.docs-search {
  position: relative;
  margin-bottom: 18px;
}

.docs-search-icon {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  opacity: 0.55;
  pointer-events: none;
  font-size: 0.9rem;
}

.docs-search input[type="search"] {
  width: 100%;
  box-sizing: border-box;
  padding: 10px 34px 10px 32px;
  border-radius: 10px;
  border: 1px solid var(--doc-border);
  background: var(--doc-bg);
  color: var(--doc-text);
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.docs-search input[type="search"]::-webkit-search-cancel-button {
  display: none;
}

.docs-search input[type="search"]:focus {
  border-color: var(--doc-accent);
  box-shadow: 0 0 0 3px var(--doc-accent-soft);
}

.docs-search-clear {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  border: none;
  background: none;
  color: var(--doc-muted);
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 6px;
  display: none;
}

.docs-search-clear:hover {
  background: var(--doc-active-bg);
}

.docs-search.has-value .docs-search-clear {
  display: block;
}

.docs-search-results {
  position: absolute;
  z-index: 40;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: var(--doc-surface-raised);
  border: 1px solid var(--doc-border);
  border-radius: 12px;
  box-shadow: var(--doc-shadow);
  max-height: 60vh;
  overflow-y: auto;
  padding: 6px;
  display: none;
}

.docs-search-results.open {
  display: block;
}

.docs-search-group-label {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--doc-muted);
  padding: 8px 10px 4px;
}

.docs-search-result {
  display: block;
  padding: 8px 10px;
  border-radius: 8px;
  text-decoration: none;
  color: var(--doc-text);
  font-size: 0.87rem;
  line-height: 1.35;
  cursor: pointer;
}

.docs-search-result strong {
  color: var(--doc-heading);
  font-weight: 600;
}

.docs-search-result small {
  display: block;
  color: var(--doc-muted);
  font-size: 0.74rem;
  margin-top: 1px;
}

.docs-search-result:hover,
.docs-search-result.is-active {
  background: var(--doc-active-bg);
}

.docs-search-empty {
  padding: 14px 10px;
  color: var(--doc-muted);
  font-size: 0.85rem;
  text-align: center;
}

/* ── Nav groups ─────────────────────────────────────────────── */
.docs-nav-section {
  margin-bottom: 4px;
}

.docs-nav-label {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--doc-muted);
  margin: 18px 6px 6px;
}

.docs-nav-section:first-of-type .docs-nav-label {
  margin-top: 4px;
}

.docs-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.doc-link {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border-radius: 9px;
  font-size: 0.88rem;
  font-weight: 500;
  text-decoration: none;
  color: var(--doc-text);
  border: 1px solid transparent;
  transition: background 0.12s, color 0.12s;
  white-space: normal;
}

.doc-link .doc-link-icon {
  flex-shrink: 0;
  font-size: 0.95rem;
  line-height: 1;
}

.doc-link:hover {
  background: var(--doc-accent-soft);
  color: var(--doc-accent);
}

.doc-link.active {
  background: var(--doc-active-bg);
  color: var(--doc-accent);
  font-weight: 700;
}

.docs-nav-divider {
  border: none;
  border-top: 1px solid var(--doc-border);
  margin: 14px 2px;
}

/* ── Mobile sidebar toggle ──────────────────────────────────── */
.docs-sidebar-toggle {
  display: none;
  align-items: center;
  gap: 8px;
  width: 100%;
  box-sizing: border-box;
  padding: 12px 16px;
  margin-bottom: 16px;
  border-radius: 12px;
  border: 1px solid var(--doc-border);
  background: var(--doc-surface);
  color: var(--doc-heading);
  font-weight: 600;
  font-size: 0.92rem;
  cursor: pointer;
  box-shadow: var(--doc-shadow);
}

.docs-sidebar-backdrop {
  display: none;
}

/* ============================================================
   Content column
   ============================================================ */
.docs-main {
  min-width: 0;
}

.docs-content {
  background: var(--doc-surface);
  border: 1px solid var(--doc-border);
  border-radius: var(--doc-radius);
  padding: 28px 32px 40px;
  box-shadow: var(--doc-shadow);
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
  color: var(--doc-heading);
  line-height: 1.3;
}

.docs-content > *:first-child {
  margin-top: 0;
}

.docs-content > h1 {
  font-size: 1.85rem;
  margin: 0 0 22px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--doc-border);
}

/* Auf einigen Seiten steht das Inhaltsverzeichnis vor der Überschrift */
.docs-content > .toc:first-child {
  margin-top: 0;
}

h2 { font-size: 1.4rem; margin-top: 34px; margin-bottom: 14px; }
h3 { font-size: 1.15rem; margin-top: 22px; margin-bottom: 10px; }

p {
  line-height: 1.65;
  margin-bottom: 15px;
  color: var(--doc-text);
}

ol, ul {
  margin-bottom: 18px;
  padding-left: 26px;
}

ol li, ul li {
  margin-bottom: 7px;
  line-height: 1.55;
  color: var(--doc-text);
}

ol { counter-reset: step-counter; }
ol li { counter-increment: step-counter; }
ol li::marker { color: var(--doc-accent); font-weight: 700; }

code {
  background-color: var(--doc-bg);
  color: var(--doc-heading);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: "Courier New", Courier, monospace;
  font-size: 0.87em;
  border: 1px solid var(--doc-border);
}

pre {
  background-color: var(--doc-bg);
  padding: 15px;
  border-radius: 10px;
  overflow-x: auto;
  margin-bottom: 20px;
  border: 1px solid var(--doc-border);
}

pre code { background: none; border: none; padding: 0; font-size: 0.85em; }

hr {
  border: none;
  height: 1px;
  background-color: var(--doc-border);
  margin: 25px 0;
}

table {
  border-collapse: collapse;
}

th, td {
  border-bottom: 1px solid var(--doc-border);
}

/* Documentation Sections */
.doc-section {
  margin-bottom: 34px;
  padding-bottom: 18px;
}

.doc-section:not(:last-child) {
  border-bottom: 1px solid var(--doc-border);
}

/* Info / warning callouts */
.info-box {
  background-color: var(--doc-accent-soft);
  border-left: 4px solid var(--doc-accent);
  padding: 14px 16px;
  margin: 18px 0;
  border-radius: 0 10px 10px 0;
}

.warning-box {
  background-color: rgba(245, 158, 11, 0.12);
  border-left: 4px solid #f59e0b;
  padding: 14px 16px;
  margin: 18px 0;
  border-radius: 0 10px 10px 0;
}

body.night-mode .info-box,
body.night-mode .warning-box {
  background-color: var(--doc-accent-soft);
}

/* Links within Documentation */
.docs-content a:not(.doc-link):not(.docs-search-result) {
  color: var(--doc-link);
  text-decoration: underline;
  text-decoration-color: rgba(44, 94, 246, 0.35);
  text-underline-offset: 2px;
}

.docs-content a:not(.doc-link):not(.docs-search-result):hover {
  color: var(--doc-link-hover);
}

/* Table of Contents */
.toc {
  background-color: var(--doc-bg);
  padding: 16px 20px;
  border-radius: 10px;
  margin-bottom: 26px;
  border: 1px solid var(--doc-border);
}

.toc h3 {
  margin: 0 0 10px;
  font-size: 0.95rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--doc-muted);
}

.toc ul { margin-bottom: 0; padding-left: 18px; }
.toc a { color: var(--doc-link); text-decoration: none; }
.toc a:hover { text-decoration: underline; }

/* Quick links (Schnellzugriff etc.) */
.doc-subnav {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 10px;
  padding: 4px 0;
}

.doc-subnav .doc-link {
  border: 1px solid var(--doc-border);
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 980px) {
  .docs-shell {
    display: block;
  }

  .docs-sidebar-toggle {
    display: flex;
  }

  .docs-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    max-height: none;
    width: min(320px, 86vw);
    z-index: 60;
    border-radius: 0;
    transform: translateX(-105%);
    transition: transform 0.22s ease;
    box-shadow: 12px 0 30px rgba(0, 0, 0, 0.25);
  }

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

  .docs-sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    z-index: 55;
  }

  .docs-sidebar-backdrop.open {
    display: block;
  }

  .docs-content {
    padding: 22px 18px 32px;
  }
}

@media (max-width: 768px) {
  .container { margin: 0; padding: 12px 12px 40px; }

  .docs-content > h1:first-child { font-size: 1.5rem; }
  h2 { font-size: 1.2rem; }
  h3 { font-size: 1.05rem; }

  ol, ul { padding-left: 20px; }

  code { font-size: 0.8rem; word-break: break-word; }
  pre { padding: 10px; font-size: 0.78rem; }

  .doc-subnav { flex-direction: column; gap: 6px; }
  .doc-subnav .doc-link { justify-content: center; }
}

@media (max-width: 480px) {
  .docs-content { padding: 16px 14px 26px; }
  .docs-content > h1:first-child { font-size: 1.3rem; }
  h2 { font-size: 1.1rem; }
}

/* Word-wrap for long strings */
.docs-content p,
.docs-content li,
.docs-content a,
.docs-content h1,
.docs-content h2,
.docs-content h3,
.docs-content h4 {
  overflow-wrap: anywhere;
  word-break: break-word;
}

.container { overflow-x: hidden; }

/* Print Styles */
@media print {
  .docs-sidebar, .docs-sidebar-toggle, .docs-sidebar-backdrop { display: none; }
  .docs-shell { display: block; }
  .docs-content { box-shadow: none; border: none; padding: 0; }
  h1, h2, h3 { color: black; }
  a { color: black; text-decoration: underline; }
}
