:root {
    /* Light Mode */
    --bg-body: #ffffff;
    --bg-sidebar: #ffffff;
    --bg-header: rgba(255, 255, 255, 0.95);
    --bg-hover: #f3f4f6;
    --bg-code: #f5f7fa;
    --bg-input: #ffffff;
    --border-input: #e5e7eb;

    --bg-callout-info: #eef9fd;
    --border-callout-info: rgba(14, 165, 233, 0.3);
    --text-callout-info: #0c4a6e;

    --bg-callout-warn: #fffbeb;
    --border-callout-warn: rgba(245, 158, 11, 0.3);
    --text-callout-warn: #92400e;

    --text-main: #111827;
    --text-muted: #6b7280;
    --text-link: #374151;

    --border-color: #e5e7eb;
    --primary-color: #004bad;

    --sidebar-width: 280px;
    --toc-width: 240px;
    --header-height: 64px;

    --callout-info-bg: #eef9fd;
    --callout-info-border: #0ea5e9;
    --callout-warn-bg: #fffbeb;
    --callout-warn-border: #f59e0b;
    --callout-danger-bg: #fee2e2;
    --callout-danger-border: #ef4444;
}

/* Dark Mode */
[data-theme="dark"] {
    --bg-body: #0b1120;
    --bg-sidebar: #020617;
    --bg-header: rgba(11, 17, 32, 0.95);
    --bg-hover: #1e293b;
    --bg-code: #1e293b;
    --bg-input: #1e293b;
    --border-input: #334155;

    --bg-callout-info: rgba(14, 165, 233, 0.15);
    --border-callout-info: rgba(14, 165, 233, 0.3);
    --text-callout-info: #38bdf8;

    --bg-callout-warn: rgba(245, 158, 11, 0.15);
    --border-callout-warn: rgba(245, 158, 11, 0.3);
    --text-callout-warn: #fbbf24;

    --text-main: #f1f5f9;
    --text-muted: #94a3b8;
    --text-link: #cbd5e1;

    --border-color: #1e293b;
    --primary-color: #60a5fa;
}

/* --- RESET --- */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    outline: none;
}

body {
    font-family: "Inter", sans-serif;
    background-color: var(--bg-body);
    color: var(--text-main);
    line-height: 1.6;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    overflow-x: hidden;
}

a {
    text-decoration: none;
    color: inherit;
    transition: color 0.2s;
}

ul {
    list-style: none;
}

/* --- 0. HEADER --- */
.top-header {
    height: var(--header-height);
    background-color: var(--bg-header);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    padding: 0;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 100;
    backdrop-filter: blur(10px);
}

.header-brand-area {
    width: var(--sidebar-width);
    height: 100%;
    display: flex;
    align-items: center;
    padding-left: 1.5rem;
    flex-shrink: 0;
}

.brand {
    display: flex;
    align-items: center;
    font-weight: 600;
    font-size: 1.1rem;
    color: var(--primary-color);
}

.brand img {
    height: 32px;
    margin-right: 10px;
}

.header-content-area {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
}

.header-left-controls {
    display: flex;
    align-items: center;
    flex: 1;
}

.mobile-menu-btn {
    display: none;
    font-size: 1.6rem;
    cursor: pointer;
    margin-right: 1rem;
    color: var(--text-main);
}

.search-container {
    position: relative;
    width: 100%;
    max-width: 300px;
    margin-left: 0;
}

.search-container i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 1.1rem;
    pointer-events: none;
}

.search-input {
    width: 100%;
    padding: 0.5rem 1rem 0.5rem 2.4rem;
    border-radius: 8px;
    border: 1px solid var(--border-input);
    background-color: var(--bg-input);
    color: var(--text-main);
    font-size: 0.9rem;
    font-family: "Inter", sans-serif;
    transition: all 0.2s;
}

.search-input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(0, 75, 173, 0.1);
}

.search-kbd {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.7rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 2px 5px;
    color: var(--text-muted);
    background: var(--bg-hover);
    pointer-events: none;
}

.header-actions {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

.btn-link {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-link);
    padding: 0.5rem 0.8rem;
    border-radius: 6px;
}

.btn-link:hover {
    color: var(--primary-color);
    background: var(--bg-hover);
}

.btn-primary {
    background: var(--primary-color);
    color: #fff;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 600;
    transition: opacity 0.2s;
}

.btn-primary:hover {
    opacity: 0.9;
}

.theme-toggle {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: var(--bg-input);
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 1.2rem;
}

.theme-toggle:hover {
    border-color: var(--text-muted);
    color: var(--text-main);
}

/* --- 1. SIDEBAR --- */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--bg-sidebar);
    height: calc(100vh - var(--header-height));
    position: fixed;
    left: 0;
    top: var(--header-height);
    z-index: 50;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.sidebar-menu {
    padding: 1.5rem 1.5rem;
    flex: 1;
}

.menu-group-title {
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-main);
    margin: 1rem 0 0.5rem 0;
    letter-spacing: 0.05em;
}

.menu-group-title:first-child {
    margin-top: 0;
}

.menu-item {
    display: block;
    padding: 0.38rem 0.75rem;
    font-size: 0.9rem;
    color: var(--text-link);
    border-radius: 6px;
    margin-bottom: 2px;
    cursor: pointer;
    font-weight: 500;
    transition: background 0.2s, color 0.2s;
    margin-left: -0.75rem;
    margin-right: -0.75rem;
    padding-left: 0.75rem;
}

.menu-item:hover {
    background-color: var(--bg-hover);
    color: var(--text-main);
}

.menu-item.active {
    color: var(--primary-color);
    font-weight: 600;
}

/* --- 2. MAIN WRAPPER --- */
.main-wrapper {
    margin-left: var(--sidebar-width);
    margin-right: var(--toc-width);
    width: calc(100% - var(--sidebar-width) - var(--toc-width));
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    background-color: var(--bg-body);
    margin-top: var(--header-height);
}

.content-body {
    padding: 2rem 4rem;
    width: 100%;
    margin: 0;
}

.breadcrumbs {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 1.1rem;
    display: flex;
    align-items: center;
    gap: 5px;
}

.breadcrumbs span.curr {
    color: var(--primary-color);
    font-weight: 500;
}

h1 {
    font-size: 2.4rem;
    font-weight: 800;
    margin-bottom: 1rem;
    letter-spacing: -0.03em;
    line-height: 1.2;
    color: var(--text-main);
}

h2 {
    font-size: 1.75rem;
    font-weight: 700;
    margin-top: 2rem;
    margin-bottom: 1rem;
    letter-spacing: -0.02em;
    color: var(--text-main);
}

h3 {
    font-size: 1.35rem;
    font-weight: 600;
    margin-top: 2rem;
    margin-bottom: 0.75rem;
    color: var(--text-main);
}

p {
    margin-bottom: 1.5rem;
    font-size: 1.05rem;
    color: var(--text-link);
    line-height: 1.75;
}

      ul {
        list-style: disc;
        margin-left: 1.5rem;
        margin-bottom: 1.5rem;
        color: var(--text-link);
      }
      li {
        margin-bottom: 0.5rem;
      }

hr {
    border: 0;
    border-top: 1px solid var(--border-color);
    margin: 2rem 0;
}

/* Components */
.callout {
    padding: 1rem 1.25rem;
    margin-bottom: 1.5rem;
    border-radius: 6px;
    border-left: 4px solid;
    display: flex;
    gap: 12px;
    font-size: 0.95rem;
    line-height: 1.5;
}

.callout-icon {
    font-size: 1.2rem;
    margin-top: 2px;
    flex-shrink: 0;
}

.callout.info {
    background-color: var(--callout-info-bg);
    border-color: var(--callout-info-border);
    color: #0c4a6e;
}

.callout.warning {
    background-color: var(--callout-warn-bg);
    border-color: var(--callout-warn-border);
    color: #92400e;
}

.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.feature-card {
    border: 1px solid var(--border-color);
    padding: 1.25rem;
    border-radius: 8px;
    background: var(--bg-body);
    transition: transform 0.2s;
}

.feature-card:hover {
    border-color: var(--primary-color);
    transform: translateY(-2px);
}

.feature-card h4 {
    margin-bottom: 0.5rem;
    color: var(--primary-color);
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
}


      /* Custom Diagram Flow (Simple) */
      .flow-diagram {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 1rem;
        flex-wrap: wrap;
        margin: 2rem 0;
        padding: 2rem;
        background-color: var(--bg-hover);
        border-radius: 8px;
        border: 1px solid var(--border-color);
      }
      .flow-step {
        display: flex;
        flex-direction: column;
        align-items: center;
        text-align: center;
        width: 120px;
      }
      .flow-icon {
        font-size: 2rem;
        color: var(--primary-color);
        background: var(--bg-body);
        width: 60px;
        height: 60px;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
        margin-bottom: 0.5rem;
        border: 1px solid var(--border-color);
      }
      .flow-arrow {
        color: var(--text-muted);
        font-size: 1.5rem;
      }

/* Table */
      .table-container {
        overflow-x: auto;
        margin-bottom: 1.5rem;
        border: 1px solid var(--border-color);
        border-radius: 8px;
      }
      table {
        width: 100%;
        border-collapse: collapse;
        min-width: 600px;
      }
      th,
      td {
        padding: 0.75rem 1rem;
        border-bottom: 1px solid var(--border-color);
        text-align: left;
        font-size: 0.9rem;
        color: var(--text-link);
      }
      th {
        background-color: var(--bg-hover);
        font-weight: 600;
        color: var(--text-main);
      }
      tr:last-child td {
        border-bottom: none;
      }

.page-footer {
    margin-top: 2rem;
    padding-top: 2rem;
    display: grid;
    gap: 1rem;
    grid-template-columns: 1fr 1fr;
}

.nav-card {
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 1rem 1.25rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background-color: var(--bg-body);
    transition: all 0.2s ease;
    text-decoration: none;
    min-height: 80px;
}

.nav-card:hover {
    border-color: var(--primary-color);
    background-color: var(--bg-hover);
}

.nav-card small {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.25rem;
}

.nav-card span {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--primary-color);
    display: flex;
    align-items: center;
    gap: 6px;
    line-height: 1.3;
}

.nav-card.next {
    align-items: flex-end;
    text-align: right;
}

.nav-card.next span {
    flex-direction: row-reverse;
}

/* --- 3. RIGHT SIDEBAR (TOC) --- */
.toc {
    width: var(--toc-width);
    position: fixed;
    right: 0;
    top: var(--header-height);
    height: calc(100vh - var(--header-height));
    padding: 2rem 1.5rem;
    overflow-y: auto;
    background-color: var(--bg-body);
    z-index: 40;
}

.toc-title {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-main);
    margin-bottom: 1rem;
    letter-spacing: 0.05em;
    margin-top: -8px;
}

      .toc ul {
        margin: 0;
        padding: 0;
        list-style: none; /* Reset disc for TOC */
      }

.toc li {
    margin-bottom: 0.5rem;
}

.toc a {
    font-size: 0.85rem;
    color: var(--text-muted);
    display: block;
    border-left: 2px solid transparent;
    padding-left: 12px;
    line-height: 1.5;
}

.toc a:hover {
    color: var(--primary-color);
    border-left-color: var(--border-color);
}

.toc a.active {
    color: var(--primary-color);
    border-left-color: var(--primary-color);
    font-weight: 500;
}

/* Responsive Logic */
.mobile-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 45;
    backdrop-filter: blur(2px);
}

.sidebar {
    scrollbar-width: none;
}

.sidebar:hover {
    scrollbar-width: thin;
    scrollbar-color: var(--border-color) transparent;
}

@media (max-width: 1024px) {
    :root {
        --toc-width: 0px;
    }

    .toc {
        display: none;
    }

    .main-wrapper {
        margin-right: 0;
        width: calc(100% - var(--sidebar-width));
    }

    .content-body {
        padding: 2rem;
    }
}

@media (max-width: 768px) {
    :root {
        --sidebar-width: 0px;
    }

    .sidebar {
        transform: translateX(-100%);
        width: 280px;
        transition: transform 0.3s ease-in-out;
        z-index: 150;
        top: 0;
        height: 100vh;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .main-wrapper {
        margin-left: 0;
        width: 100%;
    }

    .mobile-menu-btn {
        display: block;
    }

    .header-brand-area {
        width: auto;
        border-right: none;
        padding-left: 0;
    }

    .header-content-area {
        padding: 0 1rem;
    }

    .brand {
        display: none;
    }

    .search-container {
        display: none;
    }

    .mobile-overlay.active {
        display: block;
    }

    .header-actions .btn-link {
        display: none;
    }

    .page-footer {
        grid-template-columns: 1fr !important;
    }
}