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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-color: #f8fafc;
    color: #1e293b;
    line-height: 1.6;
}

.container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

header {
    background: white;
    border-bottom: 1px solid #e2e8f0;
    padding: 1rem 2rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

header h1 {
    font-size: 1.5rem;
    margin-bottom: 1rem;
    color: #0f172a;
}

.controls {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    align-items: center;
}

.controls button, .controls select, .controls input {
    padding: 0.5rem 1rem;
    border: 1px solid #d1d5db;
    border-radius: 0.375rem;
    font-size: 0.875rem;
    background: white;
}

.controls button {
    background: #3b82f6;
    color: white;
    border: none;
    cursor: pointer;
    transition: background-color 0.2s;
}

.controls button:hover:not(:disabled) {
    background: #2563eb;
}

.controls button:disabled {
    background: #9ca3af;
    cursor: not-allowed;
}

.main-content {
    display: flex;
    flex: 1;
    height: calc(100vh - 140px);
}

.sidebar {
    width: 300px;
    background: white;
    border-right: 1px solid #e2e8f0;
    overflow-y: auto;
    padding: 1rem;
}

.sidebar h3 {
    margin-bottom: 1rem;
    color: #374151;
    font-size: 1rem;
}

.content {
    flex: 1;
    padding: 2rem;
    overflow-y: auto;
    background: white;
}

#welcome-message {
    text-align: center;
    padding: 3rem 2rem;
    color: #6b7280;
}

#welcome-message h2 {
    color: #1f2937;
    margin-bottom: 1rem;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
    margin-top: 2rem;
}

.stat-item {
    background: #f9fafb;
    padding: 1.5rem;
    border-radius: 0.5rem;
    text-align: center;
    border: 1px solid #e5e7eb;
}

.stat-number {
    font-size: 2rem;
    font-weight: bold;
    color: #3b82f6;
}

.stat-label {
    font-size: 0.875rem;
    color: #6b7280;
    margin-top: 0.5rem;
}

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

.file-header h2 {
    color: #1f2937;
    margin-bottom: 0.5rem;
}

.file-meta {
    display: flex;
    gap: 1rem;
    font-size: 0.875rem;
    color: #6b7280;
}

#markdown-content {
    max-width: none;
}

/* Tree Navigation Styles */
.tree-node {
    margin-bottom: 0.25rem;
}

.folder-header {
    padding: 0.5rem;
    cursor: pointer;
    border-radius: 0.25rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: background-color 0.2s;
}

.folder-header:hover {
    background: #f3f4f6;
}

.folder-icon, .file-icon {
    font-size: 0.875rem;
}

.folder-content {
    display: none;
    margin-left: 1rem;
    border-left: 1px solid #e5e7eb;
    padding-left: 0.5rem;
}

.tree-node.expanded .folder-content {
    display: block;
}

.files-container {
    margin-bottom: 0.5rem;
}

.subfolders-container {
    margin-top: 0.25rem;
}

/* Nested folder indentation */
.level-0 { margin-left: 0; }
.level-1 { margin-left: 0.5rem; }
.level-2 { margin-left: 1rem; }
.level-3 { margin-left: 1.5rem; }
.level-4 { margin-left: 2rem; }

.file-item {
    padding: 0.375rem 0.5rem;
    cursor: pointer;
    border-radius: 0.25rem;
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0.125rem 0;
    transition: all 0.2s ease;
}

.file-item:hover {
    background: #f3f4f6;
}

.file-item.active {
    background: #dbeafe;
    color: #1d4ed8;
    font-weight: 500;
}

/* Read/Unread status styling */
.file-item.read {
    opacity: 0.7;
}

.file-item.read .file-content {
    color: #6b7280;
}

.file-item.unread {
    opacity: 1;
    font-weight: 500;
}

.file-item.unread .file-content {
    color: #1f2937;
}

/* Read toggle button */
.read-toggle {
    background: none;
    border: 1px solid #d1d5db;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 0.75rem;
    line-height: 1;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.read-toggle:hover {
    background: #f3f4f6;
    border-color: #9ca3af;
}

.read-toggle.read {
    background: #10b981;
    border-color: #10b981;
    color: white;
}

.read-toggle.unread {
    background: white;
    color: #9ca3af;
}

.file-content {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Markdown Content Styles */
#markdown-content h1, #markdown-content h2, #markdown-content h3 {
    margin-top: 2rem;
    margin-bottom: 1rem;
    color: #1f2937;
}

#markdown-content h1 {
    font-size: 1.875rem;
    border-bottom: 2px solid #e5e7eb;
    padding-bottom: 0.5rem;
}

#markdown-content h2 {
    font-size: 1.5rem;
}

#markdown-content h3 {
    font-size: 1.25rem;
}

#markdown-content p {
    margin-bottom: 1rem;
}

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

#markdown-content li {
    margin-bottom: 0.5rem;
}

#markdown-content blockquote {
    border-left: 4px solid #3b82f6;
    padding-left: 1rem;
    margin: 1rem 0;
    color: #4b5563;
    font-style: italic;
}

#markdown-content code {
    background: #f1f5f9;
    padding: 0.125rem 0.25rem;
    border-radius: 0.25rem;
    font-size: 0.875rem;
    font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;
}

#markdown-content pre {
    background: #1e293b;
    padding: 1rem;
    border-radius: 0.5rem;
    overflow-x: auto;
    margin: 1rem 0;
}

#markdown-content pre code {
    background: none;
    padding: 0;
    color: #e2e8f0;
}

#markdown-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 1rem 0;
}

#markdown-content th, #markdown-content td {
    border: 1px solid #e5e7eb;
    padding: 0.75rem;
    text-align: left;
}

#markdown-content th {
    background: #f9fafb;
    font-weight: 600;
}

#markdown-content a {
    color: #3b82f6;
    text-decoration: none;
}

#markdown-content a:hover {
    text-decoration: underline;
}

.error {
    background: #fee2e2;
    color: #dc2626;
    padding: 1rem;
    border-radius: 0.5rem;
    border: 1px solid #fecaca;
}

/* Responsive Design */
@media (max-width: 768px) {
    .main-content {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100%;
        max-height: 300px;
        border-right: none;
        border-bottom: 1px solid #e2e8f0;
    }
    
    .content {
        padding: 1rem;
    }
    
    header {
        padding: 1rem;
    }
    
    .controls {
        flex-direction: column;
        align-items: stretch;
    }
    
    .controls > * {
        width: 100%;
    }
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f5f9;
}

::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}