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

:root {
    --color-primary: #24292e;
    --color-background: #ffffff;
    --color-sidebar-bg: #f6f8fa;
    --color-border: #e1e4e8;
    --color-link: #0366d6;
    --color-code-bg: #f6f8fa;
    --font-main: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
    --font-code: SFMono-Regular, Consolas, "Liberation Mono", Menlo, monospace;
    --sidebar-width: 280px;
    --header-height: 60px;
    --footer-height: 50px;
}

body {
    font-family: var(--font-main);
    color: var(--color-primary);
    background: var(--color-background);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.site-header {
    background: var(--color-background);
    border-bottom: 1px solid var(--color-border);
    height: var(--header-height);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
}

.header-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 20px;
    height: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.site-title {
    font-size: 1.25rem;
    font-weight: 600;
    flex: 1;
}

.search-container {
    display: flex;
    gap: 8px;
    align-items: center;
}

#search-input {
    padding: 6px 12px;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    font-size: 0.875rem;
    width: 200px;
}

#search-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1rem;
}

/* Main Container */
.main-container {
    display: flex;
    margin-top: var(--header-height);
    margin-bottom: var(--footer-height);
    min-height: calc(100vh - var(--header-height) - var(--footer-height));
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--color-sidebar-bg);
    border-right: 1px solid var(--color-border);
    position: fixed;
    left: 0;
    top: var(--header-height);
    bottom: var(--footer-height);
    overflow-y: auto;
}

#topic-list {
    list-style: none;
    padding: 16px 0;
}

#topic-list li a {
    display: block;
    padding: 8px 20px;
    color: var(--color-primary);
    text-decoration: none;
    font-size: 0.9rem;
    transition: background 0.15s ease;
}

#topic-list li a:hover {
    background: var(--color-border);
}

#topic-list li a.active {
    background: var(--color-link);
    color: white;
}

/* Content Area */
.content {
    margin-left: var(--sidebar-width);
    flex: 1;
    padding: 40px;
    padding-bottom: 70px;
    max-width: 900px;
}

.topic-content h1,
.topic-content h2,
.topic-content h3 {
    margin-top: 24px;
    margin-bottom: 16px;
    font-weight: 600;
}

.topic-content h1 { font-size: 2rem; }
.topic-content h2 { font-size: 1.5rem; }
.topic-content h3 { font-size: 1.25rem; }

.topic-content p {
    margin-bottom: 16px;
}

.topic-content code {
    background: var(--color-code-bg);
    padding: 2px 6px;
    border-radius: 3px;
    font-family: var(--font-code);
    font-size: 0.9em;
}

.topic-content pre {
    background: var(--color-code-bg);
    padding: 16px;
    border-radius: 6px;
    overflow-x: auto;
    margin-bottom: 16px;
    position: relative;
}

.topic-content pre code {
    background: none;
    padding: 0;
}

.topic-content img {
    max-width: 100%;
    height: auto;
    border-radius: 6px;
    margin: 16px 0;
}

.topic-content ul,
.topic-content ol {
    margin-bottom: 16px;
    padding-left: 24px;
}

.topic-content blockquote {
    border-left: 4px solid var(--color-border);
    padding-left: 16px;
    margin: 16px 0;
    color: #6a737d;
}

.topic-content a {
    color: var(--color-link);
    text-decoration: none;
}

.topic-content a:hover {
    text-decoration: underline;
}

/* Footer */
.site-footer {
    background: var(--color-background);
    border-top: 1px solid var(--color-border);
    height: var(--footer-height);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
    color: #6a737d;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 99;
}

/* Search Results */
.search-results {
    position: absolute;
    top: 100%;
    right: 0;
    background: white;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    width: 300px;
    max-height: 400px;
    overflow-y: auto;
    display: none;
    z-index: 200;
}

.search-results.show {
    display: block;
}

.search-result-item {
    padding: 12px;
    cursor: pointer;
    border-bottom: 1px solid var(--color-border);
}

.search-result-item:last-child {
    border-bottom: none;
}

.search-result-item:hover {
    background: var(--color-sidebar-bg);
}

.search-result-item .title {
    font-weight: 600;
    margin-bottom: 4px;
}

.search-result-item .snippet {
    font-size: 0.875rem;
    color: #6a737d;
}

/* Loading State */
.loading {
    text-align: center;
    padding: 40px;
    color: #6a737d;
}

.error {
    text-align: center;
    padding: 40px;
    color: #d73a49;
}

/* Code Copy Button */
.code-block-wrapper {
    position: relative;
}

.copy-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    background: var(--color-border);
    border: none;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.15s;
}

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

.copy-btn:hover {
    background: var(--color-link);
    color: white;
}

/* Mobile Overlay */
.mobile-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 140;
}

.mobile-overlay.show {
    display: block;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    :root {
        --sidebar-width: 0px;
        --header-height: 60px;
    }

    .main-container {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        position: relative;
        top: 0;
        bottom: auto;
        border-right: none;
        border-bottom: 1px solid var(--color-border);
        max-height: 200px;
        overflow-y: auto;
    }

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

    .header-container {
        padding: 0 16px;
    }

    .site-title {
        font-size: 1rem;
    }
}

@media (min-width: 769px) {
    .menu-toggle {
        display: none !important;
    }
}

.menu-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    margin-right: 12px;
}
