:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #818cf8;
    --bg-dark: #0f172a;
    --bg-card: #1e293b;
    --bg-card-hover: #334155;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --border: #334155;
    --code-bg: #1e1e1e;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #3b82f6;
    --sidebar-width: 280px;
    --header-height: 60px;
    --mobile-header-height: 56px;
}

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-dark);
    color: var(--text-primary);
    line-height: 1.6;
}

/* App Container */
.app {
    display: flex;
    min-height: 100vh;
}

/* Overlay for mobile */
.overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.overlay.active {
    display: block;
    opacity: 1;
}

/* Mobile Header */
.mobile-header {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--mobile-header-height);
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    z-index: 998;
    display: flex;
    align-items: center;
    justify-content: center;
    padding-left: 56px;
}

.mobile-header h1 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

/* Mobile Menu Button */
.mobile-menu-btn {
    display: none;
    position: fixed;
    top: 12px;
    right: 12px;
    z-index: 1001;
    flex-direction: column;
    gap: 5px;
    background: var(--primary);
    border: none;
    border-radius: 8px;
    padding: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.mobile-menu-btn:hover {
    background: var(--primary-dark);
}

.mobile-menu-btn span {
    width: 20px;
    height: 2px;
    background: white;
    border-radius: 2px;
    transition: all 0.3s ease;
}

.mobile-menu-btn.active span:nth-child(1) {
    transform: rotate(45deg) translate(5px, 5px);
}

.mobile-menu-btn.active span:nth-child(2) {
    opacity: 0;
}

.mobile-menu-btn.active span:nth-child(3) {
    transform: rotate(-45deg) translate(5px, -5px);
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-card);
    border-right: 1px solid var(--border);
    height: 100vh;
    position: fixed;
    left: 0;
    top: 0;
    overflow-y: auto;
    transition: transform 0.3s ease;
    z-index: 1000;
}

.sidebar::-webkit-scrollbar {
    width: 6px;
}

.sidebar::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

.sidebar::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Sidebar Close Button (Mobile) */
.sidebar-close {
    display: none;
    position: absolute;
    top: 16px;
    right: 16px;
    width: 32px;
    height: 32px;
    background: var(--bg-card-hover);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    transition: all 0.2s ease;
}

.sidebar-close:hover {
    background: var(--border);
    color: var(--text-primary);
}

.sidebar-close svg {
    width: 18px;
    height: 18px;
}

.sidebar-header {
    padding: 24px 20px;
    border-bottom: 1px solid var(--border);
}

.logo {
    font-size: 28px;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary-light), var(--primary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 4px;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 13px;
}

/* Search Box */
.search-box {
    padding: 16px 20px;
    position: relative;
}

.search-box input {
    width: 100%;
    padding: 12px 16px 12px 40px;
    background: var(--bg-dark);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 14px;
    transition: all 0.2s ease;
}

.search-box input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

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

.search-icon {
    position: absolute;
    left: 32px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    color: var(--text-muted);
    pointer-events: none;
}

/* Navigation */
.nav-menu {
    padding: 8px 0;
}

.nav-group {
    margin-bottom: 8px;
}

.nav-group-title {
    padding: 8px 20px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
}

.nav-item {
    display: block;
    padding: 12px 20px;
    padding-left: 32px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 14px;
    transition: all 0.2s ease;
    border-left: 3px solid transparent;
}

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

.nav-item.active {
    background: rgba(99, 102, 241, 0.1);
    color: var(--primary-light);
    border-left-color: var(--primary);
}

/* Sidebar Footer */
.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border);
    font-size: 12px;
    color: var(--text-muted);
}

.sidebar-footer p {
    margin-bottom: 8px;
}

.sidebar-footer a {
    color: var(--primary-light);
    text-decoration: none;
}

.sidebar-footer a:hover {
    text-decoration: underline;
}

/* Main Content */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    padding: 32px 48px;
    max-width: 1200px;
    width: 100%;
    box-sizing: border-box;
    overflow-x: hidden;
}

/* Alert */
.alert {
    padding: 16px 20px;
    border-radius: 12px;
    margin-bottom: 24px;
    font-size: 14px;
}

.alert-warning {
    background: rgba(245, 158, 11, 0.1);
    border: 1px solid rgba(245, 158, 11, 0.3);
    color: var(--warning);
}

.alert-warning a {
    color: var(--warning);
    text-decoration: underline;
}

.alert-info {
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid rgba(59, 130, 246, 0.3);
    color: var(--info);
}

/* Section */
.section {
    margin-bottom: 48px;
    scroll-margin-top: 20px;
}

.section-header {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-bottom: 20px;
}

.section-title {
    flex: 0 1 auto;
    order: 1;
}

.section-header .bookmark-link {
    order: 2;
}

.section-header .section-desc {
    flex-basis: 100%;
    order: 3;
}

.section-title {
    font-size: 28px;
    font-weight: 600;
    color: var(--text-primary);
}

.section-desc {
    color: var(--text-secondary);
    margin-bottom: 0;
    font-size: 15px;
}

/* Bookmark Link */
.bookmark-link {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    color: var(--text-muted);
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.bookmark-link:hover {
    background: var(--bg-card-hover);
    color: var(--primary-light);
}

.bookmark-link svg {
    width: 16px;
    height: 16px;
}

/* Card */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 24px;
    max-width: 100%;
    overflow-x: hidden;
}

/* Notice List */
.notice-list {
    list-style: none;
}

.notice-item {
    padding: 16px;
    border-radius: 8px;
    margin-bottom: 12px;
    line-height: 1.8;
    word-break: break-word;
    overflow-wrap: break-word;
}

.notice-item:last-child {
    margin-bottom: 0;
}

.notice-item.warning {
    background: rgba(239, 68, 68, 0.1);
    border-left: 4px solid var(--danger);
}

.notice-item.info {
    background: rgba(59, 130, 246, 0.1);
    border-left: 4px solid var(--info);
}

.notice-item strong {
    font-weight: 600;
    color: var(--text-primary);
}

.notice-item code {
    background: rgba(0, 0, 0, 0.3);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 13px;
    color: var(--primary-light);
    white-space: nowrap;
    max-width: 100%;
    overflow-wrap: break-word;
}

/* File List */
.file-list {
    display: grid;
    gap: 16px;
    margin-bottom: 24px;
}

.file-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
    background: var(--bg-dark);
    border-radius: 8px;
}

.file-icon {
    font-size: 24px;
}

.file-item code {
    font-size: 14px;
    color: var(--primary-light);
}

.file-item p {
    color: var(--text-secondary);
    font-size: 13px;
    margin-top: 4px;
}

/* Config Box & Folder Tree */
.config-box, .folder-tree {
    background: var(--bg-dark);
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 16px;
}

.config-box h4, .folder-tree h4 {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.config-box pre, .folder-tree pre {
    margin: 0;
}

/* API Grid */
.api-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

.api-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px;
    position: relative;
    transition: all 0.2s ease;
}

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

.api-type {
    font-size: 11px;
    color: var(--primary-light);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.api-name {
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.api-desc {
    font-size: 13px;
    color: var(--text-secondary);
}

/* Card Bookmark */
.card-bookmark {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    opacity: 0;
    transition: all 0.2s ease;
}

.api-card:hover .card-bookmark,
.api-item:hover .card-bookmark,
.callback-card:hover .card-bookmark {
    opacity: 1;
}

.card-bookmark:hover {
    background: var(--bg-card-hover);
    color: var(--primary-light);
}

.card-bookmark svg {
    width: 14px;
    height: 14px;
}

/* Example Box */
.example-box {
    background: var(--bg-dark);
    border-radius: 12px;
    padding: 20px;
}

.example-box h4 {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.example-box pre {
    margin: 0;
}

/* Code Block Large */
.code-block-large {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    max-width: 100%;
}

.code-block-large pre {
    margin: 0;
    padding: 24px;
    overflow-x: auto;
    max-width: 100%;
}

/* Callback List */
.callback-list {
    display: grid;
    gap: 16px;
    margin-bottom: 20px;
}

.callback-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px;
    position: relative;
}

.callback-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.callback-header h4 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.callback-card p {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 12px;
}

.signature {
    background: var(--bg-dark);
    padding: 12px 16px;
    border-radius: 8px;
    margin: 12px 0;
    overflow-x: auto;
    max-width: 100%;
}

.signature code {
    display: block;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 13px;
    color: var(--primary-light);
    white-space: pre-wrap;
    word-break: break-word;
    margin-bottom: 4px;
}

.signature code:last-child {
    margin-bottom: 0;
}

.signature-note {
    font-size: 12px;
    color: var(--text-muted);
    margin: 4px 0 12px 0;
    padding-left: 8px;
}

.signature-note:last-of-type {
    margin-bottom: 0;
}

.param-list {
    margin-top: 16px;
}

.param-list h5 {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.params {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.param {
    background: var(--bg-dark);
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12px;
    color: var(--text-secondary);
}

.param code {
    color: var(--primary-light);
}

/* Details for params/struct */
.params-detail,
.struct-detail {
    margin-top: 12px;
}

.params-detail summary,
.struct-detail summary {
    cursor: pointer;
    color: var(--primary-light);
    font-size: 13px;
    user-select: none;
    padding: 8px 12px;
    background: var(--bg-dark);
    border-radius: 6px;
    display: inline-block;
}

.params-detail[open] summary,
.struct-detail[open] summary {
    margin-bottom: 12px;
}

.params-detail .params,
.struct-detail ul {
    margin-top: 8px;
}

.struct-detail ul {
    list-style: none;
}

.struct-detail li {
    padding: 6px 0;
    font-size: 13px;
    color: var(--text-secondary);
}

.struct-detail li code {
    font-family: 'Consolas', 'Monaco', monospace;
    color: var(--primary-light);
}

/* API List */
.api-list {
    display: grid;
    gap: 16px;
}

.api-item {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px;
    position: relative;
    max-width: 100%;
    overflow: hidden;
    word-wrap: break-word;
}

.api-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.api-header h4 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.api-item p {
    color: var(--text-secondary);
    font-size: 14px;
}

.api-note {
    margin-top: 8px;
    font-size: 13px;
    color: var(--text-muted);
}

.api-notes {
    margin-top: 12px;
    list-style: none;
}

.api-notes li {
    font-size: 13px;
    color: var(--text-muted);
    padding-left: 16px;
    position: relative;
}

.api-notes li::before {
    content: '';
    position: absolute;
    left: 0;
    top: 8px;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: var(--primary);
}

/* API Group */
.api-group {
    margin-bottom: 32px;
}

.api-group:last-child {
    margin-bottom: 0;
}

.api-group h3 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--text-primary);
}

/* Pre & Code */
pre {
    background: var(--code-bg);
    border-radius: 8px;
    padding: 16px;
    overflow-x: auto;
    max-width: 100%;
    position: relative;
}

pre code {
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 13px;
    line-height: 1.6;
    white-space: pre;
    word-break: break-all;
    padding-right: 40px;
}

/* Code Copy Button */
.code-copy-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 32px;
    height: 32px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: all 0.2s ease;
    color: var(--text-secondary);
}

pre:hover .code-copy-btn {
    opacity: 1;
}

.code-copy-btn:hover {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

.code-copy-btn.copied {
    background: var(--success);
    border-color: var(--success);
    color: white;
}

.code-copy-btn svg {
    width: 16px;
    height: 16px;
}

/* Highlight.js overrides */
.hljs {
    background: transparent !important;
    padding: 0 !important;
}

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

.footer p {
    margin-bottom: 8px;
}

/* Search Highlight */
.search-highlight {
    background: rgba(245, 158, 11, 0.3);
    border-radius: 3px;
    padding: 0 2px;
}

/* Copy Toast */
.copy-toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--success);
    color: white;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    opacity: 0;
    transition: all 0.3s ease;
    z-index: 9999;
}

.copy-toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .main-content {
        padding: 24px 32px;
    }

    .api-grid {
        grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    }
}

@media (max-width: 768px) {
    .mobile-menu-btn {
        display: flex;
    }

    .mobile-header {
        display: none;
    }

    .sidebar {
        transform: translateX(-100%);
    }

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

    .sidebar-close {
        display: flex;
    }

    .main-content {
        margin-left: 0;
        padding: 70px 16px 24px;
        width: 100%;
        max-width: 100vw;
        overflow-x: hidden;
    }

    .section {
        max-width: 100%;
        overflow-x: hidden;
        scroll-margin-top: 20px;
    }

    .card {
        padding: 16px;
        overflow-x: hidden;
    }

    .api-item {
        padding: 16px;
        overflow-x: hidden;
    }

    .api-list {
        gap: 12px;
    }

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

    .section-title {
        font-size: 22px;
        word-break: break-word;
    }

    .section-header {
        gap: 4px;
    }

    .code-block-large pre {
        padding: 16px;
        font-size: 12px;
    }

    .signature {
        overflow-x: auto;
        padding: 10px 12px;
    }

    .signature code {
        white-space: pre-wrap;
        font-size: 11px;
        word-break: break-word;
    }

    .signature-note {
        font-size: 11px;
    }

    .notice-item {
        padding: 12px;
        font-size: 14px;
    }

    .notice-item code {
        font-size: 12px;
        padding: 1px 4px;
    }

    pre {
        font-size: 12px;
        padding: 12px;
    }

    pre code {
        font-size: 12px;
        word-break: break-all;
    }

    .code-copy-btn {
        opacity: 1;
        width: 28px;
        height: 28px;
    }

    .code-copy-btn svg {
        width: 14px;
        height: 14px;
    }

    /* Mobile search placeholder */
    .search-box input::placeholder {
        content: attr(placeholder-mobile);
    }
}

@media (max-width: 480px) {
    .main-content {
        padding: 68px 12px 20px;
    }

    .mobile-menu-btn {
        top: 8px;
        right: 8px;
        padding: 8px;
    }

    .mobile-header {
        padding-left: 48px;
    }

    .mobile-header h1 {
        font-size: 14px;
    }

    .section-title {
        font-size: 20px;
        word-break: break-word;
    }

    .card {
        padding: 12px;
    }

    .api-card,
    .api-item,
    .callback-card {
        padding: 12px;
        overflow-x: hidden;
    }

    .signature {
        padding: 8px 10px;
    }

    .signature code {
        font-size: 10px;
    }

    .signature-note {
        font-size: 10px;
    }

    .card-bookmark {
        opacity: 1;
    }

    .notice-item {
        padding: 10px;
        font-size: 13px;
        gap: 8px;
    }

    .notice-item code {
        font-size: 11px;
        padding: 1px 3px;
    }

    pre {
        padding: 10px;
        font-size: 11px;
    }

    pre code {
        font-size: 11px;
    }

    .code-copy-btn {
        width: 26px;
        height: 26px;
        top: 6px;
        right: 6px;
    }

    .code-copy-btn svg {
        width: 12px;
        height: 12px;
    }
}

/* Touch targets for mobile */
@media (max-width: 768px) {
    .nav-item {
        padding: 14px 20px;
        padding-left: 32px;
        font-size: 15px;
    }

    .bookmark-link,
    .card-bookmark {
        width: 36px;
        height: 36px;
    }

    .bookmark-link svg,
    .card-bookmark svg {
        width: 18px;
        height: 18px;
    }
}

/* Print styles */
@media print {
    .mobile-menu-btn,
    .mobile-header,
    .sidebar,
    .overlay,
    .bookmark-link,
    .card-bookmark,
    .back-to-top {
        display: none !important;
    }

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

    .section {
        page-break-inside: avoid;
    }

    body {
        background: white;
        color: black;
    }

    .card,
    .api-card,
    .api-item,
    .callback-card {
        border: 1px solid #ccc;
        box-shadow: none;
    }
}
