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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica', 'Arial', sans-serif;
    background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
    color: #2d3748;
    min-height: 100vh;
    line-height: 1.6;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

/* Header */
.header {
    text-align: center;
    margin-bottom: 3rem;
}

.main-title {
    font-size: 2.5rem;
    font-weight: 700;
    background: linear-gradient(90deg, #4299e1, #667eea);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 0.5rem;
}

.subtitle {
    color: #718096;
    font-size: 1.1rem;
}

/* Search Section */
.search-section {
    background: #ffffff;
    padding: 2rem;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    margin-bottom: 2rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.search-box {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.search-input {
    flex: 1;
    padding: 0.75rem 1rem;
    background: #f7fafc;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    color: #2d3748;
    font-size: 1rem;
    transition: border-color 0.3s, background 0.3s;
}

.search-input:focus {
    outline: none;
    border-color: #4299e1;
    background: #ffffff;
}

.search-button {
    padding: 0.75rem 2rem;
    background: linear-gradient(90deg, #4299e1, #667eea);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.search-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(66, 153, 225, 0.3);
}

.search-button:active {
    transform: translateY(0);
}

.search-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* Filters */
.filters-container {
    display: flex;
    gap: 1rem;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.filter-label {
    color: #4a5568;
    cursor: pointer;
}

.filter-select, .filter-input {
    padding: 0.5rem;
    background: #f7fafc;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    color: #2d3748;
    font-size: 0.9rem;
}

.filter-select:focus, .filter-input:focus {
    outline: none;
    border-color: #4299e1;
}

.filter-input.small {
    width: 80px;
}

.toggle-filters-btn {
    padding: 0.5rem 1rem;
    background: #edf2f7;
    color: #4a5568;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.toggle-filters-btn:hover {
    background: #4299e1;
    color: white;
    border-color: #4299e1;
}

.advanced-filters {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid #e2e8f0;
}

.advanced-filters.hidden {
    display: none;
}

.filter-row {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

/* Loading Spinner */
.loading-spinner {
    text-align: center;
    padding: 3rem;
}

.loading-spinner.hidden {
    display: none;
}

.spinner {
    border: 4px solid #e2e8f0;
    border-top: 4px solid #4299e1;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Metrics */
.metrics-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.metric-card {
    background: #ffffff;
    padding: 1.5rem;
    border-radius: 10px;
    border: 1px solid #e2e8f0;
    text-align: center;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.metric-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(66, 153, 225, 0.15);
}

.metric-number {
    font-size: 2.5rem;
    font-weight: 700;
    color: #4299e1;
    margin-bottom: 0.5rem;
}

.metric-label {
    color: #718096;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* Tabs */
.tabs-container {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    border-bottom: 2px solid #e2e8f0;
}

.tab-button {
    padding: 1rem 2rem;
    background: transparent;
    color: #718096;
    border: none;
    border-bottom: 3px solid transparent;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.tab-button:hover {
    color: #4a5568;
}

.tab-button.active {
    color: #4299e1;
    border-bottom-color: #4299e1;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* Answer Section */
.answer-section {
    background: #ffffff;
    padding: 2rem;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    margin-top: 1rem;
    line-height: 1.8;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.answer-section h1, .answer-section h2, .answer-section h3 {
    color: #2d3748;
    margin-top: 1.5rem;
    margin-bottom: 0.75rem;
    font-weight: 600;
}

.answer-section h1 { color: #4299e1; }
.answer-section h2 { color: #667eea; }

.answer-section p {
    margin-bottom: 1rem;
    color: #4a5568;
}

.answer-section img {
    max-width: 100%;
    border-radius: 8px;
    margin: 1.5rem 0;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.answer-section ul, .answer-section ol {
    margin-left: 2rem;
    margin-bottom: 1rem;
    color: #4a5568;
}

.answer-section code {
    background: #f7fafc;
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    color: #667eea;
    border: 1px solid #e2e8f0;
}

/* Raw Chunks View */
.chunks-info {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.info-badge {
    background: #f7fafc;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    color: #4a5568;
}

.chunks-description {
    color: #718096;
    font-size: 0.9rem;
    margin-bottom: 1.5rem;
    font-style: italic;
}

.section-header {
    color: #4299e1;
    font-size: 1.8rem;
    font-weight: 600;
    margin-top: 2rem;
    margin-bottom: 0.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid #e2e8f0;
}

.chunk-badge {
    display: inline-block;
    background: linear-gradient(90deg, #4299e1, #667eea);
    color: white;
    padding: 0.3rem 0.8rem;
    border-radius: 5px;
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    margin-top: 1rem;
}

.chunk-container {
    background: #f7fafc;
    padding: 1.5rem;
    border-radius: 10px;
    margin: 1rem 0;
    border-left: 4px solid #4299e1;
    white-space: pre-wrap;
    line-height: 1.6;
    color: #4a5568;
}

.chunk-image {
    max-width: 100%;
    border-radius: 8px;
    margin: 1rem 0;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    border: 1px solid #e2e8f0;
}

.image-description {
    color: #718096;
    font-size: 0.9rem;
    font-style: italic;
    margin-top: 0.5rem;
}

/* Sources Section */
.sources-section {
    margin-top: 2rem;
    border-top: 2px solid #e2e8f0;
    padding-top: 1.5rem;
}

.section-toggle {
    width: 100%;
    padding: 1rem;
    background: #ffffff;
    color: #4a5568;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    text-align: left;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.section-toggle:hover {
    background: #f7fafc;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.sources-container {
    margin-top: 1rem;
}

.sources-container.hidden {
    display: none;
}

.source-card {
    background: #f7fafc;
    padding: 1rem;
    border-radius: 8px;
    border-left: 3px solid #4299e1;
    margin: 0.75rem 0;
}

.source-header {
    font-weight: 600;
    color: #2d3748;
    margin-bottom: 0.5rem;
}

.source-details {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    color: #4a5568;
}

.source-content {
    color: #718096;
    font-size: 0.9rem;
    margin-top: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px solid #e2e8f0;
}

/* Results Section */
.results-section {
    margin-top: 2rem;
}

.results-section.hidden {
    display: none;
}

/* Error Message */
.error-message {
    background: #fff5f5;
    color: #c53030;
    padding: 1.5rem;
    border-radius: 8px;
    margin-top: 1rem;
    border: 1px solid #feb2b2;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.error-message.hidden {
    display: none;
}

.hidden {
    display: none !important;
}

/* Footer */
.footer {
    text-align: center;
    padding: 2rem;
    margin-top: 3rem;
    color: #a0aec0;
    border-top: 1px solid #e2e8f0;
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 1rem;
    }

    .main-title {
        font-size: 2rem;
    }

    .search-box {
        flex-direction: column;
    }

    .search-button {
        width: 100%;
    }

    .metrics-container {
        grid-template-columns: 1fr;
    }

    .filter-row {
        flex-direction: column;
    }
}

