/* BMS-EV Documentation — technical docs style
   Design: clean, readable, professional technical documentation
   Palette: neutral slate + BMS-EV accent (deep green energy) */

:root {
    --bg: #ffffff;
    --bg-alt: #f7f8fa;
    --text: #1a1f2b;
    --text-muted: #556173;
    --border: #e2e6ec;
    --accent: #0a4d2c;
    --accent-hover: #075e34;
    --accent-bg: #e8f3ed;
    --code-bg: #f4f5f7;
    --code-text: #24292f;
    --tested: #16a34a;
    --pending: #ca8a04;
    --not-supported: #dc2626;
    --link: #0a4d2c;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.06);
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg: #0d1117;
        --bg-alt: #161b22;
        --text: #e6edf3;
        --text-muted: #8b949e;
        --border: #30363d;
        --accent: #56d364;
        --accent-hover: #7ee787;
        --accent-bg: #143020;
        --code-bg: #161b22;
        --code-text: #c9d1d9;
        --link: #79c0ff;
    }
}
:root[data-theme="dark"] {
    --bg: #0d1117;
    --bg-alt: #161b22;
    --text: #e6edf3;
    --text-muted: #8b949e;
    --border: #30363d;
    --accent: #56d364;
    --accent-hover: #7ee787;
    --accent-bg: #143020;
    --code-bg: #161b22;
    --code-text: #c9d1d9;
    --link: #79c0ff;
}

* { box-sizing: border-box; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    margin: 0;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    font-size: 16px;
}

/* Top nav */
.docs-nav {
    background: var(--bg-alt);
    border-bottom: 1px solid var(--border);
    padding: 12px 24px;
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    gap: 24px;
    flex-wrap: wrap;
}
.docs-nav a { color: var(--text); text-decoration: none; font-weight: 500; }
.docs-nav a:hover { color: var(--accent); }
.docs-nav .brand {
    font-weight: 700;
    font-size: 18px;
    color: var(--accent);
}
.docs-nav .brand:hover { color: var(--accent-hover); }
.docs-nav .brand-sub { color: var(--text-muted); font-weight: 400; font-size: 14px; margin-left: 4px; }
.docs-nav .external {
    margin-left: auto;
    font-size: 14px;
    color: var(--text-muted);
}

/* Layout: sidebar + main */
.docs-container {
    max-width: 1280px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: 240px 1fr;
    gap: 32px;
    padding: 24px;
}
@media (max-width: 900px) {
    .docs-container { grid-template-columns: 1fr; padding: 16px; }
    .docs-sidebar { position: static; }
}

.docs-sidebar {
    position: sticky;
    top: 68px;
    align-self: start;
    max-height: calc(100vh - 88px);
    overflow-y: auto;
    padding-right: 8px;
}
.docs-sidebar h4 {
    font-size: 12px;
    text-transform: uppercase;
    color: var(--text-muted);
    margin: 20px 0 6px;
    letter-spacing: 0.05em;
    font-weight: 600;
}
.docs-sidebar h4:first-child { margin-top: 0; }
.docs-sidebar ul {
    list-style: none;
    padding: 0;
    margin: 0 0 12px;
}
.docs-sidebar li a {
    display: block;
    padding: 6px 10px;
    color: var(--text);
    text-decoration: none;
    border-radius: 6px;
    font-size: 14px;
}
.docs-sidebar li a:hover { background: var(--bg-alt); color: var(--accent); }
.docs-sidebar li a.active {
    background: var(--accent-bg);
    color: var(--accent);
    font-weight: 600;
}

.docs-main {
    min-width: 0;
    max-width: 880px;
}
.docs-main h1 {
    font-size: 34px;
    line-height: 1.2;
    margin: 0 0 8px;
    letter-spacing: -0.02em;
    color: var(--text);
    text-wrap: balance;
}
.docs-main .lede {
    font-size: 18px;
    color: var(--text-muted);
    margin: 0 0 32px;
}
.docs-main h2 {
    font-size: 24px;
    margin: 40px 0 12px;
    padding-top: 8px;
    border-top: 1px solid var(--border);
    padding-top: 32px;
}
.docs-main h2:first-of-type { border-top: none; padding-top: 0; }
.docs-main h3 { font-size: 18px; margin: 24px 0 8px; }
.docs-main p, .docs-main ul, .docs-main ol { margin: 0 0 16px; }
.docs-main a { color: var(--link); }
.docs-main code {
    background: var(--code-bg);
    color: var(--code-text);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: "SF Mono", Monaco, "Cascadia Code", "Roboto Mono", monospace;
    font-size: 90%;
}
.docs-main pre {
    background: var(--code-bg);
    color: var(--code-text);
    padding: 16px;
    border-radius: 8px;
    overflow-x: auto;
    border: 1px solid var(--border);
}
.docs-main pre code { background: none; padding: 0; font-size: 13px; }

/* Direct answer box - critical for AI */
.direct-answer {
    background: var(--accent-bg);
    border-left: 4px solid var(--accent);
    padding: 16px 20px;
    border-radius: 0 8px 8px 0;
    margin: 24px 0;
}
.direct-answer p { margin: 0; }
.direct-answer p + p { margin-top: 8px; }
.direct-answer strong { color: var(--accent); }

/* Compatibility table */
.compat-table {
    overflow-x: auto;
    margin: 24px 0;
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: var(--shadow-sm);
}
.compat-table table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
    font-variant-numeric: tabular-nums;
    min-width: 700px;
}
.compat-table th {
    background: var(--bg-alt);
    text-align: left;
    padding: 12px 14px;
    font-weight: 600;
    color: var(--text);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
}
.compat-table td {
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
.compat-table tr:last-child td { border-bottom: none; }
.compat-table tr:hover td { background: var(--bg-alt); }
.compat-table td.battery { font-weight: 500; }
.compat-table td.center { text-align: center; }

/* Status pills */
.status {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.4;
    white-space: nowrap;
}
.status-tested { background: rgba(22,163,74,0.12); color: var(--tested); }
.status-customer { background: rgba(59,130,246,0.12); color: #2563eb; }
.status-experimental { background: rgba(202,138,4,0.14); color: var(--pending); }
.status-not { background: rgba(220,38,38,0.12); color: var(--not-supported); }

/* Feature grid */
.feature-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 16px;
    margin: 24px 0;
}
.feature-card {
    background: var(--bg-alt);
    padding: 20px;
    border-radius: 10px;
    border: 1px solid var(--border);
}
.feature-card h3 { margin: 0 0 8px; font-size: 16px; }
.feature-card p { margin: 0; color: var(--text-muted); font-size: 14px; }

/* Meta info bar - last verified etc */
.meta-info {
    background: var(--bg-alt);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 14px 18px;
    font-size: 13px;
    color: var(--text-muted);
    display: flex;
    flex-wrap: wrap;
    gap: 16px 24px;
    margin: 32px 0;
}
.meta-info strong { color: var(--text); font-weight: 600; }

/* Diagram (ASCII / SVG container) */
.diagram {
    background: var(--code-bg);
    color: var(--code-text);
    padding: 20px;
    border-radius: 8px;
    font-family: "SF Mono", Monaco, monospace;
    font-size: 13px;
    line-height: 1.4;
    overflow-x: auto;
    white-space: pre;
    margin: 24px 0;
    border: 1px solid var(--border);
}

/* FAQ */
.faq details {
    background: var(--bg-alt);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 16px 20px;
    margin: 12px 0;
}
.faq summary {
    font-weight: 600;
    cursor: pointer;
    font-size: 15px;
    padding: 2px 0;
}
.faq details[open] summary { margin-bottom: 12px; }
.faq p { margin: 0; }

/* CTA to shop */
.shop-cta {
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-hover) 100%);
    color: white !important;
    padding: 20px 24px;
    border-radius: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    text-decoration: none;
    margin: 32px 0;
    flex-wrap: wrap;
}
.shop-cta:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); }
.shop-cta .cta-title { font-weight: 700; font-size: 18px; margin-bottom: 4px; }
.shop-cta .cta-sub { opacity: 0.9; font-size: 14px; }
.shop-cta .cta-arrow { font-size: 22px; }

/* Breadcrumb */
.breadcrumb {
    font-size: 13px;
    color: var(--text-muted);
    margin: 0 0 12px;
}
.breadcrumb a { color: var(--text-muted); }
.breadcrumb a:hover { color: var(--accent); }
.breadcrumb .sep { margin: 0 8px; }

/* Footer */
.docs-footer {
    border-top: 1px solid var(--border);
    padding: 32px 24px;
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
    margin-top: 60px;
}
.docs-footer a { color: var(--text-muted); }
.docs-footer a:hover { color: var(--accent); }

/* Homepage hero */
.hero {
    text-align: center;
    padding: 60px 20px 40px;
    background: linear-gradient(180deg, var(--accent-bg) 0%, var(--bg) 100%);
    margin: -24px -24px 32px;
    border-radius: 0 0 16px 16px;
}
.hero h1 {
    font-size: 42px;
    margin: 0 0 12px;
    color: var(--text);
}
.hero .lede { font-size: 18px; max-width: 640px; margin: 0 auto 24px; }
.hero-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    max-width: 900px;
    margin: 32px auto 0;
    padding: 0 24px;
}
.hero-cards a {
    background: var(--bg);
    padding: 20px;
    border-radius: 10px;
    border: 1px solid var(--border);
    text-decoration: none;
    color: var(--text);
    transition: transform 0.15s, box-shadow 0.15s;
}
.hero-cards a:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--accent); }
.hero-cards h3 { margin: 0 0 6px; font-size: 16px; color: var(--accent); }
.hero-cards p { margin: 0; font-size: 14px; color: var(--text-muted); }

/* Homepage-only layout: sidebar hidden */
.docs-container.no-sidebar {
    grid-template-columns: 1fr;
}
.docs-container.no-sidebar .docs-main { max-width: 100%; }
