/* 基礎設定 */
:root {
    /* Bright Theme - 明亮主題（Tux 白腹配色） */
    --bg-primary: #ffffff;
    --bg-secondary: #f8f9fa;
    --bg-sidebar: #1a1a1a;
    --text-primary: #2c2c2c;
    --text-secondary: #5a5a5a;
    --text-sidebar: #e8e8e8;
    --border-color: #e0e0e0;
    --link-color: #d4a017;
    --link-hover: #b8860b;
    --code-bg: #f5f5f5;
    --accent-yellow: #fdb924;
    --accent-black: #1a1a1a;
    --sidebar-width: 280px;
}

[data-theme="dark"] {
    /* Dark Theme - 深色主題（Tux 黑身配色） */
    --bg-primary: #1a1a1a;
    --bg-secondary: #242424;
    --bg-sidebar: #0d0d0d;
    --text-primary: #d4d4d4;
    --text-secondary: #9a9a9a;
    --text-sidebar: #e0e0e0;
    --border-color: #333333;
    --link-color: #fdb924;
    --link-hover: #ffc940;
    --code-bg: #2a2a2a;
    --accent-yellow: #fdb924;
    --accent-black: #0d0d0d;
}

[data-theme="system"] {
    /* System Theme - 護眼主題（柔和配色） */
    --bg-primary: #f4f1ea;
    --bg-secondary: #e8e4da;
    --bg-sidebar: #2a2622;
    --text-primary: #3a3632;
    --text-secondary: #6a6662;
    --text-sidebar: #e8e4da;
    --border-color: #d4d0c6;
    --link-color: #c9941a;
    --link-hover: #a67c15;
    --code-bg: #e8e4da;
    --accent-yellow: #d4a017;
    --accent-black: #2a2622;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans TC", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 16px;
    line-height: 1.7;
    color: var(--text-primary);
    background-color: var(--bg-primary);
    transition: background-color 0.3s, color 0.3s;
}

/* 手機版頂部選單 */
.mobile-header {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 56px;
    background-color: var(--bg-sidebar);
    color: var(--text-sidebar);
    align-items: center;
    padding: 0 1rem;
    border-bottom: 1px solid var(--border-color);
    z-index: 1001;
}

.mobile-header h1 {
    font-size: 1.1rem;
    font-weight: 600;
    margin: 0;
}

.mobile-menu-btn {
    background: none;
    border: none;
    color: var(--text-sidebar);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.5rem;
    margin-right: 0.75rem;
}

/* 容器佈局 */
.container {
    display: flex;
    min-height: 100vh;
}

/* 側邊欄 */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--bg-sidebar);
    color: var(--text-sidebar);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    overflow-y: auto;
    border-right: 1px solid var(--border-color);
    transition: transform 0.3s ease;
    z-index: 1000;
}

.sidebar-header {
    padding: 1.5rem 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sidebar-header h1 {
    font-size: 1.3rem;
    font-weight: 600;
    color: var(--text-sidebar);
}

.sidebar-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text-sidebar);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.25rem;
}

/* 側邊欄遮罩（手機版） */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 999;
}

/* 文件樹 */
.doc-tree {
    flex: 1;
    padding: 1rem 0;
    overflow-y: auto;
}

.doc-tree ul {
    list-style: none;
    padding-left: 0;
}

.doc-tree > ul {
    padding-left: 0;
}

.doc-tree ul ul {
    padding-left: 1.25rem;
}

.doc-tree li {
    margin: 0.25rem 0;
}

.doc-tree a {
    display: block;
    padding: 0.5rem 1rem;
    color: var(--text-sidebar);
    text-decoration: none;
    transition: background-color 0.2s;
    border-radius: 4px;
}

.doc-tree a:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.doc-tree a.active {
    background-color: var(--link-color);
    color: white;
    font-weight: 500;
}

.doc-tree .dir {
    margin: 0.5rem 0;
}

.doc-tree .dir-toggle {
    cursor: pointer;
    user-select: none;
    display: inline-block;
    width: 1rem;
    transition: transform 0.2s;
}

.doc-tree .dir.open > .dir-toggle {
    transform: rotate(90deg);
}

.doc-tree .dir-name {
    font-weight: 600;
    color: var(--text-sidebar);
    opacity: 0.9;
}

.doc-tree .dir > ul {
    display: none;
}

.doc-tree .dir.open > ul {
    display: block;
}

.sidebar-footer {
    padding: 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.theme-toggle {
    width: 100%;
    padding: 0.625rem;
    background-color: rgba(255, 255, 255, 0.1);
    border: none;
    color: var(--text-sidebar);
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.95rem;
    transition: background-color 0.2s;
}

.theme-toggle:hover {
    background-color: rgba(255, 255, 255, 0.2);
}

/* 主內容區 */
.content {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: 2rem;
    transition: margin-left 0.3s ease;
}

.content-wrapper {
    max-width: 900px;
    margin: 0 auto;
}

/* 文件內容樣式 */
.content-wrapper h1 {
    font-size: 2.25rem;
    margin: 2rem 0 1rem 0;
    color: var(--text-primary);
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 0.5rem;
}

.content-wrapper h2 {
    font-size: 1.75rem;
    margin: 1.75rem 0 1rem 0;
    color: var(--text-primary);
}

.content-wrapper h3 {
    font-size: 1.4rem;
    margin: 1.5rem 0 0.75rem 0;
    color: var(--text-primary);
}

.content-wrapper p {
    margin: 1rem 0;
    color: var(--text-primary);
}

.content-wrapper code {
    background-color: var(--code-bg);
    padding: 0.2rem 0.4rem;
    border-radius: 3px;
    font-family: "Consolas", "Monaco", "Courier New", monospace;
    font-size: 0.9em;
    color: var(--text-primary);
}

.content-wrapper pre {
    background-color: var(--code-bg);
    padding: 1rem;
    border-radius: 6px;
    overflow-x: auto;
    margin: 1rem 0;
    border: 1px solid var(--border-color);
}

.content-wrapper pre code {
    background: none;
    padding: 0;
    font-size: 0.9rem;
    line-height: 1.5;
}

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

.content-wrapper a:hover {
    color: var(--link-hover);
    text-decoration: underline;
}

.content-wrapper ul,
.content-wrapper ol {
    margin: 1rem 0;
    padding-left: 2rem;
}

.content-wrapper li {
    margin: 0.5rem 0;
}

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

/* RWD 響應式設計 */
@media (max-width: 1024px) {
    :root {
        --sidebar-width: 260px;
    }
}

@media (max-width: 768px) {
    .mobile-header {
        display: flex;
    }
    
    .sidebar {
        transform: translateX(-100%);
        top: 0;
    }
    
    .sidebar.open {
        transform: translateX(0);
        box-shadow: 2px 0 8px rgba(0, 0, 0, 0.3);
    }
    
    .sidebar-overlay.show {
        display: block;
    }
    
    .sidebar-toggle {
        display: block;
    }
    
    .content {
        margin-left: 0;
        padding: 1rem;
        margin-top: 56px;
    }
    
    .content-wrapper h1 {
        font-size: 1.75rem;
    }
    
    .content-wrapper h2 {
        font-size: 1.4rem;
    }
    
    .content-wrapper h3 {
        font-size: 1.2rem;
    }
}

@media (max-width: 480px) {
    body {
        font-size: 14px;
    }
    
    .content {
        padding: 0.75rem;
    }
}

/* 滾動條樣式 */
.sidebar::-webkit-scrollbar,
.doc-tree::-webkit-scrollbar {
    width: 8px;
}

.sidebar::-webkit-scrollbar-track,
.doc-tree::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1);
}

.sidebar::-webkit-scrollbar-thumb,
.doc-tree::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 4px;
}

.sidebar::-webkit-scrollbar-thumb:hover,
.doc-tree::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.5);
}
