/* =========================================================
   1) LAYOUT-FIX FÜR DIE SPHINX-BOOTSTRAP-THEME-SPALTEN
   ---------------------------------------------------------
   Problem aus dem Screenshot:
   - Theme legt ein 2-Spalten-Bootstrap-Grid an:
        .col-lg-3  (Sidebar / TOC)
        .col-lg-9  (eigentliche Seite)
   - Auf Desktop verschiebt das Theme die Sidebar nach oben,
     aber lässt die linke 3er-Spalte trotzdem "reserviert".
     => riesige linke Lücke, Content schmal und nach rechts verschoben.

   Lösung:
   - Sidebar-Spalte komplett verstecken ab Desktop
   - Content-Spalte auf volle Breite ziehen, linksbündig machen
   ========================================================= */

@media (min-width: 992px) {
  /* Sidebar-/TOC-Spalte ausblenden (egal ob col-md-3 oder col-lg-3) */
  .row > .col-md-3,
  .row > .col-lg-3,
  #sidebar,
  .sphinxsidebar {
    display: none !important;
  }

  /* Haupt-Content-Spalte auf volle Breite ziehen */
  .row > .col-md-9[role="main"],
  .row > .col-lg-9[role="main"],
  .col-md-9.content,
  .col-lg-9.content,
  [role="main"].col-md-9,
  [role="main"].col-lg-9 {
    float: none !important;
    width: auto !important;
    max-width: 1100px !important;

    /* schöner linksbündiger Look mit etwas Rand */
    margin-left: 2rem !important;
    margin-right: 2rem !important;
  }

  /* Der eigentliche Textkörper */
  .row > .col-md-9[role="main"] .body,
  .row > .col-lg-9[role="main"] .body,
  .body,
  .document,
  .body > .section,
  .rst-content {
    max-width: 1100px !important;
    margin: 0 !important;
    padding-right: 24px;
  }
}

/* Auf kleineren Screens (unter 992px) einfach Standardverhalten lassen */
@media (max-width: 991.98px) {
  /* nichts besonderes, aber falls Sidebar da doch floated, normalisieren */
  .sphinxsidebar,
  #sidebar {
    width: auto !important;
    float: none !important;
    border-right: 0;
    box-shadow: none;
  }
}

/* =========================================================
   2) TYPO / LESBARKEIT
   ========================================================= */

.rst-content p,
.rst-content li {
  line-height: 1.55;
  word-break: break-word;
}

.rst-content code,
.rst-content tt,
.rst-content kbd {
  white-space: normal !important;
  overflow-wrap: anywhere !important;
  word-break: break-word !important;
}

/* =========================================================
   3) SIGNATUREN (Funktionen / Klassen / Methoden)
   Ziel:
   - Kein hässliches Floaten vom [source]-Link über dem Text
   - Signaturblock als schöne Box
   ========================================================= */

/* Grundsätzlich: keine Floats für Signatur-Definitionen */
.rst-content dl:not(.footnote):not(.citation) dt {
  float: none !important;
  width: auto !important;
}

.rst-content dl:not(.footnote):not(.citation) dd {
  margin-left: 0 !important;
}

/* Signatur-Box selber */
dt.sig,
.rst-content dl.py.class > dt,
.rst-content dl.py.method > dt,
.rst-content dl.py.function > dt,
.rst-content dl.class > dt,
.rst-content dl.method > dt,
.rst-content dl.function > dt {
  display: block !important;
  clear: both !important;
  max-width: 100% !important;
  box-sizing: border-box !important;
  overflow: hidden; /* enthält den [source]-Link */

  margin: .6rem 0 .4rem 0 !important;
  padding: .35rem .75rem !important;

  border: 1px solid #e5e7eb;
  background: #fffbe6; /* leicht gelb wie Sphinx kennt */
  border-radius: 6px;
  font-family: Consolas, Menlo, monospace;
  font-size: 0.9rem;
  line-height: 1.4;
}

/* [source]-Link schön nach rechts, aber nicht überlappend */
dt.sig .viewcode-link {
  float: right;
  margin-left: .6rem;
  white-space: nowrap;
  font-size: 0.8rem;
  font-weight: 600;
}

/* Platz nach der Signatur */
dt.sig + dd,
dt.sig + p,
dt.sig + dd > p:first-child {
  clear: both !important;
  margin-top: .75rem !important;
}

/* =========================================================
   4) CODEBLÖCKE
   ========================================================= */

pre,
.highlight pre {
  overflow-x: auto;
  line-height: 1.45;
}

/* Optik von Code-Blöcken */
pre {
  background: #f8f9fa;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 10px;
  font-size: 0.85rem;
}

/* Inline code */
code {
  background: #f8f9fa;
  padding: 2px 4px;
  border-radius: 4px;
  font-size: 0.85rem;
  border: 1px solid #e5e7eb;
}

/* =========================================================
   5) COLLAPSIBLE CODE (falls du collapse_code.js nutzt)
   ========================================================= */

details.code-collapse {
  border: 1px solid #d1d5db;
  border-radius: 6px;
  background: #f8f9fa;
  margin: 1rem 0;
  box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

details.code-collapse[open] {
  background: #ffffff;
}

.code-collapse-summary {
  cursor: pointer;
  font-family: monospace;
  font-size: 0.9rem;
  font-weight: 600;
  padding: 0.6rem 0.8rem;
  border-bottom: 1px solid #d1d5db;
  list-style: none;
}

.code-collapse-summary::-webkit-details-marker {
  display: none;
}

.code-content {
  padding: 0.8rem;
  overflow-x: auto;
}

.code-content .highlight,
.code-content .viewcode-block {
  margin: 0;
}
