/* Health Heuristics - Styles */

:root {
    --primary: #1e40af;
    --primary-light: #3b82f6;
    --secondary: #64748b;
    --success: #16a34a;
    --danger: #dc2626;
    --warning: #d97706;
    --dark: #1e293b;
    --light: #f8fafc;
    --border: #e2e8f0;
    --text: #334155;
    --text-muted: #64748b;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--light);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

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

/* Header */
.header {
    background: white;
    border-bottom: 1px solid var(--border);
    padding: 12px 0;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: var(--dark);
}

.logo-icon {
    background: var(--primary);
    color: white;
    padding: 6px 10px;
    border-radius: 6px;
    font-weight: 700;
    font-size: 14px;
}

.logo-text {
    font-size: 18px;
    font-weight: 600;
}

.nav {
    display: flex;
    gap: 8px;
}

.nav-link {
    padding: 8px 16px;
    text-decoration: none;
    color: var(--text-muted);
    border-radius: 6px;
    font-weight: 500;
    transition: all 0.2s;
}

.nav-link:hover {
    background: var(--light);
    color: var(--text);
}

.nav-link.active {
    background: var(--primary);
    color: white;
}

/* Main */
.main {
    flex: 1;
    padding: 40px 0;
}

/* Search Section */
.search-section {
    text-align: center;
    margin-bottom: 40px;
}

.search-section h1 {
    font-size: 28px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--dark);
}

.subtitle {
    color: var(--text-muted);
    margin-bottom: 32px;
}

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

.search-input-wrapper {
    display: flex;
    gap: 12px;
    margin-bottom: 24px;
}

.search-input {
    flex: 1;
    padding: 14px 20px;
    font-size: 16px;
    border: 2px solid var(--border);
    border-radius: 8px;
    outline: none;
    transition: border-color 0.2s;
}

.search-input:focus {
    border-color: var(--primary-light);
}

.search-button {
    padding: 14px 32px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
}

.search-button:hover {
    background: var(--primary-light);
}

/* Filters */
.filters {
    display: flex;
    flex-wrap: wrap;
    gap: 24px;
    justify-content: center;
    text-align: left;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.filter-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.checkbox-group {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.checkbox-group-inline {
    flex-wrap: nowrap;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    font-size: 14px;
}

.checkbox-label input {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

.year-range {
    display: flex;
    align-items: center;
    gap: 8px;
}

.year-range input {
    width: 80px;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 14px;
}

.range-separator {
    color: var(--text-muted);
}

/* Results */
.results-section {
    margin-top: 40px;
}

.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}

.results-header h2 {
    font-size: 20px;
    font-weight: 600;
}

.results-count {
    color: var(--text-muted);
    font-size: 14px;
}

.results-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Article Card */
.article-card {
    background: white;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 20px;
    text-align: left;
}

.article-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 12px;
}

.article-title {
    font-size: 16px;
    font-weight: 600;
    line-height: 1.4;
}

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

.article-title a:hover {
    text-decoration: underline;
}

.article-badges {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

.badge {
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 500;
    text-transform: uppercase;
    white-space: nowrap;
}

.badge-fulltext {
    background: #dcfce7;
    color: #166534;
}

.badge-abstract {
    background: #fef3c7;
    color: #92400e;
}

.badge-source {
    background: #e0e7ff;
    color: #3730a3;
}

.article-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 12px;
}

.article-authors {
    font-style: italic;
}

.article-journal {
    font-weight: 500;
}

.article-snippet {
    font-size: 14px;
    line-height: 1.6;
    color: var(--text);
    margin-bottom: 12px;
}

.article-snippet mark {
    background: #fef08a;
    padding: 1px 3px;
    border-radius: 2px;
}

.article-footer {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    align-items: center;
    font-size: 12px;
    color: var(--text-muted);
    padding-top: 12px;
    border-top: 1px solid var(--border);
}

.article-link {
    color: var(--primary);
    text-decoration: none;
    margin-left: auto;
}

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

.article-link-disabled {
    color: var(--text-muted);
    margin-left: auto;
    font-style: italic;
}

/* Loading */
.loading {
    text-align: center;
    padding: 60px;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 16px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-inline {
    color: var(--text-muted);
    padding: 20px;
    text-align: center;
}

/* No Results / Error */
.no-results, .error {
    text-align: center;
    padding: 40px;
    color: var(--text-muted);
}

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

/* Statistics Page */
.stats-section h1 {
    font-size: 28px;
    font-weight: 600;
    margin-bottom: 8px;
    text-align: center;
}

.stats-section .subtitle {
    text-align: center;
    margin-bottom: 32px;
}

/* Stats Totals */
.stats-totals {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 40px;
}

.stat-card {
    background: white;
    border: 1px solid var(--border);
    border-left: 4px solid var(--primary);
    border-radius: 8px;
    padding: 20px;
}

.stat-card-total {
    border-left-color: var(--dark);
    background: var(--dark);
    color: white;
}

.stat-card-total .stat-source {
    color: white;
}

.stat-card-total .stat-breakdown {
    color: rgba(255,255,255,0.8);
}

.stat-card-header {
    margin-bottom: 8px;
}

.stat-source {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
}

.stat-total {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 12px;
}

.stat-breakdown {
    font-size: 13px;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    padding: 4px 0;
}

/* Stats Filters */
.stats-filters {
    background: white;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 24px;
    margin-bottom: 24px;
}

.stats-filters h2 {
    font-size: 18px;
    margin-bottom: 16px;
}

.filters-row {
    display: flex;
    flex-wrap: wrap;
    gap: 24px;
    align-items: flex-end;
}

.button {
    padding: 10px 20px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
}

.button-secondary {
    background: var(--secondary);
    color: white;
}

.button-secondary:hover {
    background: #475569;
}

/* Chart */
.chart-container {
    background: white;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 24px;
    margin-bottom: 32px;
    height: 400px;
}

/* Stats Table */
.stats-table-section {
    background: white;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 24px;
    margin-bottom: 32px;
}

.stats-table-section h2 {
    font-size: 18px;
    margin-bottom: 16px;
}

.table-wrapper {
    overflow-x: auto;
}

.stats-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.stats-table th,
.stats-table td {
    padding: 10px 12px;
    text-align: right;
    border-bottom: 1px solid var(--border);
}

.stats-table th {
    background: var(--light);
    font-weight: 600;
    text-align: right;
}

.stats-table th:first-child,
.stats-table td:first-child {
    text-align: left;
}

.year-cell {
    font-weight: 600;
}

.total-cell {
    font-weight: 600;
    background: #f1f5f9;
}

/* Content Types */
.content-types-section {
    background: white;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 24px;
}

.content-types-section h2 {
    font-size: 18px;
    margin-bottom: 20px;
}

.content-types-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
}

.content-type-card {
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: 6px;
}

.content-type-header {
    font-weight: 600;
    margin-bottom: 12px;
    font-size: 14px;
}

.content-type-bar {
    display: flex;
    height: 24px;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 8px;
}

.bar-segment {
    transition: width 0.3s;
}

.bar-fulltext {
    background: var(--success);
}

.bar-abstract {
    background: var(--warning);
}

.bar-title {
    background: var(--secondary);
}

.content-type-legend {
    display: flex;
    gap: 16px;
    font-size: 12px;
    color: var(--text-muted);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 4px;
}

.legend-color {
    width: 12px;
    height: 12px;
    border-radius: 2px;
}

.legend-fulltext {
    background: var(--success);
}

.legend-abstract {
    background: var(--warning);
}

.legend-title {
    background: var(--secondary);
}

/* Footer */
.footer {
    background: var(--dark);
    color: white;
    padding: 24px 0;
    text-align: center;
    margin-top: auto;
}

.footer p {
    margin-bottom: 4px;
}

.footer-note {
    font-size: 12px;
    color: rgba(255,255,255,0.6);
}

/* Responsive */
@media (max-width: 768px) {
    .header .container {
        flex-direction: column;
        gap: 12px;
    }
    
    .search-input-wrapper {
        flex-direction: column;
    }
    
    .filters {
        flex-direction: column;
        align-items: center;
    }
    
    .filters-row {
        flex-direction: column;
    }
    
    .article-header {
        flex-direction: column;
    }
    
    .stats-totals {
        grid-template-columns: 1fr;
    }
}
