/* ================================================
   Research Trends Page Styles
   ================================================ */

/* Navigation (matching deadlines page) */
.nav-btn.deadlines-btn,
.nav-btn.wiki-btn,
.nav-btn.discussion-btn,
.nav-btn.trends-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-width: 100px;
    height: 36px;
    padding: 0 14px;
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
    background: var(--primary-bg);
    color: var(--primary);
    border: 1px solid var(--primary-light);
}

.nav-btn.deadlines-btn:hover,
.nav-btn.wiki-btn:hover,
.nav-btn.discussion-btn:hover,
.nav-btn.trends-btn:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.nav-btn.help-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    background: var(--bg-gray);
    color: var(--text-muted);
    border: 1px solid var(--border-light, var(--border));
    border-radius: 50%;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.2s;
}

.nav-btn.help-btn:hover {
    background: var(--primary-bg);
    color: var(--primary);
    border-color: var(--primary-light);
}

.back-link {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    transition: all 0.2s;
}

.back-link:hover {
    color: var(--primary);
    background: var(--primary-bg);
}

.last-updated {
    font-size: 12px;
    color: var(--text-muted);
}

/* Main Content */
.trends-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px;
    position: relative;
    min-height: 60vh;
}

/* Header */
.trends-header {
    text-align: center;
    margin-bottom: 28px;
}

.trends-title {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.trends-subtitle {
    font-size: 15px;
    color: var(--text-secondary);
}

/* Controls */
.trends-controls {
    margin-bottom: 24px;
}

.trends-tabs {
    display: flex;
    gap: 4px;
    background: var(--bg-gray);
    border-radius: var(--radius-md);
    padding: 4px;
    margin-bottom: 16px;
    overflow-x: auto;
}

.trend-tab {
    flex: 1;
    padding: 10px 16px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.trend-tab:hover {
    color: var(--text-primary);
    background: var(--bg-white);
}

.trend-tab.active {
    background: var(--bg-white);
    color: var(--primary);
    font-weight: 600;
    box-shadow: var(--shadow-sm);
}

.trends-filters {
    display: flex;
    gap: 16px;
    align-items: end;
    flex-wrap: wrap;
}

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

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

.filter-group select {
    padding: 8px 32px 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-white);
    font-size: 14px;
    color: var(--text-primary);
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236B7280' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
}

.filter-group select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.1);
}

/* Tab Panels */
.tab-panel {
    display: none;
}

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

/* Stats Row */
.stats-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--bg-white);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    padding: 20px;
    text-align: center;
}

.stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 4px;
}

.stat-label {
    font-size: 13px;
    color: var(--text-muted);
    font-weight: 500;
}

/* Coverage Warning */
.coverage-warning {
    background: #FEF3C7;
    color: #92400E;
    border: 1px solid #FCD34D;
    border-radius: var(--radius-sm);
    padding: 10px 16px;
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 16px;
}

/* Trend Columns (Emerging / Declining) */
.trend-columns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 24px;
}

.trend-column {
    background: var(--bg-white);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    padding: 20px;
}

.column-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.emerging-title::before {
    content: '';
    display: inline-block;
    width: 8px;
    height: 8px;
    background: #10B981;
    border-radius: 50%;
}

.declining-title::before {
    content: '';
    display: inline-block;
    width: 8px;
    height: 8px;
    background: #EF4444;
    border-radius: 50%;
}

.keyword-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.keyword-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 12px;
    border-radius: var(--radius-full);
    font-size: 13px;
    font-weight: 500;
}

.keyword-tag.emerging {
    background: #ECFDF5;
    color: #065F46;
    border: 1px solid #A7F3D0;
}

.keyword-tag.declining {
    background: #FEF2F2;
    color: #991B1B;
    border: 1px solid #FECACA;
}

.keyword-tag.rising {
    background: #EFF6FF;
    color: #1E40AF;
    border: 1px solid #BFDBFE;
}

.keyword-tag.stable {
    background: var(--bg-gray);
    color: var(--text-secondary);
    border: 1px solid var(--border-light);
}

/* Chart Containers */
.chart-container {
    background: var(--bg-white);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    padding: 20px;
    margin-bottom: 20px;
}

.chart-container.chart-large {
    min-height: 400px;
}

.chart-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 16px;
}

/* Keyword Table */
.keywords-section {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 20px;
}

.keyword-table-container {
    background: var(--bg-white);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    padding: 20px;
    overflow-x: auto;
}

.section-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 16px;
}

.section-desc {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 12px;
}

.keyword-table {
    width: 100%;
    border-collapse: collapse;
}

.keyword-table th {
    text-align: left;
    padding: 10px 12px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 2px solid var(--border-light);
}

.keyword-table td {
    padding: 10px 12px;
    font-size: 14px;
    border-bottom: 1px solid var(--border-light);
}

.keyword-table tr:hover {
    background: var(--bg-gray);
}

.keyword-table .keyword-name {
    font-weight: 500;
    color: var(--text-primary);
}

.keyword-table .count-cell {
    font-variant-numeric: tabular-nums;
}

.trend-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: var(--radius-full);
    font-size: 12px;
    font-weight: 600;
}

.trend-badge.rising,
.trend-badge.emerging {
    background: #ECFDF5;
    color: #065F46;
}

.trend-badge.declining,
.trend-badge.fading {
    background: #FEF2F2;
    color: #991B1B;
}

.trend-badge.stable {
    background: var(--bg-gray);
    color: var(--text-secondary);
}

.change-value {
    font-size: 13px;
    font-variant-numeric: tabular-nums;
}

.change-value.positive {
    color: #059669;
}

.change-value.negative {
    color: #DC2626;
}

/* Bigram Section */
.bigram-section {
    background: var(--bg-white);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    padding: 20px;
}

.bigram-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.bigram-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: var(--bg-gray);
    border-radius: var(--radius-sm);
}

.bigram-phrase {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
}

.bigram-count {
    font-size: 13px;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}

/* Conference Grid */
.conference-grid, .area-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 20px;
}

.conf-card, .area-card {
    background: var(--bg-white);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    padding: 20px;
    transition: box-shadow 0.2s;
}

.conf-card:hover, .area-card:hover {
    box-shadow: var(--shadow-md);
}

.conf-card-header, .area-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.conf-name, .area-name {
    font-size: 18px;
    font-weight: 700;
    color: var(--primary);
}

.conf-area-badge {
    font-size: 11px;
    padding: 3px 8px;
    background: var(--primary-bg);
    color: var(--primary);
    border-radius: var(--radius-full);
    font-weight: 500;
}

.conf-paper-count, .area-paper-count {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 12px;
}

.conf-keywords, .area-keywords {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.conf-keyword {
    font-size: 12px;
    padding: 4px 10px;
    background: var(--bg-gray);
    border-radius: var(--radius-full);
    color: var(--text-secondary);
    font-weight: 500;
}

.conf-keyword.top-3 {
    background: var(--primary-bg);
    color: var(--primary);
    font-weight: 600;
}

/* Timeline Scope Bar */
.timeline-scope-bar {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.scope-tabs {
    display: flex;
    gap: 4px;
    background: var(--bg-gray);
    border-radius: var(--radius-sm);
    padding: 3px;
}

.scope-tab {
    padding: 7px 14px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.scope-tab:hover {
    color: var(--text-primary);
}

.scope-tab.active {
    background: var(--bg-white);
    color: var(--primary);
    font-weight: 600;
    box-shadow: var(--shadow-sm);
}

.scope-select-group select {
    padding: 7px 32px 7px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-white);
    font-size: 13px;
    color: var(--text-primary);
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236B7280' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
}

/* Timeline Section */
.timelines-section {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.timeline-keyword-selector {
    background: var(--bg-white);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    padding: 20px;
}

.keyword-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    max-height: 150px;
    overflow-y: auto;
}

.keyword-chip {
    padding: 6px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    background: var(--bg-white);
    cursor: pointer;
    transition: all 0.2s;
}

.keyword-chip:hover {
    border-color: var(--primary-light);
    color: var(--primary);
}

.keyword-chip.selected {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* Loading */
.loading-overlay {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    color: var(--text-muted);
    gap: 12px;
}

.loading-overlay .loading-spinner {
    width: 36px;
    height: 36px;
    border: 3px solid var(--border-light);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* Empty State */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.empty-state code {
    display: inline-block;
    margin-top: 12px;
    padding: 8px 16px;
    background: var(--bg-gray);
    border-radius: var(--radius-sm);
    font-size: 13px;
}

/* Responsive */
@media (max-width: 900px) {
    .stats-row {
        grid-template-columns: repeat(2, 1fr);
    }
    .trend-columns {
        grid-template-columns: 1fr;
    }
    .keywords-section {
        grid-template-columns: 1fr;
    }
    .conference-grid, .area-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 600px) {
    .trends-content {
        padding: 16px;
    }
    .trends-tabs {
        gap: 2px;
    }
    .trend-tab {
        padding: 8px 10px;
        font-size: 13px;
    }
    .stats-row {
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }
    .stat-card {
        padding: 14px;
    }
    .stat-value {
        font-size: 22px;
    }
    .trends-filters {
        flex-direction: column;
        gap: 8px;
    }
}
