:root {
    --bg-main: #1e272e;        /* Dunkler Hintergrund aus dem Screenshot */
    --bg-sidebar: #161d22;     /* Etwas dunklere Sidebar */
    --text-primary: #dcdde1;   /* Hellgrauer Text */
    --accent-blue: #3498db;    /* Das Blau der Ueberschriften */
    --code-bg: #1b2127;
    --nav-hover: #2c3e50;
    --padding-top-global: 40px; /* Einheitlicher Abstand fuer Buendigkeit */
}

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

body {
    font-family: 'Segoe UI', sans-serif;
    background-color: var(--bg-main);
    color: var(--text-primary);
    line-height: 1.6;
}

/* Tabellen-Styles */
table {
    width: 100%;
    table-layout: fixed; /* Dies erzwingt die gleichmäßige Spaltenbreite */
    border-collapse: collapse; /* Verhindert doppelte Rahmen */
    margin: 25px 0;
    background-color: var(--code-bg); /* Nutzt die dunkle Farbe der Code-Blöcke */
    border: 1px solid #2f3640;
    font-size: 0.95rem;
}

th, td {
    border: 1px solid #2f3640;
    padding: 12px 15px;
    text-align: left;
    overflow: hidden; /* Verhindert, dass langer Text das Layout sprengt */
    text-overflow: ellipsis; /* Fügt ... bei zu langem Text hinzu */
    word-wrap: break-word; /* Bricht lange Wörter um */
}

/* Tabellenkopf */
th {
    background-color: var(--nav-hover);
    color: var(--accent-blue);
    font-weight: bold;
    text-transform: uppercase;
    font-size: 0.8rem;
    letter-spacing: 1px;
}

/* Zebrastreifen für bessere Lesbarkeit */
tr:nth-child(even) {
    background-color: rgba(255, 255, 255, 0.03);
}

/* Farben für die Risikomatrix */
.bg-red    { background-color: #c0392b !important; color: #ffffff; }
.bg-yellow { background-color: #f1c40f !important; color: #000000; }
.bg-green  { background-color: #27ae60 !important; color: #ffffff; }

/* Unterstützung für linke Kopfzeilen */
table tbody th {
    background-color: var(--nav-hover);
    color: var(--accent-blue);
    font-weight: bold;
    text-align: left;
    border: 1px solid #2f3640;
    width: 25%; /* Optionale feste Breite für die linke Spalte */
}

/* Layout-Struktur */
.wrapper {
    display: grid;
    grid-template-columns: 1fr; /* Mobile: Eine Spalte */
}

/* Sidebar */
#sidebar {
    background-color: var(--bg-sidebar);
    padding: var(--padding-top-global) 25px 20px 25px;
}

/* Hauptinhalt */
main {
    padding: var(--padding-top-global) 20px;
    width: 100%;
    /* Hier wird die maximale Breite und Zentrierung definiert */
    max-width: 850px; 
    margin-left: auto;
    margin-right: auto;
}

/* DESKTOP ANPASSUNGEN */
@media (min-width: 992px) {
    .wrapper {
        /* Wir erstellen 3 Spalten: 
           1. Die Sidebar (fest)
           2. Der Inhaltsbereich (flexibel, aber zentriert)
        */
        grid-template-columns: 300px 1fr;
        min-height: 100vh;
    }

    #sidebar {
        height: 100vh;
        position: sticky;
        top: 0;
        border-right: 1px solid #2f3640;
    }

    main {
        /* Auf Desktop sorgen wir dafür, dass der Inhalt 
           innerhalb des verbleibenden Platzes mittig sitzt */
        padding: var(--padding-top-global) 60px;
        margin-left: auto;
        margin-right: auto;
    }
}

h1, .nav-title {
    margin-top: 0; /* Verhindert vertikalen Versatz */
    color: var(--accent-blue);
    font-size: 1.8rem;
    margin-bottom: 25px;
}

h2 {
    color: var(--accent-blue);
    font-size: 1.4rem;
    margin-bottom: 25px;
}

h3 {
    color: var(--accent-blue);
    font-size: 1.2rem;
    margin-bottom: 25px;
}

a {
    color: var(--accent-blue);
}


/* Navigation-Links */
nav ul { list-style: none; }
nav li { margin: 5px 0; }
nav a {
    color: #a4b0be;
    text-decoration: none;
    display: block;
    padding: 8px 12px;
    border-radius: 4px;
    transition: 0.2s;
}
nav a.small {
    font-size: 0.8rem;
    color: #7f8c8d;
    display: block;      /* Erlaubt dem Hintergrund, die Breite zu füllen */
    padding: 8px 12px;   /* Erzeugt den Raum für die "Unterlegung" */
    border-radius: 4px;  /* Optionale Abrundung wie bei den großen Links */
    margin-top: 5px;
    transition: all 0.2s ease; /* Macht den Farbwechsel geschmeidig */
}


nav a:hover, nav a.active {
    background: var(--nav-hover) !important;
    color: #fff !important;
}

/* Einrueckung der Ebenen */
nav ul ul { margin-left: 20px; font-size: 0.95rem; }

ol { display: block; padding-left: 20px; }

ul { display: block; padding-left: 20px; }

/* Code-Block Design nach Screenshot */
.code-block {
    background: var(--code-bg);
    border: 1px solid #2f3640;
    border-radius: 8px;
    margin: 20px 0;
    padding: 5px;
    padding-top: 0px;
}

.code-header {
    color: #7f8c8d;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 15px;
    border-bottom: 1px solid #2f3640;
    padding-bottom: 10px;
}

/* Mobile Menü-Button (standardmäßig versteckt) */
#menu-toggle {
    display: none;
    background: var(--accent-blue);
    color: white;
    border: none;
    padding: 10px 20px;
    width: 100%;
    cursor: pointer;
    font-weight: bold;
}

/* RESPONSIVE DESIGN */
@media (min-width: 992px) {
    .wrapper {
        grid-template-columns: 300px 1fr;
        min-height: 100vh;
    }
    #sidebar {
        height: 100vh;
        position: sticky;
        top: 0;
    }
}

@media (max-width: 991px) {
    #menu-toggle { display: block; } /* Button auf Mobile zeigen */
    #sidebar-content {
        display: none; /* Menue standardmaessig zu auf Mobile */
        padding-top: 20px;
    }
    #sidebar-content.active { display: block; }
}

/* Responsive Bilder */
main img {
    cursor: zoom-in;
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    margin: 20px 0;
    border: 1px solid #2f3640;
}

/* Das Hintergrund-Overlay */
.lightbox {
    display: none; /* Standardmäßig versteckt */
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(22, 29, 34, 0.95); /* Passend zu Ihrer Sidebar-Farbe */
    justify-content: center;
    align-items: center;
    flex-direction: column;
}

/* Das vergrößerte Bild */
.lightbox-img {
    max-width: 90%;
    max-height: 80%;
    box-shadow: 0 0 20px rgba(0,0,0,0.5);
    border-radius: 4px;
    animation: zoom 0.3s;
}

/* Animation beim Öffnen */
@keyframes zoom {
    from {transform: scale(0.95); opacity: 0;}
    to {transform: scale(1); opacity: 1;}
}

/* Schließen-Button */
.lightbox-close {
    position: absolute;
    top: 20px;
    right: 35px;
    color: var(--text-primary);
    font-size: 40px;
    font-weight: bold;
    cursor: pointer;
}

/* Bildunterschrift im Modal */
#lightbox-caption {
    margin-top: 15px;
    color: var(--accent-blue);
    font-weight: bold;
}

/* Spezielle Korrektur, wenn ein Bild in einem Figure-Container ist */
figure {
    margin: 30px 0; /* Abstand des gesamten Blocks zum restlichen Text */
    text-align: center;
}

figure img {
    margin-bottom: 8px; /* Deutlich kleinerer Abstand zur Bildunterschrift */
}

figcaption {
    font-size: 0.85rem;
    color: #7f8c8d;
    text-align: left; /* Oder center, falls gewünscht */
    margin-top: 0; 
    font-style: italic;
    line-height: 1.4;
}

/* Ergänzung in der style.css */
pre {
    background-color: var(--code-bg);
    padding: 5px;
    
    /* Die Lösung für das Überlaufen: */
    overflow-x: auto;  /* Scrollbalken erscheint nur bei Bedarf */
    white-space: pre;  /* Behält Leerzeichen und Umbrüche exakt bei */
    border: none;
}

/* Optional: Den Scrollbalken dezent stylen, damit er zum Dark-Mode passt */
pre::-webkit-scrollbar {
    height: 8px;
}
pre::-webkit-scrollbar-thumb {
    background: #34495e;
}
pre::-webkit-scrollbar-thumb:hover {
    background: var(--accent-blue);
}
