/* ========== 1. Github Content Layout ========== */
.github-content {
    display: grid;
    grid-template-columns: 1fr 4fr;
    gap: 20px;
    height: calc(100vh - 380px);
    min-height: 500px;
    margin: 2rem;
    width: 100%;
}

/* ========== 2. Left Panel — File Tree ========== */
.github-file {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.repo-header {
    padding: 16px 18px 14px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.repo-header-top {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

.repo-icon {
    color: var(--text-secondary);
    flex-shrink: 0;
}

.repo-name {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--accent);
    transition: opacity 0.2s;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.repo-name:hover {
    opacity: 0.8;
    text-decoration: underline;
}

.repo-desc {
    display: block;
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin: 4px 0 10px;
    padding-left: 28px;
}

.repo-stats {
    display: flex;
    align-items: center;
    gap: 16px;
    font-size: 0.78rem;
    color: var(--text-secondary);
    padding-left: 28px;
}

.repo-stat,
.repo-lang {
    display: flex;
    align-items: center;
    gap: 4px;
}

.repo-stat svg {
    color: var(--text-tertiary);
}

.lang-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #3572A5;
    display: inline-block;
}

.file-tree {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.tree-header {
    padding: 10px 18px;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.tree-list {
    flex: 1;
    overflow-y: auto;
    padding: 6px 0;
}

.tree-list::-webkit-scrollbar {
    width: 6px;
}

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

/* ========== 3. Tree Items ========== */
.tree-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 18px 6px 12px;
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--text-primary);
    transition: background 0.15s;
    user-select: none;
    position: relative;
}

.tree-item:hover {
    background: var(--row-hover);
}

.tree-item.is-active {
    background: rgba(59, 130, 246, 0.1);
    color: var(--accent);
}

.tree-item .tree-icon {
    flex-shrink: 0;
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-tertiary);
}

.tree-item .tree-icon.is-dir {
    color: var(--accent);
}

.tree-item .tree-icon.is-file {
    color: var(--text-tertiary);
}

.tree-item .tree-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tree-item .tree-arrow {
    font-size: 0.6rem;
    color: var(--text-tertiary);
    transition: transform 0.2s;
    flex-shrink: 0;
    width: 12px;
    text-align: center;
}

.tree-item .tree-arrow.is-open {
    transform: rotate(90deg);
}

.tree-children {
    overflow: hidden;
    transition: max-height 0.25s ease;
}

.tree-children.is-collapsed {
    max-height: 0;
}

.tree-children .tree-item {
    padding-left: 32px;
}

.tree-children .tree-children .tree-item {
    padding-left: 52px;
}

.tree-children .tree-children .tree-children .tree-item {
    padding-left: 72px;
}

/* ========== 4. Right Panel — File Viewer ========== */
.github-fileRead {
    min-width: 0;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.file-viewer {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.file-path {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    border-bottom: 1px solid var(--border);
    font-size: 0.82rem;
    font-family: var(--font-mono);
    color: var(--text-secondary);
    flex-shrink: 0;
    overflow-x: auto;
    white-space: nowrap;
    background: #FAFBFC;
}

.file-path::-webkit-scrollbar {
    height: 2px;
}

.file-path .path-sep {
    color: var(--text-tertiary);
    font-size: 0.7rem;
}

.file-path .path-item {
    color: var(--text-secondary);
    cursor: default;
}

.file-path .path-item:last-child {
    color: var(--text-primary);
    font-weight: 500;
}

.file-content {
    flex: 1;
    overflow: auto;
    padding: 0;
    position: relative;
}

.file-content::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.file-content::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

/* ========== 5. Code / Markdown Rendering ========== */
.file-content pre {
    margin: 0;
    padding: 20px 24px;
    font-family: var(--font-mono);
    font-size: 0.82rem;
    line-height: 1.65;
    color: var(--text-primary);
    overflow-x: auto;
    tab-size: 4;
}

.file-content .file-loading,
.file-content .file-error {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    min-height: 200px;
    color: var(--text-tertiary);
    font-size: 0.9rem;
}

.file-content .file-error {
    color: var(--danger);
}

.file-content .file-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    min-height: 200px;
    color: var(--text-tertiary);
    font-size: 0.9rem;
    flex-direction: column;
    gap: 8px;
}

/* ========== 6. Markdown Styling ========== */
.file-content .markdown-body {
    padding: 24px 28px;
    font-size: 0.9rem;
    line-height: 1.7;
    color: var(--text-primary);
}

.file-content .markdown-body h1 { font-size: 1.6rem; margin: 0 0 16px; font-weight: 700; padding-bottom: 8px; border-bottom: 1px solid var(--border); }
.file-content .markdown-body h2 { font-size: 1.3rem; margin: 24px 0 12px; font-weight: 600; }
.file-content .markdown-body h3 { font-size: 1.1rem; margin: 20px 0 10px; font-weight: 600; }
.file-content .markdown-body p { margin: 0 0 12px; }
.file-content .markdown-body ul,
.file-content .markdown-body ol { margin: 0 0 12px; padding-left: 24px; }
.file-content .markdown-body li { margin-bottom: 4px; }
.file-content .markdown-body ul li { list-style: disc; }
.file-content .markdown-body ol li { list-style: decimal; }
.file-content .markdown-body code {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    background: #F1F5F9;
    padding: 2px 6px;
    border-radius: 4px;
    color: #E11D48;
}
.file-content .markdown-body pre {
    background: #F8FAFC;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 16px 20px;
    margin: 0 0 16px;
    overflow-x: auto;
}
.file-content .markdown-body pre code {
    background: none;
    padding: 0;
    color: var(--text-primary);
}
.file-content .markdown-body blockquote {
    border-left: 4px solid var(--accent);
    padding: 8px 16px;
    margin: 0 0 16px;
    color: var(--text-secondary);
    background: #FAFBFC;
    border-radius: 0 8px 8px 0;
}
.file-content .markdown-body hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 20px 0;
}
.file-content .markdown-body strong {
    font-weight: 700;
}
.file-content .markdown-body a {
    color: var(--accent);
}
.file-content .markdown-body a:hover {
    text-decoration: underline;
}
.file-content .markdown-body img {
    max-width: 100%;
    border-radius: 8px;
    margin: 12px 0;
}

/* ========== 7. Repo Header Breadcrumb ========== */
.file-path .path-root {
    display: flex;
    align-items: center;
    gap: 4px;
    color: var(--accent);
    cursor: pointer;
}

.file-path .path-root:hover {
    text-decoration: underline;
}

/* ========== 8. Line Numbers ========== */
.file-content .code-block {
    display: flex;
    font-family: var(--font-mono);
    font-size: 0.82rem;
    line-height: 1.65;
}

.file-content .line-numbers {
    padding: 20px 0 20px 16px;
    text-align: right;
    color: var(--text-tertiary);
    user-select: none;
    border-right: 1px solid var(--border);
    min-width: 48px;
    flex-shrink: 0;
}

.file-content .line-numbers span {
    display: block;
    padding: 0 12px 0 0;
}

.file-content .code-lines {
    padding: 20px 24px;
    overflow-x: auto;
    flex: 1;
    white-space: pre;
    tab-size: 4;
}

/* ========== 9. Responsive ========== */
@media (max-width: 768px) {
    .github-content {
        grid-template-columns: 1fr;
        height: auto;
    }
    .github-file {
        max-height: 300px;
    }
    .github-fileRead {
        height: 60vh;
    }
}
