:root {
    --sidebar-width: 300px;
    --primary-color: #3884ff;
    --bg-color: #fff;
    --sidebar-bg: #f5f7f9;
    --text-color: #3b454e;
    --border-color: #e6ecf1;
}

body, html {
    margin: 0;
    padding: 0;
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: var(--text-color);
}

.book {
    display: flex;
    height: 100vh;
}

/* Sidebar */
.book-summary {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border-color);
    overflow-y: auto;
    flex-shrink: 0;
}

.bluedot--faded {
    opacity: 0.3;
    filter: saturate(0.4);
}

.summary {
    list-style: none;
    padding: 0;
    margin: 0;
}

.summary li {
    padding: 0;
}

.summary li.header {
    padding: 1rem 1.5rem;
    text-transform: uppercase;
    font-size: 0.75rem;
    font-weight: 700;
    color: #363333;
}

.summary li.chapter a {
    display: block;
    padding: 0.5rem 1.5rem;
    text-decoration: none;
    color: inherit;
    font-size: 0.9rem;
    border-left: 4px solid transparent;
}

.summary li.chapter:hover {
    background: #e6ecf1;
}

.summary li.chapter.active {
    background: #fff;
}

.summary li.chapter.active a {
/*    color: var(--primary-color);*/
    border-left-color: var(--primary-color);
    font-weight: 600;
}
.articles .chapter-row a{
    border-left-color: white !important;
    font-weight: 200 !important;
}

.articles li.chapter:last-child{
    padding-bottom: 5px
}

.summary li.chapter.disabled {
    opacity: 0.5;
    pointer-events: none;
}

.bluedot{
    font-size: 7px;
}

/* TOC Nesting & Collapsing */
.summary li ul.articles {
    padding-left: 1rem;
    list-style: none;
    display: none; /* Collapse by default */
}

.summary li.chapter.active ul.articles {
    display: block; /* Expand if active */
}

.summary li ul.articles li.chapter a {
    padding-left: 0.5rem;
    font-size: 0.85rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.summary li ul.articles li.chapter a.current-sub {
/*    color: var(--primary-color);*/
    font-weight: 700;
}

/* Container Boxes */
.warningbox, .infobox, .taskbox {
    padding: 1rem;
    margin: 1.5rem 0;
    border-radius: 4px;
    border-left: 6px solid #ccc;
}

.warningbox {
    background-color: #fff3cd;
    border-left-color: #ffc107;
    color: #856404;
}

.infobox {
    background-color: #d1ecf1;
    border-left-color: #17a2b8;
    color: #0c5460;
}

.taskbox {
    background-color: #d4edda;
    border-left-color: #28a745;
    color: #155724;
}

.warningbox p, .infobox p, .taskbox p {
    margin-bottom: 0rem;
    margin-top: 0rem;
}

.warningbox ul, .infobox ul, .taskbox ul {
    margin-left: 1.5rem;
    list-style-type: disc;
    margin-top: 0.5rem;
}

.warningbox li, .infobox li, .taskbox li {
    margin-bottom: 0.25rem;
}

/* Locked Content */
.part-wrapper {
    position: relative;
    transition: filter 0.3s, opacity 0.3s;
}

.part-wrapper.locked {
    filter: blur(5px);
    opacity: 0.4;
    pointer-events: none;
    user-select: none;
}

.lock-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(255, 255, 255, 0.9);
    padding: 1rem 2rem;
    border-radius: 50px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    z-index: 10;
    font-weight: 700;
    color: #3b454e;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    pointer-events: auto; /* Allow seeing the label */
}

/* Header Numbering */
.content-header h1, .section-content h2 {
    position: relative;
}

.header-number {
    position: absolute;
    right: 100%;
    margin-right: 1.5rem;
    color: #a0a0a0;
    font-weight: 400;
}

/* TOC Adjustments */
.chapter-row:hover {
    background: #e6ecf1;
}

.admin-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #ccc;
    transition: color 0.2s, transform 0.2s;
}

.admin-mark:hover { 
    color: #999;
    transform: scale(1.2);
}

.admin-mark.marked { 
    color: #dc3545; 
}

.admin-mark.passed { 
    color: #f8d7da; 
}

/* Body */
.book-body {
    flex-grow: 1;
    overflow-y: auto;
    background: var(--bg-color);
    margin-left:30px;
    margin-right:40px;
}

.page-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 3rem;
    margin-left:20px !important;
}

.content-header h1 {
    font-size: 2.5rem;
    margin-bottom: 2rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 1rem;
}

/* Markdown Styling */
.markdown-body:not(pre code) {
    line-height: 1.7;
    font-size: 1.1rem;
}

.markdown-body h2 { border-bottom: 1px solid var(--border-color); padding-bottom: 0.5rem; margin-top: 2rem; }
code { background: #f6f8fa; border-radius: 3px; font-family: monospace;font-size:0.9rem; line-height:1; }
pre { background: #f6f8fa; padding: 1rem; border-radius: 6px; overflow-x: auto; }
code:not(pre code){padding: 0.2rem 0.4rem;font-size:0.9rem; }

/* Task Box */
.task-box {
    background: #f0f7ff;
    border-left: 6px solid var(--primary-color);
    padding: 1.5rem;
    margin: 2rem 0;
    border-radius: 6px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.taskbox .task-box {
    border-left: none;
}

.task-box.completed {
    background: #f0fff4;
    border-left-color: #28a745;
}

.task-box.close {
    background: #fffdf0;
    border-left-color: #ffeeba;
}

.task-box.admin {
    background: #fff9f0;
    border-left-color: #ff9800;
}

.task-box h3 { margin-top: 0; color: #1a4fb3; }
.task-box.completed h3 { color: #155724; }

.task-ui { margin-top: 1rem; }

.input-group { display: flex; gap: 0.5rem; }
.input-group input { flex-grow: 1; padding: 0.75rem; border: 1px solid #ddd; border-radius: 4px; font-size: 1rem; }
.input-group button { padding: 0.75rem 1.5rem; background: var(--primary-color); color: white; border: none; border-radius: 4px; cursor: pointer; }

.feedback { margin-top: 0.5rem; font-weight: 600; }
.feedback.error { color: #dc3545; }
.feedback.success { color: #28a745; }
.feedback.close { color: #856404; font-style: italic; }

.attempts { margin-top: 0.5rem; font-size: 0.85rem; color: #666; }

.alert { padding: 1rem; border-radius: 4px; margin-bottom: 1rem; }
.alert-success { background: #d4edda; color: #155724; border: 1px solid #c3e6cb; }
.alert-close { background: #fff3cd; color: #856404; border: 1px dashed #ffeeba; }

/* Admin Stats */
.admin-stats { margin-top: 1rem; }
.stat-item { display: flex; justify-content: space-between; margin-bottom: 0.5rem; }
.stat-item .label { font-weight: 600; }
.stat-item .value.correct { color: #28a745; font-weight: 700; }

/* Admin Stats Table */
.progress-table td.correct { background-color: #d4edda; color: #155724; }
.progress-table td.close { background-color: #fff3cd; color: #856404; }
.progress-table td.incorrect { background-color: #f8d7da; color: #721c24; }

/* Admin Stats Distribution */
.status-distribution {
    display: flex;
    height: 20px;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 0.5rem;
    width: 100%;
}
.progress-bar {
    height: 100%;
}

.progress-bar.correct { background-color: #28a745; }
.progress-bar.close { background-color: #94d3a2; }
.progress-bar.incorrect { background-color: #dc3545; }
.progress-bar.unattempted { background-color: #ddd; }

.stats-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    font-size: 0.85rem;
    margin-bottom: 1rem;
}

.legend-item { display: flex; align-items: center; gap: 0.3rem; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.dot.correct { background-color: #28a745; }
.dot.close { background-color: #94d3a2; }
.dot.incorrect { background-color: #dc3545; }
.dot.unattempted { background-color: #ddd; }

.top3-badges {
    display: flex;
    gap: 1rem;
}

.badge {
    padding: 0.2rem 0.6rem;
    border-radius: 12px;
    font-size: 0.85rem;
    font-weight: 600;
}

.rank-1 { background-color: #fff3cd; border: 1px solid #ffeeba; }
.rank-2 { background-color: #f8f9fa; border: 1px solid #dee2e6; }
.rank-3 { background-color: #fdf2f2; border: 1px solid #fbd5d5; }

/* Navigation Footer */
.navigation-footer {
    display: flex;
    justify-content: space-between;
    margin-top: 4rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border-color);
}

.btn-nav {
    text-decoration: none;
    color: var(--primary-color);
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-nav:hover { text-decoration: underline; }

/* Fullscreen Support */
.fullscreen-toggle {
    position: fixed;
    top: 10px;
    right: 20px;
    z-index: 1000;
    background: rgba(255, 255, 255, 0.8);
    padding: 8px 12px;
    border-radius: 4px;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    transition: background 0.2s;
}
.fullscreen-toggle:hover {
    background: #fff;
}
.fullscreen-active .book-summary {
    display: none;
}
.fullscreen-active .book-body {
    left: 0 !important;
}

/* Sidebar Link Padding */

.summary li a {
    padding: 0.1rem 0.5rem;
}
.summary .articles li a {
    padding: 0.1rem 0.5rem;
}
.summary .chapter-row li a {
    padding: 0.5rem 0.5rem;
}
.summary li .fa-solid {
    margin-right: 0.5rem;
}

/* Task States */
.task-box.given-up {
    background: #f8f9fa;
    border-left-color: #6c757d;
}
.alert-given-up {
    background: #e9ecef;
    color: #495057;
    border: 1px solid #ced4da;
}

/* Admin Dashboard Detail Styling */
.all-finishers {
    line-height: 1.8;
}
.finisher.given-up {
    color: #999;
}
.finisher {
    display: inline-block;
    padding: 2px 8px;
    background: white;
    border: 1px solid #eee;
    border-radius: 4px;
}

/* Badge Animations */
@keyframes badgePop {
    0% { transform: scale(0); opacity: 0; }
    70% { transform: scale(1.2); opacity: 1; }
    100% { transform: scale(1); }
}

.badge-animate {
    animation: badgePop 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
    display: inline-block;
}

.badge {
    transition: all 0.3s ease;
}

/* Sidebar Footer Card */
.sidebar-footer {
    padding: 1.5rem;
    margin-top: auto;
}

.footer-card {
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.75rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.03);
}

.footer-card ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.footer-card li {
    margin-bottom: 0.5rem;
}

.footer-card li:last-child {
    margin-bottom: 0;
}

.footer-card a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem;
    text-decoration: none;
    color: var(--text-color);
    font-size: 0.85rem;
    border-radius: 4px;
    transition: background 0.2s;
}

.footer-card a:hover {
    background: #f0f4f8;
    color: var(--primary-color);
}

.footer-card i {
    width: 16px;
    text-align: center;
    color: #8899a6;
}

.footer-card .logout-link {
    color: #dc3545;
    border-top: 1px solid var(--border-color);
    margin-top: 0.5rem;
    padding-top: 0.75rem;
    border-radius: 0;
}

.footer-card .logout-link:hover {
    background: #fff5f5;
    color: #c82333;
}
