/* MCP Web Viewer - Main Stylesheet */

/* --- 1. Base & Reset --- */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f5f5f5;
    height: 100vh;
}

/* --- 2. Layout Structure --- */
.container {
    max-width: 100%;
    margin: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

header {
    background-color: #2c3e50;
    color: white;
    padding: 0.8rem 1.5rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    z-index: 10;
}

header h1 {
    font-size: 1.25rem;
    font-weight: 600;
}

.main-layout {
    display: flex;
    flex: 1;
    overflow: hidden; /* Prevent body scroll, use pane scroll */
}

/* --- 3. Sidebar & Navigation --- */
.sidebar {
    width: 320px;
    background-color: white;
    border-right: 1px solid #ddd;
    overflow-y: auto;
    padding: 1.2rem;
}

.sidebar h2 {
    font-size: 1.1rem;
    margin-bottom: 1.2rem;
    color: #2c3e50;
    border-bottom: 1px solid #eee;
    padding-bottom: 0.5rem;
}

.tree {
    font-size: 0.9rem;
}

.tree-node {
    margin: 0.2rem 0;
}

details > summary {
    cursor: pointer;
    user-select: none;
    list-style: none;
    padding: 0.3rem 0.5rem;
    border-radius: 4px;
    transition: background-color 0.2s;
}

details > summary::-webkit-details-marker {
    display: none;
}

details > summary:hover {
    background-color: #f0f0f0;
}

.tree-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.tree-children {
    margin-left: 0.8rem;
    padding-left: 0.6rem;
    border-left: 1px solid #e0e0e0;
}

.tree-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.25rem 0.5rem;
    color: #3498db;
    text-decoration: none;
    border-radius: 4px;
}

.tree-link:hover {
    background-color: #e3f2fd;
    text-decoration: underline;
}

.domain-node > summary {
    font-weight: 600;
    color: #2c3e50;
    font-size: 0.95rem;
}

/* --- 4. Content Pane --- */
.content-pane {
    flex: 1;
    overflow-y: auto;
    background-color: white;
    padding: 2.5rem;
}

.content-header {
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #eee;
}

.content-header h2 {
    font-size: 1.2rem;
    color: #7f8c8d;
    font-weight: 400;
    font-family: monospace;
}

.content-body {
    max-width: 1400px;
    margin: 0;
}

@media (min-width: 2000px) {
    .content-body {
        max-width: 1600px;
    }
}

@media (min-width: 2500px) {
    .content-body {
        max-width: 1900px;
    }
}

.content-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #aaa;
    font-style: italic;
}

/* --- 5. Article & Markdown Content --- */
article {
    margin-bottom: 4rem;
    padding-bottom: 2rem;
    border-bottom: 1px solid #f0f0f0;
}

article:last-child {
    border-bottom: none;
}

article h1 {
    font-size: 2.2rem;
    color: #2c3e50;
    margin-bottom: 1.5rem;
    line-height: 1.2;
}

article h2 {
    font-size: 1.6rem;
    color: #34495e;
    margin: 2rem 0 1rem;
    border-bottom: 1px solid #eee;
    padding-bottom: 0.3rem;
}

article h3 {
    font-size: 1.3rem;
    color: #34495e;
    margin: 1.5rem 0 0.75rem;
}

article p {
    margin-bottom: 1.2rem;
    line-height: 1.7;
}

article ul, article ol {
    margin-bottom: 1.2rem;
    margin-left: 2rem;
}

article li {
    margin-bottom: 0.5rem;
}

/* --- 6. Tables (General & Canon) --- */
.content-body table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.5rem 0;
    border: 1px solid rgba(0, 0, 0, 0.15);
}

.content-body th,
.content-body td {
    padding: 0.35rem 0.9rem;
    text-align: left;
    vertical-align: top;
    border: 1px solid rgba(0, 0, 0, 0.15);
    overflow-wrap: break-word;
}

.content-body th {
    background-color: #f8f9fa;
    font-weight: 600;
    color: #2c3e50;
}

/* Canon-specific table refinements */
.canon-table thead {
    background-color: #f1f3f5;
}

.canon-table th.key-column {
    width: 200px;
}

/* Nested Tables */
.canon-table .canon-table {
    margin: 0.5rem 0;
    border: 1px solid rgba(0, 0, 0, 0.08);
}

.canon-table .canon-table thead {
    display: none; /* Hide headers in nested tables for cleaner look */
}

.canon-table .canon-table th.key-column {
    background-color: #fafafa;
    font-size: 0.85em;
    width: 150px;
}

/* --- 7. Components (Lists, Images, TOC, Code) --- */

/* Canon Lists */
.canon-list {
    margin: 0;
    padding-left: 1.2rem;
    list-style-type: circle;
}

.canon-list li {
    margin-bottom: 0.3rem;
}

/* Depiction (Images) */
.depiction {
    margin: 1rem 0;
}

.depiction img {
    max-width: 100%;
    height: auto;
    border: 1px solid #ddd;
    border-radius: 4px;
    display: block;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

/* Table of Contents */
.toc {
    background-color: #f8f9fa;
    padding: 1.5rem;
    border: 1px solid #e9ecef;
    border-radius: 6px;
    margin-bottom: 3rem;
}

.toc h3 {
    margin-top: 0;
    margin-bottom: 1rem;
    font-size: 1.1rem;
    color: #2c3e50;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.toc h4 {
    font-size: 0.95rem;
    color: #666;
    margin: 1rem 0 0.5rem;
}

.toc ul {
    margin-bottom: 0;
    list-style-type: none;
    padding-left: 0;
}

.toc li {
    margin-bottom: 0.4rem;
}

.toc a {
    color: #3498db;
    text-decoration: none;
    font-size: 0.95rem;
}

.toc a:hover {
    text-decoration: underline;
}

/* Code Styles */
article code {
    background-color: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 3px;
    padding: 0.2rem 0.4rem;
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
    font-size: 0.85em;
    color: #e83e8c;
}

article pre {
    background-color: #2c3e50;
    color: #ecf0f1;
    border-radius: 6px;
    padding: 1.2rem;
    overflow-x: auto;
    margin-bottom: 1.5rem;
    border: none;
}

article pre code {
    background: none;
    border: none;
    padding: 0;
    color: inherit;
    font-size: 0.9rem;
}

code.null { color: #aaa; font-style: italic; }
code.bool { color: #d35400; font-weight: 600; }
code.number { color: #27ae60; }

/* Status Messages */
.error, .info {
    padding: 0.8rem 1.2rem;
    border-radius: 4px;
    margin-bottom: 1.5rem;
    font-size: 0.9rem;
}

.error {
    color: #721c24;
    background-color: #f8d7da;
    border-left: 4px solid #f5c6cb;
}

.info {
    color: #0c5460;
    background-color: #d1ecf1;
    border-left: 4px solid #bee5eb;
}

/* --- 8. Responsive & Wide Screen Adjustments --- */
@media (min-width: 1600px) {
    .sidebar {
        width: 400px;
    }
}

@media (max-width: 900px) {
    .main-layout {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100%;
        height: 250px;
        border-right: none;
        border-bottom: 1px solid #ddd;
    }
    
    .content-pane {
        padding: 1.5rem;
    }
    
    article h1 {
        font-size: 1.7rem;
    }
}
