
:root {
    --primary-color: #003366;
    --secondary-color: #0066cc;
    --accent-color: #ff6600;
    --text-color: #333;
    --bg-color: #ffffff;
    --code-bg: #f5f5f5;
    --border-color: #ddd;
    --sidebar-width: 280px;
}

/* Dark Mode Variables */
body.dark-mode {
    --text-color: #e0e0e0;
    --bg-color: #1a1a1a;
    --code-bg: #2d2d2d;
    --border-color: #444;
}

body.dark-mode .sidebar {
    background-color: #242424;
}

body.dark-mode .sidebar-header h1 {
    color: #6eb3ff;
}

body.dark-mode .nav-part-title {
    color: #6eb3ff;
    background-color: #2d2d2d;
}

body.dark-mode .nav-chapters a {
    color: var(--text-color);
}

body.dark-mode .nav-chapters li.active {
    background-color: #2d2d2d;
}

body.dark-mode h1,
body.dark-mode h2,
body.dark-mode h3 {
    color: #6eb3ff;
}

body.dark-mode table th {
    background-color: #2d4a6d;
}

body.dark-mode tr:nth-child(even) {
    background-color: #242424;
}

body.dark-mode .codehilite {
    background: var(--code-bg);
}

body.dark-mode .interactive-tool {
    background-color: #242424;
    border-color: #6eb3ff;
}

body.dark-mode .result-display {
    background-color: #2d2d2d;
    border-color: #6eb3ff;
}

body.dark-mode .chapter-nav-link {
    background-color: #242424;
    color: #6eb3ff;
}

body.dark-mode .chapter-nav-link:hover {
    background-color: #0066cc;
    color: white;
}

/* Smooth theme transition */
body {
    transition: background-color 0.3s ease, color 0.3s ease;
}

.sidebar,
.sidebar-header h1,
.nav-part-title,
.nav-chapters a,
h1, h2, h3,
.codehilite,
.interactive-tool,
.result-display,
.chapter-nav-link {
    transition: all 0.3s ease;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    line-height: 1.6;
    color: var(--text-color);
    background-color: var(--bg-color);
}

.container {
    display: flex;
    min-height: 100vh;
}

/* Sidebar Navigation */
.sidebar {
    width: var(--sidebar-width);
    background-color: #f8f9fa;
    border-right: 1px solid var(--border-color);
    position: fixed;
    height: 100vh;
    overflow-y: auto;
    padding: 20px 0;
}

.sidebar-header {
    padding: 0 20px 20px;
    border-bottom: 2px solid var(--primary-color);
    margin-bottom: 20px;
}

.sidebar-header h1 {
    font-size: 1.3rem;
    color: var(--primary-color);
    margin-bottom: 5px;
}

.sidebar-header p {
    font-size: 0.85rem;
    color: #666;
}

.nav-part {
    margin-bottom: 15px;
}

.nav-part-title {
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--primary-color);
    padding: 8px 20px;
    background-color: #e9ecef;
    letter-spacing: 0.5px;
}

.nav-chapters {
    list-style: none;
}

.nav-chapters li {
    border-left: 3px solid transparent;
}

.nav-chapters li.active {
    border-left-color: var(--accent-color);
    background-color: #fff;
}

.nav-chapters a {
    display: block;
    padding: 8px 20px 8px 25px;
    color: var(--text-color);
    text-decoration: none;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.nav-chapters a:hover {
    background-color: #fff;
    color: var(--secondary-color);
}

.nav-chapters li.active a {
    color: var(--secondary-color);
    font-weight: 600;
}

/* Main Content */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    padding: 40px 60px;
    max-width: 900px;
}

/* Typography */
h1 {
    font-size: 2.5rem;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
    font-weight: 700;
}

h2 {
    font-size: 2rem;
    color: var(--primary-color);
    margin-top: 2rem;
    margin-bottom: 1rem;
    padding-bottom: 0.3rem;
    border-bottom: 2px solid #e9ecef;
}

h3 {
    font-size: 1.5rem;
    color: var(--primary-color);
    margin-top: 1.5rem;
    margin-bottom: 0.75rem;
}

h4 {
    font-size: 1.25rem;
    color: var(--text-color);
    margin-top: 1.25rem;
    margin-bottom: 0.5rem;
}

h5, h6 {
    font-size: 1.1rem;
    color: var(--text-color);
    margin-top: 1rem;
    margin-bottom: 0.5rem;
}

p {
    margin-bottom: 1rem;
    text-align: justify;
}

/* Code Blocks */
pre {
    background-color: var(--code-bg);
    border: 1px solid var(--border-color);
    border-radius: 5px;
    padding: 15px;
    overflow-x: auto;
    margin: 1.5rem 0;
    font-size: 0.9rem;
}

code {
    font-family: 'Monaco', 'Menlo', 'Courier New', monospace;
    font-size: 0.9em;
    background-color: var(--code-bg);
    padding: 2px 5px;
    border-radius: 3px;
}

pre code {
    background: none;
    padding: 0;
}

/* Lists */
ul, ol {
    margin-bottom: 1rem;
    margin-left: 2rem;
}

li {
    margin-bottom: 0.5rem;
}

/* Tables */
table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.5rem 0;
    font-size: 0.95rem;
}

th {
    background-color: var(--primary-color);
    color: white;
    padding: 12px;
    text-align: left;
    font-weight: 600;
}

td {
    padding: 10px 12px;
    border: 1px solid var(--border-color);
}

tr:nth-child(even) {
    background-color: #f8f9fa;
}

/* Blockquotes & Callouts */
blockquote {
    border-left: 4px solid var(--secondary-color);
    padding-left: 20px;
    margin: 1.5rem 0;
    font-style: italic;
    color: #555;
}

.callout {
    padding: 15px 20px;
    margin: 1.5rem 0;
    border-radius: 5px;
    border-left: 4px solid;
}

.callout-note {
    background-color: #e7f3ff;
    border-left-color: #0066cc;
}

.callout-tip {
    background-color: #e8f5e9;
    border-left-color: #4caf50;
}

.callout-warning {
    background-color: #fff3e0;
    border-left-color: #ff9800;
}

.callout-important {
    background-color: #ffebee;
    border-left-color: #f44336;
}

/* Chapter Navigation */
.chapter-nav {
    display: flex;
    justify-content: space-between;
    margin-top: 3rem;
    padding-top: 2rem;
    border-top: 2px solid #e9ecef;
}

.chapter-nav-link {
    display: flex;
    align-items: center;
    padding: 15px 20px;
    background-color: #f8f9fa;
    border-radius: 5px;
    text-decoration: none;
    color: var(--primary-color);
    transition: all 0.2s;
    max-width: 45%;
}

.chapter-nav-link:hover {
    background-color: var(--secondary-color);
    color: white;
    transform: translateX(3px);
}

.chapter-nav-link.prev:hover {
    transform: translateX(-3px);
}

.chapter-nav-label {
    font-size: 0.8rem;
    text-transform: uppercase;
    font-weight: 600;
    margin-bottom: 5px;
}

.chapter-nav-title {
    font-size: 0.95rem;
}

/* Footer */
footer {
    margin-top: 3rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border-color);
    text-align: center;
    color: #666;
    font-size: 0.9rem;
}

/* Responsive */
@media (max-width: 1024px) {
    .sidebar {
        width: 250px;
    }

    .main-content {
        margin-left: 250px;
        padding: 30px 40px;
    }
}

@media (max-width: 768px) {
    .sidebar {
        position: static;
        width: 100%;
        height: auto;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }

    .main-content {
        margin-left: 0;
        padding: 20px;
    }

    .chapter-nav {
        flex-direction: column;
        gap: 10px;
    }

    .chapter-nav-link {
        max-width: 100%;
    }
}

/* Syntax Highlighting */
.codehilite .hll { background-color: #ffffcc }
.codehilite { background: var(--code-bg); }
.codehilite .c { color: #408080; font-style: italic }
.codehilite .k { color: #008000; font-weight: bold }
.codehilite .o { color: #666666 }
.codehilite .cm { color: #408080; font-style: italic }
.codehilite .cp { color: #BC7A00 }
.codehilite .c1 { color: #408080; font-style: italic }
.codehilite .cs { color: #408080; font-style: italic }
.codehilite .gd { color: #A00000 }
.codehilite .ge { font-style: italic }
.codehilite .gr { color: #FF0000 }
.codehilite .gh { color: #000080; font-weight: bold }
.codehilite .gi { color: #00A000 }
.codehilite .go { color: #888888 }
.codehilite .gp { color: #000080; font-weight: bold }
.codehilite .gs { font-weight: bold }
.codehilite .gu { color: #800080; font-weight: bold }
.codehilite .gt { color: #0044DD }
.codehilite .kc { color: #008000; font-weight: bold }
.codehilite .kd { color: #008000; font-weight: bold }
.codehilite .kn { color: #008000; font-weight: bold }
.codehilite .kp { color: #008000 }
.codehilite .kr { color: #008000; font-weight: bold }
.codehilite .kt { color: #B00040 }
.codehilite .m { color: #666666 }
.codehilite .s { color: #BA2121 }
.codehilite .na { color: #7D9029 }
.codehilite .nb { color: #008000 }
.codehilite .nc { color: #0000FF; font-weight: bold }
.codehilite .no { color: #880000 }
.codehilite .nd { color: #AA22FF }
.codehilite .ni { color: #999999; font-weight: bold }
.codehilite .ne { color: #D2413A; font-weight: bold }
.codehilite .nf { color: #0000FF }
.codehilite .nl { color: #A0A000 }
.codehilite .nn { color: #0000FF; font-weight: bold }
.codehilite .nt { color: #008000; font-weight: bold }
.codehilite .nv { color: #19177C }
.codehilite .ow { color: #AA22FF; font-weight: bold }
.codehilite .w { color: #bbbbbb }
.codehilite .mb { color: #666666 }
.codehilite .mf { color: #666666 }
.codehilite .mh { color: #666666 }
.codehilite .mi { color: #666666 }
.codehilite .mo { color: #666666 }
.codehilite .sb { color: #BA2121 }
.codehilite .sc { color: #BA2121 }
.codehilite .sd { color: #BA2121; font-style: italic }
.codehilite .s2 { color: #BA2121 }
.codehilite .se { color: #BB6622; font-weight: bold }
.codehilite .sh { color: #BA2121 }
.codehilite .si { color: #BB6688; font-weight: bold }
.codehilite .sx { color: #008000 }
.codehilite .sr { color: #BB6688 }
.codehilite .s1 { color: #BA2121 }
.codehilite .ss { color: #19177C }
.codehilite .bp { color: #008000 }
.codehilite .vc { color: #19177C }
.codehilite .vg { color: #19177C }
.codehilite .vi { color: #19177C }
.codehilite .il { color: #666666 }

/* Interactive Tools */
.interactive-tool {
    background-color: #f8f9fa;
    border: 2px solid var(--secondary-color);
    border-radius: 8px;
    padding: 25px;
    margin: 2rem 0;
}

.interactive-tool h3 {
    color: var(--secondary-color);
    margin-top: 0;
    margin-bottom: 15px;
    font-size: 1.4rem;
}

.interactive-tool p {
    color: #555;
    margin-bottom: 20px;
}

.calculator-controls {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-bottom: 25px;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.control-group label {
    font-weight: 600;
    color: var(--text-color);
    font-size: 0.95rem;
}

.control-group input[type="range"] {
    width: 100%;
    height: 8px;
    border-radius: 5px;
    background: #ddd;
    outline: none;
}

.control-group input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--secondary-color);
    cursor: pointer;
}

.control-group input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--secondary-color);
    cursor: pointer;
    border: none;
}

.control-value {
    display: inline-block;
    min-width: 60px;
    font-weight: 700;
    color: var(--secondary-color);
    font-size: 1rem;
}

.result-display {
    background-color: white;
    border: 2px solid var(--secondary-color);
    border-radius: 5px;
    padding: 20px;
    text-align: center;
}

.result-value {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--primary-color);
    margin: 10px 0;
}

.result-label {
    font-size: 1.1rem;
    color: #666;
    margin-bottom: 10px;
}

.result-explanation {
    font-size: 0.95rem;
    color: #555;
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid #ddd;
}

.decision-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-top: 20px;
}

.decision-card {
    background-color: white;
    border: 2px solid #ddd;
    border-radius: 5px;
    padding: 15px;
    text-align: center;
    transition: all 0.3s;
}

.decision-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.decision-card.best {
    border-color: #4caf50;
    background-color: #e8f5e9;
}

.decision-card h4 {
    color: var(--primary-color);
    margin-top: 0;
    margin-bottom: 10px;
    font-size: 1.1rem;
}

.decision-card .ep-value {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--secondary-color);
    margin: 10px 0;
}

.decision-card.best .ep-value {
    color: #4caf50;
}

.decision-card .recommendation {
    font-size: 0.85rem;
    color: #666;
    margin-top: 10px;
}

.decision-card.best .recommendation {
    color: #2e7d32;
    font-weight: 600;
}

button.simulate-btn {
    background-color: var(--secondary-color);
    color: white;
    border: none;
    border-radius: 5px;
    padding: 12px 24px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    margin-top: 15px;
}

button.simulate-btn:hover {
    background-color: var(--primary-color);
    transform: scale(1.05);
}

button.simulate-btn:active {
    transform: scale(0.98);
}

#teamChart, #wpChart {
    width: 100%;
    height: 500px;
    margin-top: 20px;
}

@media (max-width: 768px) {
    .decision-cards {
        grid-template-columns: 1fr;
    }

    .result-value {
        font-size: 2rem;
    }

    #teamChart, #wpChart {
        height: 400px;
    }
}

/* Panel Tabsets (R/Python/Explanation tabs) */
.panel-tabset {
    margin: 2rem 0;
}

.nav-tabs {
    display: flex;
    list-style: none;
    border-bottom: 2px solid #dee2e6;
    padding: 0;
    margin: 0 0 1rem 0;
}

.nav-tabs .nav-item {
    margin-right: 5px;
}

.nav-tabs .nav-link {
    display: block;
    padding: 10px 20px;
    text-decoration: none;
    color: #666;
    background-color: #f8f9fa;
    border: 1px solid transparent;
    border-radius: 5px 5px 0 0;
    transition: all 0.2s;
    cursor: pointer;
}

.nav-tabs .nav-link:hover {
    background-color: #e9ecef;
    color: var(--primary-color);
}

.nav-tabs .nav-link.active {
    background-color: white;
    color: var(--secondary-color);
    border-color: #dee2e6 #dee2e6 white;
    font-weight: 600;
    border-bottom: 2px solid white;
    margin-bottom: -2px;
}

.tab-content {
    padding: 1rem 0;
}

.tab-pane {
    display: none;
}

.tab-pane.active {
    display: block;
}

/* Callout box headings */
.callout h4 {
    margin-top: 0;
    margin-bottom: 10px;
    font-size: 1.1rem;
    font-weight: 600;
}

/* ========================================================================== */
/* UI ENHANCEMENTS */
/* ========================================================================== */

/* Copy Code Button */
.copy-button {
    position: absolute;
    top: 8px;
    right: 8px;
    background-color: #0066cc;
    color: white;
    border: none;
    border-radius: 4px;
    padding: 6px 12px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    opacity: 0.9;
    transition: all 0.2s ease;
    z-index: 10;
}

.copy-button:hover {
    opacity: 1;
    transform: scale(1.05);
}

.copy-button:active {
    transform: scale(0.95);
}

.copy-button.copied {
    background-color: #00cc66;
}

/* Make codehilite container relative for button positioning */
.codehilite {
    position: relative;
}

body.dark-mode .copy-button {
    background-color: #0066cc;
}

body.dark-mode .copy-button.copied {
    background-color: #00cc66;
}

/* Dark Mode Toggle Button */
.dark-mode-toggle {
    position: absolute;
    top: 15px;
    right: 15px;
    background-color: transparent;
    border: 2px solid var(--primary-color);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    transition: all 0.3s ease;
}

.dark-mode-toggle:hover {
    background-color: var(--primary-color);
    transform: rotate(20deg) scale(1.1);
}

.dark-mode-toggle .icon {
    display: block;
    line-height: 1;
}

body.dark-mode .dark-mode-toggle {
    border-color: #6eb3ff;
}

body.dark-mode .dark-mode-toggle:hover {
    background-color: #6eb3ff;
}

/* Adjust sidebar header to accommodate toggle button */
.sidebar-header {
    position: relative;
    padding-right: 60px;
}

/* Breadcrumb Navigation */
.breadcrumb-nav {
    margin-bottom: 1.5rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-color);
}

.breadcrumb {
    display: flex;
    flex-wrap: wrap;
    list-style: none;
    padding: 0;
    margin: 0;
    font-size: 0.85rem;
    color: #666;
}

.breadcrumb-item {
    display: flex;
    align-items: center;
}

.breadcrumb-item + .breadcrumb-item::before {
    content: ">";
    padding: 0 8px;
    color: #999;
}

.breadcrumb-item a {
    color: var(--secondary-color);
    text-decoration: none;
    transition: color 0.2s;
}

.breadcrumb-item a:hover {
    color: var(--primary-color);
    text-decoration: underline;
}

.breadcrumb-item.active {
    color: var(--text-color);
    font-weight: 500;
}

.breadcrumb-item span {
    color: inherit;
}

body.dark-mode .breadcrumb {
    color: #999;
}

body.dark-mode .breadcrumb-item a {
    color: #6eb3ff;
}

body.dark-mode .breadcrumb-item a:hover {
    color: #9ec9ff;
}

body.dark-mode .breadcrumb-item.active {
    color: var(--text-color);
}

/* Mobile: Truncate breadcrumb */
@media (max-width: 768px) {
    .breadcrumb-item.breadcrumb-part {
        display: none;
    }

    .breadcrumb-item + .breadcrumb-item::before {
        content: "...";
    }

    .breadcrumb-item.active + .breadcrumb-item::before {
        content: ">";
    }

    /* Show ellipsis before active item on mobile */
    .breadcrumb-mobile .breadcrumb-item:first-child::after {
        content: " >";
        padding-left: 8px;
        color: #999;
    }
}
