/* Blog-inspired minimal academic styling */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
    font-size: 16px;
    line-height: 1.6;
    color: #2d3748;
    background: #ffffff;
    padding: 20px;
}

p {
    margin-bottom: 1.5rem;
    line-height: 1.6;
}

h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    line-height: 1.3;
    color: #1a202c;
}

h2 {
    font-size: 1.75rem;
    margin: 2rem 0 1rem;
}

h3 {
    font-size: 1.5rem;
    margin: 2rem 0 1rem;
}

ul, ol {
    margin-bottom: 1.5rem;
    line-height: 1.6;
}

li {
    margin: 1.2rem 0;
    line-height: 1.6;
}

li li {
    margin: 0.6rem 0;
}

a {
    color: #2b6cb0;
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: border-color 0.2s;
}

a:hover {
    border-bottom-color: currentColor;
}

.container {
    max-width: 900px;
    margin: 0 auto;
    background: white;
}

header {
    padding: 40px 20px;
    text-align: center;
    border-bottom: 1px solid #ddd;
}

header h1 {
    font-size: 2rem;
    font-weight: 600;
    margin-bottom: 10px;
    color: #333;
}

.subtitle {
    font-size: 1rem;
    color: #777;
}

/* Navigation */
.nav-buttons {
    display: flex;
    gap: 10px;
    padding: 15px 20px;
    background: #f8f8f8;
    border-bottom: 1px solid #ddd;
}

.nav-button {
    padding: 8px 16px;
    background: white;
    border: 1px solid #ddd;
    color: #333;
    text-decoration: none;
    font-weight: 500;
    transition: all 0.2s;
    font-size: 14px;
}

.nav-button:hover {
    background: #f8f8f8;
}

.nav-button.active {
    background: #f8f8f8;
    font-weight: 600;
}

/* Search Section */
.search-section {
    padding: 30px 20px;
    background: white;
}

.search-box {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

#searchInput {
    flex: 1;
    padding: 10px 15px;
    font-size: 14px;
    font-family: inherit;
    border: 1px solid #ddd;
    outline: none;
}

#searchInput:focus {
    border-color: #777;
}

#searchButton {
    padding: 10px 30px;
    font-size: 14px;
    font-weight: 500;
    font-family: inherit;
    color: #333;
    background: #f8f8f8;
    border: 1px solid #ddd;
    cursor: pointer;
    transition: background 0.2s;
}

#searchButton:hover {
    background: #e8e8e8;
}

#searchButton:active {
    background: #ddd;
}

/* Filters */
.filters {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    padding: 20px;
    background: #f8f8f8;
    margin-bottom: 10px;
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.filter-group label {
    font-weight: 500;
    color: #777;
    font-size: 14px;
}

.filter-group select,
.filter-group input[type="number"] {
    padding: 6px 10px;
    border: 1px solid #ddd;
    font-size: 14px;
    font-family: inherit;
    outline: none;
}

.filter-group select:focus,
.filter-group input[type="number"]:focus {
    border-color: #777;
}

.filter-group input[type="number"] {
    width: 80px;
}

.filter-group.checkbox label {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
}

/* Journal filter */
.filter-group.journal-filter,
.filter-group.jel-filter {
    flex-direction: column;
    align-items: flex-start;
    width: 100%;
    padding: 15px;
    background: white;
}

.journal-filter-controls,
.jel-filter-controls {
    display: flex;
    gap: 8px;
    margin-bottom: 10px;
}

.filter-control-btn {
    padding: 5px 12px;
    font-size: 14px;
    font-weight: 500;
    font-family: inherit;
    color: #333;
    background: #f8f8f8;
    border: 1px solid #ddd;
    cursor: pointer;
    transition: background 0.2s;
}

.filter-control-btn:hover {
    background: #e8e8e8;
}

.journal-checkboxes {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 8px;
    max-height: 300px;
    overflow-y: auto;
    width: 100%;
    padding: 10px;
    background: #f8f8f8;
    border: 1px solid #ddd;
}

.journal-checkbox-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 8px;
    cursor: pointer;
}

.journal-checkbox-item:hover {
    background: white;
}

.journal-checkbox-item input[type="checkbox"] {
    cursor: pointer;
}

.journal-checkbox-item label {
    cursor: pointer;
    flex: 1;
    font-size: 14px;
    color: #333;
}

/* JEL Category Checkboxes */
.jel-checkboxes {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 8px;
    max-height: 200px;
    overflow-y: auto;
    width: 100%;
    padding: 10px;
    background: #f8f8f8;
    border: 1px solid #ddd;
}

.jel-checkbox-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 8px;
    cursor: pointer;
}

.jel-checkbox-item:hover {
    background: white;
}

.jel-checkbox-item input[type="checkbox"] {
    cursor: pointer;
}

.jel-checkbox-item label {
    cursor: pointer;
    flex: 1;
    font-size: 13px;
    color: #333;
}

.jel-count {
    font-size: 12px;
    color: #777;
    font-weight: normal;
}

/* Query syntax - accordion style */
.query-syntax {
    margin-top: 15px;
}

.query-syntax details {
    background: #f8f8f8;
    padding: 0;
    border: 1px solid #ddd;
}

.query-syntax summary {
    cursor: pointer;
    font-weight: 500;
    color: #333;
    user-select: none;
    padding: 10px 15px;
    transition: 0.4s;
}

.query-syntax summary::before {
    content: "[+] ";
    color: #777;
    font-size: 90%;
    margin-right: 3px;
}

.query-syntax details[open] summary::before {
    content: "[−] ";
}

.query-syntax summary:hover {
    background: #e8e8e8;
}

.query-syntax ul {
    list-style: none;
    padding: 0 20px 15px 20px;
    margin-top: 5px;
    background: white;
}

.query-syntax li {
    padding: 8px 0;
    border-bottom: 1px solid #f0f0f0;
}

.query-syntax li:last-child {
    border-bottom: none;
}

.query-syntax code {
    background: #f8f8f8;
    padding: 2px 6px;
    font-family: 'Courier New', monospace;
    color: #333;
}

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

.spinner {
    width: 50px;
    height: 50px;
    margin: 0 auto 20px;
    border: 4px solid #f0f0f0;
    border-top: 4px solid #777;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Results Section */
.results-section {
    padding: 30px 20px;
    min-height: 200px;
}

.results-header {
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid #ddd;
}

#resultsToggle {
    background: white;
    padding: 0;
    border: 1px solid #ddd;
    margin-top: 20px;
}

#resultsToggle summary {
    cursor: pointer;
    font-weight: 500;
    color: #333;
    user-select: none;
    padding: 10px 15px;
    background: #f8f8f8;
    transition: 0.4s;
}

#resultsToggle summary::before {
    content: "[+] ";
    color: #777;
    font-size: 90%;
    margin-right: 3px;
}

#resultsToggle[open] summary::before {
    content: "[−] ";
}

#resultsToggle summary:hover {
    background: #e8e8e8;
}

#resultsToggle[open] summary {
    border-bottom: 1px solid #ddd;
}

#resultCount {
    font-size: 14px;
    font-weight: 600;
    color: #333;
}

.result-item {
    padding: 20px;
    margin-bottom: 10px;
    background: #f8f8f8;
    border: 1px solid #ddd;
    transition: background 0.2s;
}

.result-item:hover {
    background: #f0f0f0;
}

.result-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: #333;
    margin-bottom: 10px;
    line-height: 1.4;
}

.result-title a {
    color: #333;
    text-decoration: none;
}

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

.result-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    margin-bottom: 12px;
    font-size: 14px;
    color: #777;
}

.result-meta span {
    display: flex;
    align-items: center;
    gap: 5px;
}

.result-snippet {
    margin-top: 12px;
    padding: 15px;
    background: white;
    border-left: 2px solid #ddd;
    font-size: 14px;
    line-height: 1.6;
    color: #555;
}

.result-snippet b {
    background: #fff3cd;
    padding: 1px 2px;
}

/* Trend Section */
.trend-section {
    padding: 30px 20px;
    background: white;
    border-top: 1px solid #ddd;
}

#trendToggle {
    background: white;
    padding: 0;
    border: 1px solid #ddd;
}

#trendToggle summary {
    cursor: pointer;
    font-weight: 500;
    color: #333;
    user-select: none;
    padding: 10px 15px;
    background: #f8f8f8;
    transition: 0.4s;
}

#trendToggle summary::before {
    content: "[+] ";
    color: #777;
    font-size: 90%;
    margin-right: 3px;
}

#trendToggle[open] summary::before {
    content: "[−] ";
}

#trendToggle summary:hover {
    background: #e8e8e8;
}

#trendToggle[open] summary {
    border-bottom: 1px solid #ddd;
}

.chart-container {
    position: relative;
    height: 400px;
    max-width: 1000px;
    margin: 20px auto 0;
    padding: 0 20px 20px 20px;
    background: white;
}

/* Stats Section */
.stats-section {
    padding: 30px 20px;
    background: #f8f8f8;
    border-top: 1px solid #ddd;
}

.stats-section h3 {
    margin-bottom: 20px;
    color: #333;
    font-weight: 600;
}

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

.stat-item {
    background: white;
    padding: 20px;
    border: 1px solid #ddd;
    text-align: center;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: #333;
    margin-bottom: 5px;
}

.stat-label {
    font-size: 14px;
    color: #777;
}

/* No results */
.no-results {
    text-align: center;
    padding: 60px 20px;
    color: #777;
}

.no-results-icon {
    font-size: 4rem;
    margin-bottom: 20px;
}

/* Error messages */
.error-message {
    padding: 20px;
    background: #fff3cd;
    border: 1px solid #ffc107;
    color: #856404;
    margin: 20px 0;
}

/* Export button */
.export-button {
    padding: 8px 16px;
    background: #f8f8f8;
    color: #333;
    border: 1px solid #ddd;
    font-size: 14px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.2s;
}

.export-button:hover {
    background: #e8e8e8;
}

.export-button:active {
    background: #ddd;
}

/* Chart title and info modal */
.chart-title-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: 15px;
}

.chart-title {
    font-weight: 600;
    color: #333;
}

.query-info-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    background: #777;
    color: white;
    border-radius: 50%;
    font-size: 0.7rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s;
    user-select: none;
}

.query-info-icon:hover {
    background: #555;
}

.query-modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    animation: fadeIn 0.2s;
}

.query-modal.show {
    display: flex;
    align-items: center;
    justify-content: center;
}

.query-modal-content {
    background: white;
    padding: 30px;
    border: 1px solid #ddd;
    max-width: 600px;
    width: 90%;
    animation: slideIn 0.3s;
}

.query-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid #ddd;
}

.query-modal-header h3 {
    color: #333;
    font-size: 1.2rem;
    font-weight: 600;
}

.query-modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: #777;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s;
}

.query-modal-close:hover {
    color: #333;
}

.query-modal-body {
    color: #555;
    line-height: 1.6;
}

.query-modal-body pre {
    background: #f8f8f8;
    padding: 15px;
    border-left: 2px solid #777;
    overflow-x: auto;
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
    color: #333;
    margin-top: 10px;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideIn {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Responsive */
@media (max-width: 768px) {
    body {
        padding: 10px;
    }

    header h1 {
        font-size: 1.5rem;
    }

    .search-section,
    .results-section,
    .trend-section,
    .stats-section {
        padding: 20px 10px;
    }

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

    .filters {
        flex-direction: column;
    }

    .filter-group {
        width: 100%;
    }
}
