/* ==========================================================================
   Donjon Platform v7.0 - Knowledge Base Styles
   Dark theme matching the Donjon dashboard aesthetic
   ========================================================================== */

/* --- CSS Variables --- */
:root {
    --bg-primary: #1a1a2e;
    --bg-secondary: #16213e;
    --bg-tertiary: #0f3460;
    --bg-card: #1e2a4a;
    --bg-code: #0d1117;
    --bg-sidebar: #12122a;
    --bg-hover: #253561;

    --text-primary: #e0e0e0;
    --text-secondary: #a0a0b8;
    --text-muted: #6c6c8a;
    --text-heading: #ffffff;

    --accent-purple: #6c63ff;
    --accent-purple-light: #8b83ff;
    --accent-purple-dark: #4a42d4;
    --accent-green: #26de81;
    --accent-green-dark: #1db96a;
    --accent-red: #ff6b6b;
    --accent-orange: #ffa94d;
    --accent-blue: #4ecdc4;
    --accent-yellow: #ffd43b;

    --border-color: #2a2a4a;
    --border-light: #3a3a5a;

    --font-sans: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', 'Consolas', monospace;

    --sidebar-width: 280px;
    --header-height: 64px;
    --content-max-width: 960px;
    --transition-speed: 0.2s;
}

/* --- Reset and Base --- */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
    font-size: 16px;
}

body {
    font-family: var(--font-sans);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.7;
    min-height: 100vh;
}

/* --- Typography --- */
h1, h2, h3, h4, h5, h6 {
    color: var(--text-heading);
    font-weight: 600;
    line-height: 1.3;
    margin-top: 2rem;
    margin-bottom: 0.75rem;
}

h1 {
    font-size: 2rem;
    border-bottom: 2px solid var(--accent-purple);
    padding-bottom: 0.5rem;
    margin-top: 0;
}

h2 {
    font-size: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.4rem;
}

h3 {
    font-size: 1.25rem;
    color: var(--accent-purple-light);
}

h4 {
    font-size: 1.1rem;
    color: var(--text-secondary);
}

p {
    margin-bottom: 1rem;
}

a {
    color: var(--accent-purple-light);
    text-decoration: none;
    transition: color var(--transition-speed);
}

a:hover {
    color: var(--accent-green);
    text-decoration: underline;
}

strong {
    color: var(--text-heading);
}

/* --- Layout --- */
.page-wrapper {
    display: flex;
    min-height: 100vh;
}

/* --- Header / Top Bar --- */
.top-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    background: linear-gradient(135deg, var(--bg-secondary), var(--bg-tertiary));
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    z-index: 1000;
}

.top-bar .logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.top-bar .logo-icon {
    width: 36px;
    height: 36px;
    background: var(--accent-purple);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    font-weight: 700;
    color: #fff;
}

.top-bar .logo-text {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-heading);
    letter-spacing: -0.02em;
}

.top-bar .logo-text span {
    color: var(--accent-purple-light);
}

.top-bar .badges {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.25rem 0.65rem;
    border-radius: 20px;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    text-transform: uppercase;
}

.badge-version {
    background: var(--accent-purple);
    color: #fff;
}

.badge-pqc {
    background: rgba(38, 222, 129, 0.15);
    color: var(--accent-green);
    border: 1px solid rgba(38, 222, 129, 0.3);
}

.badge-tier-community {
    background: rgba(108, 99, 255, 0.15);
    color: var(--accent-purple-light);
    border: 1px solid rgba(108, 99, 255, 0.3);
}

.badge-tier-pro {
    background: rgba(78, 205, 196, 0.15);
    color: var(--accent-blue);
    border: 1px solid rgba(78, 205, 196, 0.3);
}

.badge-tier-enterprise {
    background: rgba(255, 169, 77, 0.15);
    color: var(--accent-orange);
    border: 1px solid rgba(255, 169, 77, 0.3);
}

.badge-tier-managed {
    background: rgba(255, 107, 107, 0.15);
    color: var(--accent-red);
    border: 1px solid rgba(255, 107, 107, 0.3);
}

.hamburger {
    display: none;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.5rem;
}

/* --- Sidebar --- */
.sidebar {
    position: fixed;
    top: var(--header-height);
    left: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    overflow-y: auto;
    padding: 1rem 0;
    z-index: 900;
    transition: transform var(--transition-speed);
}

.sidebar-section {
    padding: 0 1rem;
    margin-bottom: 1.5rem;
}

.sidebar-section-title {
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    padding: 0.5rem 0.75rem;
    margin-bottom: 0.25rem;
}

.sidebar a {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.45rem 0.75rem;
    border-radius: 6px;
    color: var(--text-secondary);
    font-size: 0.875rem;
    transition: all var(--transition-speed);
    text-decoration: none;
}

.sidebar a:hover {
    background: var(--bg-hover);
    color: var(--text-heading);
    text-decoration: none;
}

.sidebar a.active {
    background: rgba(108, 99, 255, 0.15);
    color: var(--accent-purple-light);
    font-weight: 600;
}

.sidebar a .nav-icon {
    width: 18px;
    text-align: center;
    font-size: 0.9rem;
    flex-shrink: 0;
}

/* --- Search Box --- */
.search-container {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 0.5rem;
}

.search-input {
    width: 100%;
    padding: 0.5rem 0.75rem 0.5rem 2rem;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 0.85rem;
    outline: none;
    transition: border-color var(--transition-speed);
}

.search-input:focus {
    border-color: var(--accent-purple);
}

.search-input::placeholder {
    color: var(--text-muted);
}

.search-wrapper {
    position: relative;
}

.search-wrapper::before {
    content: "\1F50D";
    position: absolute;
    left: 0.6rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.8rem;
    pointer-events: none;
}

/* --- Main Content --- */
.main-content {
    margin-left: var(--sidebar-width);
    margin-top: var(--header-height);
    padding: 2rem 2.5rem;
    flex: 1;
    min-height: calc(100vh - var(--header-height));
}

.content-wrapper {
    max-width: var(--content-max-width);
    margin: 0 auto;
}

/* --- Breadcrumbs --- */
.breadcrumbs {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.82rem;
    color: var(--text-muted);
    margin-bottom: 1.5rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-color);
}

.breadcrumbs a {
    color: var(--text-muted);
}

.breadcrumbs a:hover {
    color: var(--accent-purple-light);
}

.breadcrumbs .separator {
    color: var(--border-light);
}

.breadcrumbs .current {
    color: var(--text-primary);
}

/* --- Code Blocks --- */
pre {
    background: var(--bg-code);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1.25rem;
    overflow-x: auto;
    margin: 1rem 0 1.5rem;
    font-size: 0.85rem;
    line-height: 1.6;
}

code {
    font-family: var(--font-mono);
    font-size: 0.88em;
}

:not(pre) > code {
    background: rgba(108, 99, 255, 0.12);
    color: var(--accent-purple-light);
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    font-size: 0.85em;
}

pre code {
    color: var(--text-primary);
    background: none;
    padding: 0;
}

/* Syntax highlighting within code blocks */
.kw { color: #c678dd; }
.str { color: #98c379; }
.num { color: #d19a66; }
.cmt { color: #5c6370; font-style: italic; }
.fn { color: #61afef; }
.op { color: #56b6c2; }
.var { color: #e06c75; }

/* --- Tables --- */
table {
    width: 100%;
    border-collapse: collapse;
    margin: 1rem 0 1.5rem;
    font-size: 0.9rem;
}

thead {
    background: var(--bg-tertiary);
}

th {
    text-align: left;
    padding: 0.75rem 1rem;
    font-weight: 600;
    color: var(--text-heading);
    border-bottom: 2px solid var(--accent-purple);
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

td {
    padding: 0.65rem 1rem;
    border-bottom: 1px solid var(--border-color);
    vertical-align: top;
}

tr:hover {
    background: rgba(108, 99, 255, 0.04);
}

/* --- Cards --- */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    transition: border-color var(--transition-speed);
}

.card:hover {
    border-color: var(--accent-purple);
}

.card-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-heading);
    margin-bottom: 0.5rem;
}

.card-description {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
    margin: 1.5rem 0;
}

.card-link {
    text-decoration: none;
    color: inherit;
}

.card-link:hover {
    text-decoration: none;
}

.card-link .card {
    cursor: pointer;
}

.card-icon {
    font-size: 1.6rem;
    margin-bottom: 0.75rem;
}

/* --- Alert / Callout Boxes --- */
.callout {
    border-left: 4px solid var(--accent-purple);
    background: rgba(108, 99, 255, 0.06);
    padding: 1rem 1.25rem;
    border-radius: 0 8px 8px 0;
    margin: 1rem 0 1.5rem;
}

.callout-title {
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 0.4rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.callout-info {
    border-left-color: var(--accent-blue);
    background: rgba(78, 205, 196, 0.06);
}

.callout-info .callout-title { color: var(--accent-blue); }

.callout-warning {
    border-left-color: var(--accent-orange);
    background: rgba(255, 169, 77, 0.06);
}

.callout-warning .callout-title { color: var(--accent-orange); }

.callout-danger {
    border-left-color: var(--accent-red);
    background: rgba(255, 107, 107, 0.06);
}

.callout-danger .callout-title { color: var(--accent-red); }

.callout-success {
    border-left-color: var(--accent-green);
    background: rgba(38, 222, 129, 0.06);
}

.callout-success .callout-title { color: var(--accent-green); }

.callout p:last-child {
    margin-bottom: 0;
}

/* --- Lists --- */
ul, ol {
    margin: 0.5rem 0 1rem 1.5rem;
}

li {
    margin-bottom: 0.35rem;
}

li > ul, li > ol {
    margin-top: 0.35rem;
    margin-bottom: 0;
}

/* --- Tier Comparison Table --- */
.tier-table th:not(:first-child),
.tier-table td:not(:first-child) {
    text-align: center;
}

.tier-table .check {
    color: var(--accent-green);
    font-weight: 700;
}

.tier-table .cross {
    color: var(--text-muted);
}

.tier-table .limit {
    color: var(--accent-orange);
    font-size: 0.85em;
}

/* --- Method Badges (API) --- */
.method {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    font-size: 0.72rem;
    font-weight: 700;
    font-family: var(--font-mono);
    letter-spacing: 0.04em;
    text-transform: uppercase;
    min-width: 52px;
    text-align: center;
}

.method-get { background: rgba(38, 222, 129, 0.18); color: var(--accent-green); }
.method-post { background: rgba(108, 99, 255, 0.18); color: var(--accent-purple-light); }
.method-put { background: rgba(255, 169, 77, 0.18); color: var(--accent-orange); }
.method-delete { background: rgba(255, 107, 107, 0.18); color: var(--accent-red); }

/* --- Endpoint Row --- */
.endpoint {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 0;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.9rem;
}

.endpoint-path {
    font-family: var(--font-mono);
    color: var(--text-primary);
    font-size: 0.85rem;
}

.endpoint-desc {
    color: var(--text-secondary);
    font-size: 0.82rem;
    margin-left: auto;
}

/* --- Accordion / Collapsible --- */
details {
    margin: 0.5rem 0;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
}

summary {
    padding: 0.75rem 1rem;
    background: var(--bg-card);
    cursor: pointer;
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-heading);
    list-style: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: background var(--transition-speed);
}

summary:hover {
    background: var(--bg-hover);
}

summary::before {
    content: "\25B6";
    font-size: 0.7rem;
    transition: transform var(--transition-speed);
    color: var(--accent-purple);
}

details[open] > summary::before {
    transform: rotate(90deg);
}

details > .details-content {
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--border-color);
}

/* --- Step-by-Step --- */
.steps {
    counter-reset: step;
    list-style: none;
    margin-left: 0;
    padding-left: 0;
}

.steps > li {
    counter-increment: step;
    position: relative;
    padding-left: 3rem;
    margin-bottom: 1.5rem;
}

.steps > li::before {
    content: counter(step);
    position: absolute;
    left: 0;
    top: 0;
    width: 2rem;
    height: 2rem;
    background: var(--accent-purple);
    color: #fff;
    font-weight: 700;
    font-size: 0.85rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* --- Footer --- */
.footer {
    border-top: 1px solid var(--border-color);
    padding: 1.5rem 0;
    margin-top: 3rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.8rem;
}

.footer a {
    color: var(--accent-purple-light);
}

/* --- Scrollbar --- */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
    background: var(--border-light);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--accent-purple-dark);
}

/* --- Table of Contents (right-side on landing) --- */
.toc {
    list-style: none;
    padding: 0;
    margin: 0;
}

.toc li {
    margin: 0;
}

.toc a {
    display: block;
    padding: 0.3rem 0.75rem;
    border-left: 2px solid var(--border-color);
    color: var(--text-secondary);
    font-size: 0.85rem;
    transition: all var(--transition-speed);
}

.toc a:hover,
.toc a.active {
    border-left-color: var(--accent-purple);
    color: var(--accent-purple-light);
    text-decoration: none;
}

/* --- Hero Section (landing page) --- */
.hero {
    text-align: center;
    padding: 2.5rem 1rem;
    margin-bottom: 2rem;
    background: linear-gradient(135deg, rgba(108, 99, 255, 0.08), rgba(78, 205, 196, 0.05));
    border-radius: 12px;
    border: 1px solid var(--border-color);
}

.hero h1 {
    border: none;
    font-size: 2.2rem;
    margin-bottom: 0.5rem;
    padding-bottom: 0;
}

.hero p {
    color: var(--text-secondary);
    font-size: 1.05rem;
    max-width: 600px;
    margin: 0 auto 1rem;
}

.hero .badges {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 1rem;
}

/* --- Keyboard shortcut styling --- */
kbd {
    display: inline-block;
    background: var(--bg-code);
    border: 1px solid var(--border-light);
    border-radius: 4px;
    padding: 0.1rem 0.4rem;
    font-family: var(--font-mono);
    font-size: 0.82em;
    color: var(--text-primary);
    box-shadow: 0 1px 0 var(--border-color);
}

/* --- Status indicators --- */
.status-ok { color: var(--accent-green); }
.status-warn { color: var(--accent-orange); }
.status-error { color: var(--accent-red); }
.status-info { color: var(--accent-blue); }

/* --- Responsive --- */
@media (max-width: 900px) {
    .sidebar {
        transform: translateX(-100%);
    }

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

    .main-content {
        margin-left: 0;
        padding: 1.5rem 1rem;
    }

    .hamburger {
        display: block;
    }

    .top-bar .badges .badge:not(.badge-version) {
        display: none;
    }

    .card-grid {
        grid-template-columns: 1fr;
    }

    table {
        font-size: 0.82rem;
    }

    th, td {
        padding: 0.5rem 0.6rem;
    }
}

@media (max-width: 600px) {
    :root {
        --sidebar-width: 260px;
    }

    h1 { font-size: 1.6rem; }
    h2 { font-size: 1.25rem; }
    h3 { font-size: 1.1rem; }

    .hero h1 { font-size: 1.7rem; }
    .hero p { font-size: 0.95rem; }

    pre {
        font-size: 0.78rem;
        padding: 0.75rem;
    }
}

/* --- Print Styles --- */
@media print {
    .top-bar,
    .sidebar,
    .hamburger,
    .search-container {
        display: none !important;
    }

    .main-content {
        margin-left: 0 !important;
        margin-top: 0 !important;
        padding: 0 !important;
    }

    body {
        background: #fff;
        color: #222;
        font-size: 11pt;
    }

    h1, h2, h3, h4, h5, h6 {
        color: #111;
        break-after: avoid;
    }

    h1 { border-bottom-color: #333; }
    h2 { border-bottom-color: #999; }
    h3 { color: #333; }

    a {
        color: #333;
        text-decoration: underline;
    }

    a[href]::after {
        content: " (" attr(href) ")";
        font-size: 0.8em;
        color: #666;
    }

    .sidebar a[href]::after {
        content: "";
    }

    pre, code {
        background: #f5f5f5 !important;
        border-color: #ddd !important;
        color: #222 !important;
    }

    :not(pre) > code {
        background: #eee !important;
        color: #333 !important;
    }

    .card {
        background: #fafafa;
        border-color: #ddd;
        break-inside: avoid;
    }

    .callout {
        background: #f9f9f9;
        break-inside: avoid;
    }

    table {
        break-inside: auto;
    }

    thead {
        background: #eee;
    }

    th {
        border-bottom-color: #333;
        color: #111;
    }

    td {
        border-bottom-color: #ddd;
    }

    .badge {
        border: 1px solid #999;
        color: #333;
        background: #eee;
    }

    .footer {
        color: #666;
        border-top-color: #ddd;
    }
}
