/* --- Base & Light Mode Styles --- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Georgia', serif;
    line-height: 1.6;
    color: #333;
    background-color: #f8f9fa;
    transition: background-color 0.3s, color 0.3s;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    background: white;
    box-shadow: 0 0 20px rgba(0,0,0,0.1);
    transition: background-color 0.3s;
}

.header {
    text-align: center;
    border-bottom: 3px solid #2c5282;
    padding-bottom: 20px;
    margin-bottom: 30px;
}

.header h1 { color: #2c5282; font-size: 2.5em; margin-bottom: 10px; }
.header .subtitle { font-style: italic; color: #666; font-size: 1.2em; }
.author { color: #2c5282; font-size: 1.1em; font-weight: bold; margin-top: 10px; }

.search-container { margin-bottom: 30px; text-align: center; }
.search-box {
    width: 100%;
    max-width: 400px;
    padding: 12px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 16px;
}
.search-box:focus { outline: none; border-color: #2c5282; }

.toc { background: #f7fafc; border: 1px solid #e2e8f0; border-radius: 8px; padding: 20px; margin-bottom: 30px; }
.toc h2 { color: #2c5282; margin-bottom: 15px; text-align: center; }
.toc-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 15px; column-gap: 25px; }
.toc-chapter { margin-bottom: 15px; }
.toc-chapter-title { font-weight: bold; color: #2d3748; margin-bottom: 5px; font-size: 1.1em; }
.toc-chapter a { color: #2c5282; text-decoration: none; padding: 6px 10px; border-radius: 4px; transition: background-color 0.3s; display: block; font-size: 0.95em; }
.toc-chapter a:hover { background-color: #e2e8f0; text-decoration: underline; }

.section { margin-bottom: 40px; padding: 20px; border-radius: 8px; background: white; border-left: 4px solid #2c5282; overflow: auto; }
.section h2 { color: #2c5282; font-size: 2em; margin-bottom: 25px; border-bottom: 2px solid #e2e8f0; padding-bottom: 10px; }
.section h3 { color: #2d3748; font-size: 1.6em; margin: 25px 0 15px 0; border-bottom: 1px solid #cbd5e1; padding-bottom: 8px; }
.section h4 { color: #4a5568; font-size: 1.3em; margin: 20px 0 10px 0; }
.section h5 { color: #4a5568; font-size: 1.1em; margin: 15px 0 10px 0; font-style: italic; }

.highlight-box, .warning-box, .info-box, .clinical-pearl, .stage-box, .algorithm-step, .medication-box {
    padding: 15px 15px 15px 25px; 
    margin: 20px 0;
    border-radius: 6px;
}
.highlight-box ul, .highlight-box ol,
.warning-box ul, .warning-box ol,
.info-box ul, .info-box ol,
.clinical-pearl ul, .clinical-pearl ol,
.stage-box ul, .stage-box ol,
.algorithm-step ul, .algorithm-step ol {
    padding-left: 25px; 
}

.highlight-box { background: #e0f2fe; border-left: 5px solid #0284c7; }
.warning-box { background: #feefee; border-left: 5px solid #ef4444; }
.info-box { background: #f0fdf4; border-left: 5px solid #22c55e; }
.clinical-pearl { background: #fefce8; border-left: 5px solid #eab308; }
.stage-box { border: 2px solid #2c5282; background: #f8f9fa; }
.medication-box { background: #fefce8; border: 1px solid #fde047; }
.algorithm-step { background: #eef2ff; border-left: 5px solid #4f46e5; }

table { width: 100%; border-collapse: collapse; margin: 20px 0; background: white; box-shadow: 0 2px 4px rgba(0,0,0,0.1); border-radius: 8px; overflow: hidden; }
th, td { border: 1px solid #e2e8f0; padding: 12px 15px; text-align: left; vertical-align: top; }
th { background: #2c5282; color: white; font-weight: bold; }
tr:nth-child(even) { background: #f7fafc; }

.risk-low { background-color: #dcfce7; color: #166534; font-weight: bold; }
.risk-moderate { background-color: #ffedd5; color: #9a3412; font-weight: bold; }
.risk-high { background-color: #fee2e2; color: #991b1b; font-weight: bold; }
.risk-very-high { background-color: #ef4444; color: white; font-weight: bold; }

.formula { background: #334155; color: white; padding: 15px; border-radius: 6px; font-family: 'Courier New', monospace; margin: 20px 0; }
.normal-values { background: #f0fdfa; border: 1px solid #99f6e4; padding: 15px; border-radius: 6px; margin: 20px 0; }

.back-to-top { position: fixed; bottom: 20px; right: 20px; background: #2c5282; color: white; padding: 12px 16px; border-radius: 50%; text-decoration: none; box-shadow: 0 4px 8px rgba(0,0,0,0.3); transition: opacity 0.3s, transform 0.3s; display: none; z-index: 1000; opacity: 0; transform: translateY(100px); }
.back-to-top.visible { display: block; opacity: 1; transform: translateY(0); }

.section-footer-links { display: flex; justify-content: flex-end; align-items: center; gap: 20px; margin-top: 25px; width: 100%; }
.back-to-section-top { font-style: italic; color: #2c5282; text-decoration: none; font-size: 0.9em; }
.back-to-section-top:hover { text-decoration: underline; }

.print-footer { display: none; }

.nav-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding: 10px 0;
    border-bottom: 1px solid #e2e8f0;
}

.nav-links a {
    color: #2c5282;
    text-decoration: none;
    margin: 0 10px;
    padding: 5px 10px;
    border-radius: 4px;
    transition: background-color 0.3s;
}

.nav-links a:hover {
    background-color: #e2e8f0;
    text-decoration: underline;
}

/* --- Dark Mode Styles --- */
body.dark-mode { background-color: #1a202c; color: #e2e8f0; }
.dark-mode .container { background: #2d3748; box-shadow: 0 0 20px rgba(0,0,0,0.5); }
.dark-mode .header h1, .dark-mode .author, .dark-mode .toc h2, .dark-mode .section h2 { color: #90cdf4; }
.dark-mode .header .subtitle { color: #a0aec0; }
.dark-mode .header, .dark-mode .section h2, .dark-mode .section h3 { border-color: #4a5568; }
.dark-mode .toc { background: #1a202c; border-color: #4a5568; }
.dark-mode .toc-chapter-title { color: #cbd5e1; }
.dark-mode a { color: #63b3ed; }
.dark-mode a:hover { background-color: #4a5568; }
.dark-mode .section { background-color: #2d3748; border-left-color: #90cdf4; }
.dark-mode .section h3, .dark-mode .section h4, .dark-mode .section h5 { color: #e2e8f0; }
.dark-mode .highlight-box { background: #2c5282; border-left-color: #63b3ed; color: #e2e8f0; }
.dark-mode .warning-box { background: #742a2a; border-left-color: #fc8181; color: #e2e8f0; }
.dark-mode .info-box { background: #2f5d44; border-left-color: #68d391; color: #e2e8f0; }
.dark-mode .clinical-pearl { background: #746f36; border-left-color: #faf089; color: #e2e8f0; }
.dark-mode .stage-box { background: #374151; border-color: #90cdf4; }
.dark-mode .algorithm-step { background: #3c366b; border-left-color: #a78bfa; color: #e2e8f0; }

.dark-mode table { background-color: #2d3748; box-shadow: none; }
.dark-mode th { background: #4a5568; }
.dark-mode td { border-color: #4a5568; color: #e2e8f0; }
.dark-mode tr { background: #2d3748; }
.dark-mode tr:nth-child(even) { background: #1a202c; }

.dark-mode .risk-low { background-color: #1c4532; color: #a7f3d0; }
.dark-mode .risk-moderate { background-color: #6b3e1a; color: #fed7aa; }
.dark-mode .risk-high { background-color: #7f1d1d; color: #fecaca; }
.dark-mode .risk-very-high { background-color: #b91c1c; color: #fee2e2; }

.dark-mode .formula { background: #1a202c; }
.dark-mode .normal-values { background: #134e4a; border-color: #5eead4; }
.dark-mode .search-box { background-color: #4a5568; border-color: #718096; color: #e2e8f0; }
.dark-mode .search-box::placeholder { color: #a0aec0; }
.dark-mode .back-to-top { background: #63b3ed; color: #1a202c; }
.dark-mode .back-to-section-top { color: #90cdf4; }
.dark-mode mark { background-color: #f6e05e; color: #1a202c; }
.dark-mode .nav-header { border-color: #4a5568; }

/* --- Print Styles --- */
@media print {
    .search-container, .back-to-top, .back-to-section-top, #printBtn, #darkModeToggle, .nav-header { display: none; }
    .container { box-shadow: none; max-width: none; }
    body { background-color: #fff; color: #000; }
    .print-footer {
        display: block;
        position: fixed;
        bottom: 0;
        left: 0;
        width: 100%;
        text-align: center;
        padding: 5px;
        font-size: 10pt;
        color: #666;
        border-top: 1px solid #ccc;
    }
}
@media (max-width: 768px) {
    .container { padding: 10px; }
    .header h1 { font-size: 2em; }
    .toc-grid { grid-template-columns: 1fr; }
}