/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #667eea;
    --primary-dark: #5568d3;
    --secondary-color: #764ba2;
    --accent-color: #f093fb;
    --success-color: #4caf50;
    --danger-color: #f44336;
    --warning-color: #ff9800;
    --info-color: #2196f3;
    
    --text-primary: #2c3e50;
    --text-secondary: #666;
    --text-muted: #999;
    
    --bg-primary: #ffffff;
    --bg-secondary: #f8f9fa;
    --bg-dark: #2c3e50;
    
    --border-color: #e0e0e0;
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.15);
    --shadow-xl: 0 20px 60px rgba(0, 0, 0, 0.3);
    
    --transition-fast: 0.2s ease;
    --transition-normal: 0.3s ease;
}

body {
    font-family: 'Segoe UI', 'Microsoft JhengHei', 'PingFang TC', -apple-system, BlinkMacSystemFont, sans-serif;
    color: var(--text-primary);
    background: var(--bg-secondary);
    line-height: 1.6;
}

/* Hero Section */
.hero-section {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
    padding: 60px 20px;
    text-align: center;
    box-shadow: var(--shadow-lg);
}

.hero-content {
    max-width: 1200px;
    margin: 0 auto;
}

.hero-title {
    font-size: 3rem;
    font-weight: 700;
    margin-bottom: 15px;
    animation: fadeInDown 0.8s ease;
}

.hero-subtitle {
    font-size: 1.3rem;
    opacity: 0.95;
    margin-bottom: 40px;
    animation: fadeInUp 0.8s ease;
}

.hero-stats {
    display: flex;
    justify-content: center;
    gap: 30px;
    flex-wrap: wrap;
    animation: fadeIn 1s ease;
}

.stat-card {
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
    border-radius: 15px;
    padding: 25px 35px;
    min-width: 180px;
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.stat-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

.stat-icon {
    font-size: 2.5rem;
    margin-bottom: 10px;
}

.stat-value {
    font-size: 2.2rem;
    font-weight: 700;
    margin-bottom: 5px;
}

.stat-label {
    font-size: 0.95rem;
    opacity: 0.9;
}

/* Container */
.container {
    max-width: 1400px;
    margin: -30px auto 40px;
    padding: 0 20px;
}

/* Control Panel */
.control-panel {
    background: white;
    border-radius: 15px;
    padding: 30px;
    margin-bottom: 30px;
    box-shadow: var(--shadow-md);
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    animation: slideInUp 0.6s ease;
}

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

.control-group label {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.95rem;
}

.date-input,
.filter-select,
.search-input {
    padding: 12px 15px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
    font-family: inherit;
}

.date-input:focus,
.filter-select:focus,
.search-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* Buttons */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-family: inherit;
}

.btn-icon {
    font-size: 1.2rem;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
    box-shadow: var(--shadow-sm);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-download {
    background: white;
    color: var(--primary-color);
    border: 2px solid var(--primary-color);
}

.btn-download:hover {
    background: var(--primary-color);
    color: white;
    transform: translateY(-2px);
}

/* Download Section */
.download-section {
    background: white;
    border-radius: 15px;
    padding: 30px;
    margin-bottom: 30px;
    box-shadow: var(--shadow-md);
    animation: slideInUp 0.7s ease;
}

.download-section h3 {
    margin-bottom: 20px;
    color: var(--text-primary);
    font-size: 1.3rem;
}

.download-buttons {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
}

/* Chart Section */
.chart-section {
    background: white;
    border-radius: 15px;
    padding: 30px;
    margin-bottom: 30px;
    box-shadow: var(--shadow-md);
    animation: slideInUp 0.8s ease;
}

.chart-section h3 {
    margin-bottom: 20px;
    color: var(--text-primary);
    font-size: 1.3rem;
}

.event-chart {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 15px;
}

.event-bar {
    background: var(--bg-secondary);
    border-radius: 10px;
    padding: 15px;
    text-align: center;
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.event-bar:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-sm);
}

.event-bar-label {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.event-bar-value {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--primary-color);
}

.event-bar-fill {
    height: 8px;
    background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
    border-radius: 4px;
    margin-top: 10px;
    transition: width var(--transition-normal);
}

/* Table Section */
.table-section {
    background: white;
    border-radius: 15px;
    padding: 30px;
    box-shadow: var(--shadow-md);
    animation: slideInUp 0.9s ease;
}

.table-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 15px;
}

.table-header h3 {
    color: var(--text-primary);
    font-size: 1.3rem;
}

.table-info {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.table-container {
    overflow-x: auto;
    border-radius: 10px;
    border: 1px solid var(--border-color);
}

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

thead {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
}

th {
    padding: 15px;
    text-align: left;
    font-weight: 600;
    font-size: 0.95rem;
    white-space: nowrap;
}

th.sortable {
    cursor: pointer;
    user-select: none;
    transition: background-color var(--transition-fast);
}

th.sortable:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

tbody tr {
    border-bottom: 1px solid var(--border-color);
    transition: background-color var(--transition-fast);
}

tbody tr:hover {
    background-color: var(--bg-secondary);
}

tbody tr:last-child {
    border-bottom: none;
}

td {
    padding: 20px 15px;
    vertical-align: top;
}

.loading-cell {
    text-align: center;
    padding: 60px 20px !important;
    color: var(--text-muted);
}

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

/* Table Cell Styles */
.rank-cell {
    font-weight: 700;
    font-size: 1.2rem;
    color: var(--primary-color);
    text-align: center;
    width: 60px;
}

.title-cell {
    min-width: 300px;
}

.article-link {
    color: var(--text-primary);
    text-decoration: none;
    font-weight: 600;
    font-size: 1.05rem;
    line-height: 1.4;
    display: block;
    margin-bottom: 8px;
    transition: color var(--transition-fast);
}

.article-link:hover {
    color: var(--primary-color);
}

.article-meta {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.category-badge {
    background: #e3f2fd;
    color: #1976d2;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 0.85rem;
    font-weight: 500;
}

.event-badge {
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 0.85rem;
    font-weight: 500;
}

.event-accident { background: #ffebee; color: #c62828; }
.event-war-conflict { background: #fce4ec; color: #880e4f; }
.event-election { background: #f3e5f5; color: #6a1b9a; }
.event-financial { background: #e8f5e9; color: #2e7d32; }
.event-sports { background: #fff3e0; color: #e65100; }
.event-entertainment { background: #fce4ec; color: #c2185b; }
.event-technology { background: #e1f5fe; color: #0277bd; }
.event-health { background: #f1f8e9; color: #558b2f; }
.event-education { background: #fff9c4; color: #f57f17; }
.event-crime { background: #ffebee; color: #b71c1c; }
.event-weather { background: #e0f2f1; color: #00695c; }
.event-other { background: #f5f5f5; color: #616161; }

.engagement-cell {
    text-align: center;
    min-width: 140px;
}

.engagement-total {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 5px;
}

.engagement-breakdown {
    display: flex;
    justify-content: center;
    gap: 10px;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.entities-cell {
    min-width: 250px;
}

.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.8rem;
    margin: 2px;
    font-weight: 500;
}

.badge-person { background: #e3f2fd; color: #1976d2; }
.badge-place { background: #e8f5e9; color: #388e3c; }
.badge-org { background: #fff3e0; color: #f57c00; }
.badge-brand { background: #f3e5f5; color: #7b1fa2; }

.time-cell {
    color: var(--text-secondary);
    font-size: 0.9rem;
    min-width: 150px;
}

/* Footer */
.footer {
    background: var(--bg-dark);
    color: white;
    padding: 40px 20px;
    text-align: center;
    margin-top: 60px;
}

.footer-content {
    max-width: 1200px;
    margin: 0 auto;
}

.footer a {
    color: var(--accent-color);
    text-decoration: none;
    transition: color var(--transition-fast);
}

.footer a:hover {
    color: white;
}

.footer-note {
    margin-top: 15px;
    font-size: 0.9rem;
    opacity: 0.8;
}

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

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

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

/* Responsive Design */
@media (max-width: 768px) {
    .hero-title {
        font-size: 2rem;
    }
    
    .hero-subtitle {
        font-size: 1rem;
    }
    
    .hero-stats {
        gap: 15px;
    }
    
    .stat-card {
        padding: 20px 25px;
        min-width: 140px;
    }
    
    .stat-icon {
        font-size: 2rem;
    }
    
    .stat-value {
        font-size: 1.8rem;
    }
    
    .control-panel {
        grid-template-columns: 1fr;
        padding: 20px;
    }
    
    .download-buttons {
        flex-direction: column;
    }
    
    .btn-download {
        width: 100%;
    }
    
    .event-chart {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    }
    
    .table-section {
        padding: 20px;
    }
    
    table {
        font-size: 0.9rem;
    }
    
    th, td {
        padding: 12px 8px;
    }
    
    .rank-cell {
        width: 40px;
        font-size: 1rem;
    }
    
    .title-cell {
        min-width: 200px;
    }
    
    .article-link {
        font-size: 0.95rem;
    }
    
    .engagement-total {
        font-size: 1.2rem;
    }
    
    .engagement-breakdown {
        font-size: 0.75rem;
        gap: 5px;
    }
}

@media (max-width: 480px) {
    .hero-section {
        padding: 40px 15px;
    }
    
    .container {
        padding: 0 15px;
    }
    
    .stat-card {
        min-width: 100%;
    }
}
