:root {
    --color-bg: #0a0a0b;
    --color-surface: #141416;
    --color-surface-2: #1c1c1f;
    --color-border: #2a2a2e;
    --color-text: #e4e4e7;
    --color-text-muted: #71717a;
    --color-primary: #3b82f6;
    --color-primary-hover: #2563eb;
    --color-accent: #f59e0b;
    --color-success: #22c55e;
    --color-error: #ef4444;
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
    --radius: 8px;
    --radius-lg: 12px;
}

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

html, body {
    height: 100%;
}

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

a {
    color: var(--color-primary);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* Container */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

/* Navbar */
.navbar {
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    padding: 1rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-brand a {
    font-weight: 700;
    font-size: 1.25rem;
    color: var(--color-text);
}

.nav-brand a:hover {
    text-decoration: none;
    color: var(--color-primary);
}

.nav-links {
    display: flex;
    gap: 1.5rem;
    align-items: center;
}

.nav-links a {
    color: var(--color-text-muted);
    font-weight: 500;
    transition: color 0.2s;
}

.nav-links a:hover,
.nav-links a.active {
    color: var(--color-text);
    text-decoration: none;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    font-weight: 500;
    font-size: 0.875rem;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
    text-decoration: none;
}

.btn:hover {
    text-decoration: none;
}

.btn-primary {
    background: var(--color-primary);
    color: white;
}

.btn-primary:hover {
    background: var(--color-primary-hover);
}

.btn-secondary {
    background: var(--color-surface-2);
    color: var(--color-text);
    border: 1px solid var(--color-border);
}

.btn-secondary:hover {
    background: var(--color-border);
}

.btn-large {
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
}

.btn-block {
    width: 100%;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Hero Section */
.hero {
    text-align: center;
    padding: 4rem 0 3rem;
}

.hero h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 1rem;
}

.hero-subtitle {
    font-size: 1.25rem;
    color: var(--color-text-muted);
    margin-bottom: 2rem;
}

/* Search Form */
.search-form-hero {
    max-width: 700px;
    margin: 0 auto;
}

.search-input-wrapper {
    display: flex;
    gap: 0.75rem;
}

.search-input,
.search-input-large {
    flex: 1;
    padding: 0.75rem 1rem;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    color: var(--color-text);
    font-size: 1rem;
    font-family: inherit;
}

.search-input-large {
    padding: 1rem 1.25rem;
    font-size: 1.125rem;
}

.search-input:focus,
.search-input-large:focus {
    outline: none;
    border-color: var(--color-primary);
}

.quick-searches {
    margin-top: 1.5rem;
    color: var(--color-text-muted);
    font-size: 0.875rem;
}

.quick-searches a {
    margin-left: 0.5rem;
    color: var(--color-primary);
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
    padding: 2rem 0;
}

.stat-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    text-align: center;
}

.stat-number {
    font-size: 2rem;
    font-weight: 700;
    color: var(--color-primary);
}

.stat-label {
    color: var(--color-text-muted);
    margin-top: 0.25rem;
}

/* Dataset Grid */
.datasets-section {
    padding: 2rem 0;
}

.datasets-section h2 {
    margin-bottom: 1.5rem;
}

.dataset-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 1rem;
}

.dataset-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 1.25rem;
    transition: all 0.2s;
    display: block;
    color: var(--color-text);
}

.dataset-card:hover {
    border-color: var(--color-primary);
    text-decoration: none;
}

.dataset-name {
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.dataset-count {
    color: var(--color-text-muted);
    font-size: 0.875rem;
}

/* Search Results */
.search-results {
    padding: 2rem 0;
}

.search-header {
    margin-bottom: 1.5rem;
}

.search-form {
    display: flex;
    gap: 0.75rem;
}

.results-info {
    color: var(--color-text-muted);
    margin-bottom: 1.5rem;
}

.results-layout {
    display: grid;
    grid-template-columns: 250px 1fr;
    gap: 2rem;
}

/* Filters Sidebar */
.filters-sidebar {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    height: fit-content;
    position: sticky;
    top: 80px;
}

.filters-sidebar h3 {
    margin-bottom: 1rem;
}

.filter-group {
    margin-bottom: 1.5rem;
}

.filter-group h4 {
    font-size: 0.875rem;
    color: var(--color-text-muted);
    margin-bottom: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.filter-option {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.25rem 0;
    cursor: pointer;
    font-size: 0.875rem;
}

.filter-option input {
    accent-color: var(--color-primary);
}

/* Results List */
.results-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.result-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 1.25rem;
    transition: border-color 0.2s;
}

.result-card:hover {
    border-color: var(--color-primary);
}

.result-title {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.result-title a {
    color: var(--color-text);
}

.result-title a:hover {
    color: var(--color-primary);
}

.result-meta {
    display: flex;
    gap: 1rem;
    font-size: 0.8125rem;
    color: var(--color-text-muted);
    margin-bottom: 0.75rem;
}

.result-meta span {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.meta-dataset {
    color: var(--color-accent);
}

.result-snippet {
    color: var(--color-text-muted);
    font-size: 0.875rem;
    line-height: 1.5;
}

.result-snippet mark {
    background: rgba(59, 130, 246, 0.3);
    color: var(--color-text);
    padding: 0.1em 0.2em;
    border-radius: 2px;
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--color-border);
}

.page-info {
    color: var(--color-text-muted);
}

/* No Results */
.no-results {
    text-align: center;
    padding: 3rem;
    color: var(--color-text-muted);
}

/* Document Viewer */
.doc-viewer {
    padding: 2rem 0;
}

.doc-header {
    margin-bottom: 2rem;
}

.doc-breadcrumb {
    font-size: 0.875rem;
    color: var(--color-text-muted);
    margin-bottom: 1rem;
}

.doc-breadcrumb a {
    color: var(--color-text-muted);
}

.doc-breadcrumb a:hover {
    color: var(--color-primary);
}

.doc-title {
    font-size: 1.75rem;
    margin-bottom: 1rem;
}

.doc-meta-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.meta-item {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.meta-label {
    font-size: 0.75rem;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.meta-value {
    font-weight: 500;
}

.doc-actions {
    display: flex;
    gap: 0.75rem;
}

.doc-layout {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 2rem;
}

.doc-content {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 2rem;
}

.doc-text {
    font-family: var(--font-mono);
    font-size: 0.875rem;
    line-height: 1.8;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.doc-no-text {
    text-align: center;
    color: var(--color-text-muted);
    padding: 2rem;
}

.doc-sidebar {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.sidebar-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
}

.sidebar-card h3 {
    font-size: 0.875rem;
    margin-bottom: 1rem;
}

.sidebar-card textarea {
    width: 100%;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 0.75rem;
    color: var(--color-text);
    font-family: inherit;
    resize: vertical;
    margin-bottom: 0.75rem;
}

.related-list {
    list-style: none;
}

.related-list li {
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--color-border);
}

.related-list li:last-child {
    border-bottom: none;
}

.related-list a {
    font-size: 0.875rem;
}

.info-list {
    font-size: 0.875rem;
}

.info-list dt {
    color: var(--color-text-muted);
    margin-top: 0.75rem;
}

.info-list dt:first-child {
    margin-top: 0;
}

.info-list dd {
    margin-top: 0.25rem;
}

.mono {
    font-family: var(--font-mono);
    font-size: 0.8125rem;
    word-break: break-all;
}

/* Chat Interface */
.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    max-width: 900px;
    padding-bottom: 0;
}

.chat-header {
    padding: 1.5rem 0;
    border-bottom: 1px solid var(--color-border);
}

.chat-header h1 {
    margin-bottom: 0.5rem;
}

.chat-header p {
    color: var(--color-text-muted);
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem 0;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.message {
    display: flex;
    gap: 1rem;
}

.message.user {
    justify-content: flex-end;
}

.message-content {
    max-width: 80%;
    padding: 1rem 1.25rem;
    border-radius: var(--radius-lg);
}

.message.user .message-content {
    background: var(--color-primary);
    color: white;
    border-bottom-right-radius: 4px;
}

.message.assistant .message-content {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-bottom-left-radius: 4px;
}

.message-content p {
    margin-bottom: 0.75rem;
}

.message-content p:last-child {
    margin-bottom: 0;
}

.message-content ul {
    margin: 0.5rem 0;
    padding-left: 1.5rem;
}

.message-content li {
    margin-bottom: 0.25rem;
}

.message-content .answer {
    margin-bottom: 1rem;
}

.message-content .sources {
    font-size: 0.875rem;
    padding-top: 1rem;
    border-top: 1px solid var(--color-border);
}

.message-content .sources ul {
    margin-top: 0.5rem;
}

.source-dataset {
    color: var(--color-text-muted);
}

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

.chat-input-container {
    padding: 1.5rem 0;
    border-top: 1px solid var(--color-border);
    background: var(--color-bg);
}

.chat-form {
    display: flex;
    gap: 0.75rem;
}

.chat-form textarea {
    flex: 1;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 0.75rem 1rem;
    color: var(--color-text);
    font-family: inherit;
    font-size: 1rem;
    resize: none;
}

.chat-form textarea:focus {
    outline: none;
    border-color: var(--color-primary);
}

/* Alert */
.alert {
    padding: 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
}

.alert-error {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid var(--color-error);
    color: var(--color-error);
}

/* Error Page */
.error-page {
    text-align: center;
    padding: 4rem;
}

.error-page h1 {
    margin-bottom: 1rem;
}

.error-page p {
    color: var(--color-text-muted);
    margin-bottom: 2rem;
}

/* Footer */
.footer {
    margin-top: auto;
    padding: 2rem 0;
    border-top: 1px solid var(--color-border);
    text-align: center;
    color: var(--color-text-muted);
    font-size: 0.875rem;
}

.footer-links a {
    color: var(--color-text-muted);
}

.footer-links a:hover {
    color: var(--color-primary);
}

/* Responsive */
@media (max-width: 768px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .results-layout {
        grid-template-columns: 1fr;
    }
    
    .filters-sidebar {
        position: static;
    }
    
    .doc-layout {
        grid-template-columns: 1fr;
    }
    
    .nav-links {
        gap: 1rem;
    }
    
    .hero h1 {
        font-size: 1.75rem;
    }
}

/* YouTube Results */
.result-youtube .result-title a {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.youtube-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    background: #ff0000;
    color: white;
    border-radius: 4px;
    font-size: 12px;
    flex-shrink: 0;
}

.meta-channel {
    background: var(--color-bg-tertiary);
    color: var(--color-text-muted);
    padding: 0.125rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
}

.meta-link {
    color: var(--color-primary);
    font-size: 0.75rem;
    text-decoration: none;
}

.meta-link:hover {
    text-decoration: underline;
}

.result-youtube {
    border-left: 3px solid #ff0000;
}
