/* =================================
   1. GRUNDSTILE (für das gesamte Projekt)
   ================================= */
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    line-height: 1.6;
    background-color: #f4f4f4;
    color: #333;
    margin: 0;
    counter-reset: chapter-counter; 
}

header {
    background-color: #005A9F;
    color: white;
    padding: 1rem 5%;
    text-align: center;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

main {
    max-width: 900px;
    margin: 20px auto;
    padding: 20px 40px;
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

h1, h2, h3, h4 {
    color: #004071;
/* border-bottom: 2px solid #eee; */
    padding-bottom: 10px;
}

header h1 { 
    margin: 0; 
    color: white; 
    border: none; 
}

a { 
    color: #007bff; 
    text-decoration: none; 
}
a:hover { 
    color: #0056b3; 
    text-decoration: underline; 
}

/* =================================
   2. STILE FÜR DIE INDEX-SEITE
   ================================= */
.hauptkapitel > li { 
    margin-bottom: 20px; 
}
.hauptkapitel > li > ul { 
    padding-left: 15px; 
}
.sub-list {
    padding-left: 30px;
    margin-top: 5px;
    border-left: 2px solid #e9e9e9;
}
.sub-list li { 
    padding: 4px 0; 
}

.search-wrapper { 
    position: relative; 
    margin-bottom: 20px; 
}
#searchInput {
    width: 100%;
    padding: 10px;
    font-size: 16px;
    border: 1px solid #ddd;
    border-radius: 5px;
    box-sizing: border-box;
}
#clearSearchBtn {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    border: none;
    background: #ccc;
    color: white;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    cursor: pointer;
    font-weight: bold;
    line-height: 18px;
    text-align: center;
    display: none; /* Hidden by default */
}

/* --- Automatic Numbering --- */
.hauptkapitel > li {
    counter-reset: subchapter-counter; /* RESETS the sub-counter for each new main chapter LI */
}
.hauptkapitel > li h3::before {
    counter-increment: chapter-counter; 
    content: counter(chapter-counter) ". "; 
}
.hauptkapitel h4::before {
    counter-increment: subchapter-counter;
    content: counter(chapter-counter) "." counter(subchapter-counter) " ";
}
/* 1. Reset the new counter on the parent (the h4) */
.hauptkapitel h4 {
    counter-reset: sub-subchapter-counter;
}

/* 2. Increment and display the new counter on the child (the h5) */
.hauptkapitel h5::before {
    counter-increment: sub-subchapter-counter;
    content: counter(chapter-counter) "." counter(subchapter-counter) "." counter(sub-subchapter-counter) " ";
}

/* =================================
   3. STILE FÜR INHALTS-SEITEN (Templates & Checklisten)
   ================================= */
.back-link {
    display: inline-block;
    margin-bottom: 25px;
    font-weight: 500;
    color: #555;
    text-decoration: none;
    border: 1px solid #ddd;
    padding: 8px 15px;
    border-radius: 5px;
    transition: all 0.2s;
}
.back-link:hover { 
    background-color: #f0f0f0; 
    border-color: #bbb; 
    text-decoration: none; 
}
.further-info { 
    margin-top: 40px; 
    padding-top: 20px; 
    border-top: 2px solid #eee; 
}
li { 
    margin-bottom: 10px; 
}

/* --- Feinabstimmung der Zeilenabstände im Inhaltsverzeichnis --- */
/* Level 1.X (die Unterkapitel-Überschriften wie "Instrumentenaufbereitung") */
.hauptkapitel > li > ul > li {
    margin-bottom: 15px; /* Etwas reduzierter Abstand zwischen den h4-Gruppen */
}
/* Level 1.X Links (die Links direkt unter den h4-Überschriften) */
.sub-list li {
    padding: 3px 0;      /* Weniger Innenabstand */
    margin-bottom: 2px;  /* Deutlich reduzierter Abstand zwischen den Links */
}
/* Level 1.X.Y Links (falls Sie eine dritte Ebene hinzufügen) */
/* Diese Regel zielt auf eine .sub-list innerhalb einer anderen .sub-list */
.sub-list .sub-list li {
    padding: 1px 0;      /* Noch weniger Innenabstand */
    margin-bottom: 1px;  /* Minimaler Abstand für die tiefste Ebene */
    border: none;        /* Entfernt ggf. doppelte Ränder */
}

/* --- Spezifische Stile für die interaktive Checkliste --- */
#checklist { 
    padding-left: 0; 
}
#checklist li {
    list-style-type: none;
    padding: 10px;
    border-bottom: 1px solid #eee;
    font-size: 1.1rem;
}
#checklist label {
    cursor: pointer;
    display: flex;
    align-items: center;
}
#checklist input[type="checkbox"] {
    margin-right: 15px;
    transform: scale(1.5);
}

button {
    background-color: #007bff;
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1rem;
    margin: 5px;
    transition: background-color 0.2s;
}
button:hover { 
    background-color: #0056b3; 
}

#probleme-btn { background-color: #dc3545; }
#probleme-btn:hover { background-color: #c82333; }
#speichern-btn { background-color: #28a745; }
#speichern-btn:hover { background-color: #218838; }

input[type="text"], textarea {
    width: 100%;
    padding: 10px;
    margin-top: 5px;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-sizing: border-box;
}

#problem-workflow, #abschluss-sektion {
    display: none;
    margin-top: 20px;
    padding: 15px;
    border: 1px solid #e0e0e0;
    background-color: #f9f9f9;
    border-radius: 5px;
}
#problem-details {
    display: none;
    margin-top: 10px;
}

/* =================================
   4. RESPONSIVE ANPASSUNGEN
   ================================= */
@media (max-width: 768px) {
    main {
        margin: 15px;
        padding: 15px;
    }
    header {
        padding: 1rem 3%;
    }
    h1 {
        font-size: 1.8rem;
    }
}

@media (max-width: 600px) {
    body {
        font-size: 16px;
    }
    main {
        margin: 0;
        border-radius: 0;
        box-shadow: none;
        padding: 10px;
    }
    header {
        padding: 0.8rem 5%;
    }
    h1 {
        font-size: 1.5rem;
    }
    #checklist li {
        font-size: 1rem;
        padding: 12px 5px;
    }
    #aktions-knoepfe {
        display: flex;
        flex-direction: column;
    }
    button {
        width: 100%;
        padding: 15px;
        margin-bottom: 10px;
        font-size: 1.1rem;
    }
}
