@import url("https://font.emtech.cc/css/TaipeiSansTC");

:root {
    --primary: #000000;
    --primary-dark: #171717;
    --bg-main: #f8fafc;
    --bg-sidebar: #ffffff;
    --text-main: #2d2d2d;
    --text-muted: #64748b;
    --border-color: #e5e5e5;
    --code-bg: #f5f5f5;
    --nav-height: 64px;
    --sidebar-width: 280px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: 'Public Sans', 'Noto Sans TC', -apple-system, sans-serif;
    line-height: 1.6;
    color: var(--text-main);
    background: var(--bg-main);
}

h1, h2, h3, h4, h5, h6 {
    font-family: 'TaipeiSansTC', 'Public Sans', sans-serif;
}

/* Layout - Three Column Structure */
.docs-container {
    display: grid;
    grid-template-columns: 250px minmax(0, 1100px) 250px;
    justify-content: center;
    margin: 0 auto;
    gap: 2rem;
    padding: 0 2rem;
    padding-top: calc(var(--nav-height) + 2rem);
    min-height: 100vh;
}

/* Full-width layout for editor pages */
.docs-container.full-width {
    grid-template-columns: 250px 1fr 250px;
    max-width: 100%;
    padding: 0 1rem;
}

/* Layout variation for pages without TOC (like tools) */
.main-content.wide {
    grid-column: 2 / 4;
    /* Span across middle and right (TOC) columns */
}

.sidebar {
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    position: sticky;
    top: calc(var(--nav-height) + 1rem);
    height: calc(100vh - var(--nav-height) - 2rem);
    overflow-y: auto;
    padding: 1.5rem;
}

.main-content {
    padding: 3rem 4rem;
}

/* Navigation */
.docs-nav {
    height: var(--nav-height);
    background: #ffffff;
    border-bottom: 1px solid var(--border-color);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    z-index: 100;
}

.nav-brand {
    font-weight: 700;
    font-size: 1.25rem;
    color: var(--primary);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.nav-brand img {
    height: 32px;
}

.lang-switch {
    display: flex;
    gap: 0.5rem;
}

.lang-btn {
    padding: 0.4rem 0.8rem;
    border-radius: 6px;
    font-size: 0.875rem;
    text-decoration: none;
    color: var(--text-muted);
    border: 1px solid var(--border-color);
    transition: all 0.2s;
}

.lang-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* Sidebar Links */
.sidebar-group {
    margin-bottom: 2rem;
}

.sidebar-group-title {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 0.05em;
    margin-bottom: 1rem;
}

.sidebar-link {
    display: block;
    padding: 0.5rem 0;
    color: var(--text-main);
    text-decoration: none;
    font-size: 0.9375rem;
    transition: color 0.2s;
}

.sidebar-link:hover {
    color: var(--primary);
}

.sidebar-link.active {
    color: var(--primary);
    font-weight: 600;
}

/* Typography */
h1 {
    font-family: 'Space Mono', monospace;
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
    color: #1a1a1a;
}

h2 {
    font-family: 'Space Mono', monospace;
    font-size: 1.75rem;
    font-weight: 700;
    margin: 2.5rem 0 1rem;
    color: #1e293b;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.5rem;
}

h3 {
    font-family: 'Space Mono', monospace;
    font-size: 1.25rem;
    font-weight: 600;
    margin: 1.5rem 0 0.75rem;
    color: #334155;
}

p {
    margin-bottom: 1.25rem;
    color: var(--text-main);
}

ul,
ol {
    margin-bottom: 1.25rem;
    padding-left: 1.5rem;
}

li {
    margin-bottom: 0.5rem;
}

/* Code Blocks */
code {
    font-family: 'Space Mono', monospace;
    background: var(--code-bg);
    padding: 0.2rem 0.5rem;
    border-radius: 6px;
    font-size: 0.9em;
    color: #171717;
    font-weight: 500;
}

pre {
    background: #1e1e1e;
    color: #e4e4e4;
    padding: 1.5rem;
    border-radius: 12px;
    overflow-x: auto;
    margin: 1.5rem 0;
    border: 1px solid #333;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

pre code {
    background: transparent;
    padding: 0;
    color: inherit;
    font-size: 0.875rem;
    font-weight: 400;
}

/* Tables */
table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.5rem 0;
    background: white;
}

th,
td {
    border: 1px solid var(--border-color);
    padding: 0.75rem 1rem;
    text-align: left;
}

th {
    background: #f1f5f9;
    font-weight: 600;
}

/* Callouts */
.callout {
    padding: 1.25rem 1.5rem;
    border-left: 4px solid var(--primary);
    background: #eff6ff;
    margin: 1.5rem 0;
    border-radius: 0 8px 8px 0;
}

/* TOC Sidebar */
.toc-sidebar {
    position: sticky;
    top: calc(var(--nav-height) + 1rem);
    height: fit-content;
    max-height: calc(100vh - var(--nav-height) - 2rem);
    overflow-y: auto;
    padding: 1rem 0;
}

.toc-title {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

.toc-links {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.toc-link {
    font-size: 0.875rem;
    color: var(--text-muted);
    text-decoration: none;
    padding: 0.25rem 0;
    transition: color 0.2s;
    border-left: 2px solid transparent;
    padding-left: 0.75rem;
}

.toc-link:hover {
    color: var(--primary);
}

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

.toc-link.level-3 {
    padding-left: 1.5rem;
    font-size: 0.8125rem;
}

/* Responsive */
@media (max-width: 1024px) {
    .docs-container {
        grid-template-columns: 240px 1fr;
    }

    .toc-sidebar {
        display: none;
    }
}

@media (max-width: 768px) {
    .docs-container {
        grid-template-columns: 1fr;
        padding: 0 1.5rem;
    }

    .sidebar {
        display: none;
    }

    .toc-sidebar {
        display: none;
    }

    .main-content {
        max-width: 100%;
        padding: 2rem 0;
        margin-left: 0;
    }
}