/* ========================================
   XIAOW.AI - Documentation Layout
   ======================================== */

:root {
    /* Magazine Palette */
    --color-bg: #fcfcf9;
    --color-surface: #f9f7f2;
    --color-text: #2a2a2a;
    --color-text-secondary: #555555;
    --color-text-muted: #7a7a7a;
    --color-border: #e8e5dc;
    --color-accent: #d97706;
    --color-accent-secondary: #b45309;

    /* Typography - System fonts for better performance */
    --font-header: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "PingFang SC", "Microsoft YaHei", sans-serif;
    --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "PingFang SC", "Microsoft YaHei", sans-serif;
    --font-mono: "SFMono-Regular", "Consolas", "Liberation Mono", "Menlo", monospace;
    --font-display: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "PingFang SC", "Microsoft YaHei", sans-serif;

    /* Spacing */
    --container-max: 1100px;
    --section-padding: 7rem 0;
    --radius: 12px;
}

/* === Reset === */
* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
    font-family: var(--font-body);
    background-color: var(--color-bg);
    color: var(--color-text);
    line-height: 1.7;
    -webkit-font-smoothing: antialiased;
}
a {
    color: var(--color-accent);
    text-decoration: none;
    transition: all 0.2s ease;
    font-weight: 500;
}
a:hover {
    color: var(--color-accent-secondary);
}

/* === Header (Shared) === */
.navbar {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(252, 252, 249, 0.95);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--color-border);
}
.navbar-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 0;
}
.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-family: var(--font-display);
    font-size: 1.625rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--color-text);
    text-decoration: none;
}
.logo-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: var(--color-accent);
    border-radius: 10px;
    color: white;
    font-size: 1.5rem;
    font-weight: 700;
    font-family: var(--font-display);
}
.logo-icon svg {
    width: 24px;
    height: 24px;
    fill: white;
}
.logo-text {
    font-weight: 700;
    letter-spacing: -0.02em;
}
.nav-links {
    display: flex;
    gap: 2.5rem;
}
.nav-link {
    font-size: 0.9375rem;
    font-weight: 500;
    color: var(--color-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-family: var(--font-body);
    position: relative;
    padding: 0.25rem 0;
}
.nav-link::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--color-accent);
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 0.3s ease;
}
.nav-link:hover {
    color: var(--color-accent-secondary);
}
.nav-link:hover::after {
    transform: scaleX(1);
}
.nav-link.active::after {
    transform: scaleX(1);
}
.nav-actions {
    display: flex;
    align-items: center;
    gap: 1.25rem;
}
.nav-icon {
    color: var(--color-text-secondary);
    transition: all 0.2s ease;
}
.nav-icon svg {
    width: 22px;
    height: 22px;
    fill: currentColor;
}
.nav-icon:hover {
    color: var(--color-accent);
    transform: translateY(-2px);
}
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.625rem;
    padding: 0.875rem 1.75rem;
    font-size: 0.9375rem;
    font-weight: 600;
    font-family: var(--font-body);
    border-radius: 50px;
    cursor: pointer;
    white-space: nowrap;
    text-decoration: none;
    transition: all 0.25s ease;
}
.btn-primary {
    background: var(--color-accent);
    color: white;
    box-shadow: 0 8px 24px rgba(217, 119, 6, 0.25);
}
.btn-primary:hover {
    background: var(--color-accent-secondary);
    color: white;
    box-shadow: 0 12px 32px rgba(217, 119, 6, 0.3);
    transform: translateY(-2px);
}
.btn-secondary {
    background: transparent;
    border: 2px solid var(--color-border);
    color: var(--color-text);
}
.btn-secondary:hover {
    border-color: var(--color-accent);
    color: var(--color-accent-secondary);
    background: rgba(217, 119, 6, 0.05);
}
.btn-lg {
    padding: 1rem 2rem;
    font-size: 1rem;
}
.hamburger {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.25rem;
    position: relative;
}
.hamburger span,
.hamburger span::before,
.hamburger span::after {
    display: block;
    width: 24px;
    height: 3px;
    background: var(--color-text);
    border-radius: 2px;
    transition: all 0.3s ease;
}
.hamburger span::before { content: ''; position: relative; top: -8px; }
.hamburger span::after { content: ''; position: relative; top: 8px; }

/* === Documentation Layout === */
.doc-layout {
    display: flex;
    max-width: 1400px;
    margin: 0 auto;
    padding: 4rem 2rem;
    gap: 3rem;
}

/* === Sidebar Navigation === */
.sidebar-nav {
    position: sticky;
    top: 80px;
    height: fit-content;
    width: 280px;
    flex-shrink: 0;
}
.sidebar-title {
    font-family: var(--font-header);
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
    color: var(--color-text);
}
.sidebar-section {
    margin-bottom: 2.5rem;
}
.sidebar-section-title {
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--color-text-muted);
    margin-bottom: 1rem;
}
.sidebar-list {
    list-style: none;
}
.sidebar-list li {
    margin-bottom: 0.5rem;
}
.sidebar-list a {
    display: block;
    padding: 0.5rem 0.75rem;
    font-size: 0.9375rem;
    color: var(--color-text-secondary);
    border-radius: 6px;
    transition: all 0.2s ease;
}
.sidebar-list a:hover {
    color: var(--color-text);
    background: var(--color-surface);
}
.sidebar-list a.active {
    color: var(--color-accent);
    background: rgba(217, 119, 6, 0.05);
    font-weight: 500;
}
.sidebar-badge {
    display: inline-block;
    padding: 2px 8px;
    background: var(--color-accent);
    color: white;
    border-radius: 12px;
    font-size: 10px;
    font-weight: 600;
    margin-left: 8px;
}

/* === Main Content === */
.main-content {
    flex: 1;
    min-width: 0;
    max-width: 850px;
}
.doc-header {
    margin-bottom: 3rem;
}
.doc-title {
    font-family: var(--font-header);
    font-size: 3rem;
    font-weight: 900;
    line-height: 1.15;
    margin-bottom: 1.5rem;
    color: var(--color-text);
}
.doc-desc {
    font-size: 1.25rem;
    color: var(--color-text-secondary);
    line-height: 1.8;
}

/* === Content Sections === */
.doc-content {
    font-size: 1.125rem;
    line-height: 1.8;
    color: var(--color-text-secondary);
}
.doc-content p {
    margin-bottom: 1.5rem;
    color: var(--color-text-secondary);
}
.doc-content strong {
    color: var(--color-text);
    font-weight: 600;
}
.doc-content a {
    font-weight: 600;
}
.doc-content a:hover {
    text-decoration: underline;
}

/* Headings */
.doc-content h2 {
    font-family: var(--font-header);
    font-size: 2.25rem;
    font-weight: 700;
    margin: 4rem 0 1.75rem;
    color: var(--color-text);
    padding-bottom: 1rem;
    border-bottom: 2px solid var(--color-border);
}
.doc-content h3 {
    font-size: 1.625rem;
    font-weight: 600;
    margin: 3rem 0 1.25rem;
    color: var(--color-text);
}
.doc-content h4 {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 2rem 0 1rem;
    color: var(--color-text);
}

/* Lists */
.doc-content ul,
.doc-content ol {
    margin: 1.25rem 0 1.75rem 2rem;
}
.doc-content li {
    margin-bottom: 0.75rem;
    color: var(--color-text-secondary);
}

/* Code Blocks */
.code-block {
    background: #0d0d0d;
    border-radius: 12px;
    overflow: hidden;
    margin: 1.5rem 0;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}
.code-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    background: #1a1a1a;
    border-bottom: 1px solid #2a2a2a;
}
.code-language {
    font-family: var(--font-mono);
    font-size: 0.8125rem;
    color: #8b949e;
}
.code-lang-openai { color: #d97706; }
.code-lang-anthropic { color: #a855f7; }
.code-lang-gemini { color: #2563eb; }
.code-copy-btn {
    background: #2a2a2a;
    border: 1px solid #3d3d3d;
    color: #9ca3af;
    padding: 0.25rem 0.75rem;
    border-radius: 6px;
    font-size: 0.75rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.2s ease;
}
.code-copy-btn:hover {
    background: #3d3d3d;
    color: white;
    border-color: #525252;
}
.code-content {
    padding: 1rem;
    overflow-x: auto;
}
.code-content pre {
    margin: 0;
    font-family: var(--font-mono);
    font-size: 0.9rem;
    line-height: 1.6;
}
.code-comment { color: #6b7280; }
.code-string { color: #a5d6ff; }
.code-keyword { color: #f87171; }
.code-function { color: #818cf8; }
.code-number { color: #fbbf24; }
.code-variable { color: #34d399; }
.code-tag { color: #fca5a5; }
.code-attribute { color: #fcd34d; }

/* Callout Boxes */
.callout {
    padding: 1.25rem;
    border-radius: 8px;
    margin: 1.5rem 0;
}
.callout-info {
    background: #eff6ff;
    border-left: 4px solid #3b82f6;
}
.callout-warning {
    background: #fffbeb;
    border-left: 4px solid #f59e0b;
}
.callout-note {
    background: #f3f4f6;
    border-left: 4px solid #9ca3af;
}
.callout h4 {
    margin: 0 0 0.75rem 0;
    font-size: 1rem;
}
.callout p {
    margin: 0;
    color: var(--color-text-secondary);
}

/* API Table */
.api-table {
    width: 100%;
    border-collapse: collapse;
    margin: 2rem 0;
    background: white;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--color-border);
}
.api-table th {
    background: var(--color-surface);
    text-align: left;
    padding: 1rem 1.25rem;
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.api-table td {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--color-border);
    font-size: 0.9375rem;
}
.api-table tr:last-child td {
    border-bottom: none;
}
.api-table tr:hover td {
    background: var(--color-surface);
}
.api-table .endpoint {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    color: var(--color-accent);
}

/* Badge */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.badge-openai { background: #10a37f; color: white; }
.badge-anthropic { background: #a855f7; color: white; }
.badge-gemini { background: #2563eb; color: white; }

/* Right Sidebar - On This Page */
.right-sidebar {
    position: sticky;
    top: 80px;
    height: fit-content;
    width: 200px;
    flex-shrink: 0;
}
.right-sidebar-content {
    padding-left: 1rem;
    border-left: 2px solid var(--color-border);
}
.right-sidebar-title {
    font-size: 0.875rem;
    font-weight: 700;
    color: var(--color-text);
    margin-bottom: 1rem;
}
.right-sidebar-list {
    list-style: none;
}
.right-sidebar-list li {
    margin-bottom: 0.5rem;
}
.right-sidebar-list a {
    display: block;
    padding: 0.375rem 0;
    font-size: 0.875rem;
    color: var(--color-text-muted);
    transition: color 0.2s ease;
}
.right-sidebar-list a:hover {
    color: var(--color-accent);
}
.right-sidebar-list a.active {
    color: var(--color-accent);
    font-weight: 500;
}

/* === Footer === */
.doc-footer {
    border-top: 1px solid var(--color-border);
    padding: 2rem 0;
    margin-top: 4rem;
    background: white;
}
.footer-nav {
    display: flex;
    justify-content: space-between;
}
.footer-nav-item {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}
.footer-nav-item h4 {
    font-size: 0.875rem;
    font-weight: 700;
    color: var(--color-text);
}
.footer-nav-item a {
    font-size: 0.9375rem;
    color: var(--color-text-secondary);
}
.footer-nav-item a:hover {
    color: var(--color-accent);
}

/* === Responsive === */
@media (max-width: 968px) {
    .doc-layout {
        flex-direction: column;
        padding: 2rem 1rem;
    }
    .sidebar-nav {
        width: 100%;
        position: relative;
        top: 0;
    }
    .right-sidebar {
        display: none;
    }
}

@media (max-width: 768px) {
    .navbar-container {
        padding: 1rem 0;
    }
    .hamburger { display: block; }
    .nav-links {
        position: fixed;
        inset: 76px 0 0 0;
        background: white;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 0.5rem;
        transform: translateY(-100%);
        transition: transform 0.5s cubic-bezier(0.16, 1, 0.3, 1);
        border-bottom: 1px solid var(--color-border);
        padding-top: 2rem;
    }
    .nav-links.active { transform: translateY(0); }
    .nav-link { font-size: 1.125rem; }
    .nav-actions { display: none; }
    .doc-title { font-size: 1.875rem; }
    .sidebar-list a { font-size: 1rem; }
    .code-content pre { font-size: 0.8rem; }
}

/* Custom Scrollbar */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: #e8e5dc;
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover { background: #dcd9d0; }

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    *, ::before, ::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* API Info Box */
.api-info {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    padding: 1rem;
    margin: 1.5rem 0;
}
.api-info-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--color-border);
}
.api-info-row:last-child {
    border-bottom: none;
}
.api-info-row .label {
    font-weight: 600;
    color: var(--color-text);
    min-width: 80px;
}
.api-info-row .value {
    color: var(--color-text-secondary);
}

/* Feature Grid */
.feature-grid {
    display: grid;
    gap: 1.5rem;
    margin: 2rem 0;
}
.feature-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 12px;
    padding: 1.5rem;
}
.feature-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--color-text);
    margin-bottom: 0.5rem;
}
.feature-desc {
    font-size: 0.9375rem;
    color: var(--color-text-secondary);
}