@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;600;700&display=swap');

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

:root {
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    
    /* Deep blue color scheme */
    --primary: #2563eb; /* blue-600 */
    --secondary: #3b82f6; /* blue-500 */
    --accent: #60a5fa; /* blue-400 */

    /* Background colors - dark blue/grey palette */
    --bg-main: #111827; /* gray-900 */
    --bg-light: #1f2937; /* gray-800 */
    --card-bg: #1f2937; /* gray-800 */
    
    --text: #e5e7eb; /* gray-200 */
    --text-light: #9ca3af; /* gray-400 */
    --border: #374151; /* gray-700 */
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 10px;
}
::-webkit-scrollbar-track {
    background: var(--bg-main);
}
::-webkit-scrollbar-thumb {
    background: var(--bg-light);
    border-radius: 10px;
    border: 2px solid var(--bg-main);
}
::-webkit-scrollbar-thumb:hover {
    background: var(--primary);
}

body {
    background: var(--bg-main);
    background-attachment: fixed;
    color: var(--text);
    font-family: var(--font-sans);
    line-height: 1.6;
    min-height: 100vh;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

.skip-link {
    position: absolute;
    left: -9999px;
    padding: 1rem;
    background: var(--primary);
    color: white;
    text-decoration: none;
    z-index: 9999;
}
.skip-link:focus {
    left: 1rem;
    top: 1rem;
}

header {
    background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 100%);
    color: white;
    padding: 2.5rem 1rem;
    text-align: center;
    box-shadow: 0 4px 6px rgba(29, 78, 216, 0.2);
    position: relative;
    overflow: hidden;
}

header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    width: 800px;
    height: 800px;
    background-image: radial-gradient(circle, rgba(255, 255, 255, 0.05), transparent 60%);
    transform: translateX(-50%) translateY(-70%);
    pointer-events: none;
}

.header-content {
    max-width: 1200px;
    margin: 0 auto;
    position: relative;
}

header h1 {
    font-size: 2.8rem;
    font-weight: 700;
    letter-spacing: -1px;
    color: #ffffff;
}

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

.intro-container {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 1.5rem 2rem;
    margin-bottom: 2.5rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 2rem;
    align-items: center;
    border: 1px solid var(--border);
}

.about-section {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 1.5rem;
    align-items: center;
}

.about-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    border-radius: 10px;
    color: white;
    font-size: 1.5rem;
    flex-shrink: 0;
}

.about-content h2 {
    color: var(--primary);
    margin-bottom: 0.5rem;
    font-size: 1.25rem;
    font-weight: 600;
}

.about-content p {
    font-size: 0.95rem;
    line-height: 1.6;
    color: var(--text);
}

.stats-cards {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    min-width: 300px;
}

.stat-card {
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    border-radius: 12px;
    padding: 1.5rem 1rem;
    text-align: center;
    color: white;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
    transition: transform 0.3s ease;
}

.stat-card:hover {
    transform: translateY(-2px);
}

.stat-number {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    color: #ffffff;
}

.stat-label {
    font-size: 0.85rem;
    font-weight: 500;
    color: #bfdbfe;
    line-height: 1.2;
}

.charts-container {
    display: grid;
    grid-template-columns: 1fr;
    gap: 2rem;
}

.chart-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: 2rem;
}

@media (min-width: 992px) {
    .chart-row {
        grid-template-columns: 1fr 1fr;
        align-items: start; /* Fix: prevent boxes from stretching unevenly */
    }
    .chart-row.full-width {
        grid-template-columns: 1fr;
    }
}

.chart-box {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.5rem;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    display: flex;
    flex-direction: column;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2);
    animation: fadeIn 0.5s ease-out forwards;
    opacity: 0;
}

/* Priority-based sizing - UNIFIED HEIGHTS PER ROW */
.chart-priority-1 { min-height: 650px; }
.chart-priority-2, .chart-priority-7 { min-height: 520px; } /* Unified height */
.chart-priority-3, .chart-priority-4 { min-height: 520px; } /* Unified height */
.chart-priority-5, .chart-priority-6 { min-height: 520px; } /* Unified height */

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

.chart-box:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
}

.chart-box.full-width-map {
    grid-column: 1 / -1;
    padding: 0; /* Fix: remove padding for edge-to-edge map */
    overflow: hidden;
}

.chart-box.full-width-map .chart-header,
.chart-box.full-width-map .map-subtitle,
.chart-box.full-width-map .chart-filter-group,
.chart-box.full-width-map .chart-description {
    padding-left: 1.5rem;
    padding-right: 1.5rem;
}

/* Regional chart specific styling */
.regional-chart .regional-content {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 1.5rem;
    align-items: start;
}

.regional-chart-container {
    min-height: 280px;
}

.regional-insights {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

@media (max-width: 1200px) {
    .regional-chart .regional-content {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .regional-insights {
        order: -1;
    }
}

.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid var(--border);
}

.chart-box h2 {
    color: var(--text);
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.7rem;
    font-size: 1.25rem;
}

.chart-box h2 i {
    color: var(--primary);
    font-size: 1.3rem;
}

.map-subtitle {
    margin-bottom: 1rem;
}

.map-subtitle p {
    font-size: 0.95rem;
    margin-bottom: 0.25rem;
}

.map-subtitle .data-source {
    font-size: 0.85rem;
    color: var(--text-light);
    font-style: italic;
}

.data-year {
    font-size: 0.85rem;
    color: var(--text-light);
    font-style: italic;
    margin-bottom: 1rem;
    padding-left: 0.25rem;
}

.chart-container {
    width: 100%;
    flex: 1;
    min-height: 300px;
    background: white; /* White background for all chart areas */
    border-radius: 8px;
    padding: 0.5rem;
}

.map-container {
    min-height: 550px;
    padding: 0; /* Remove padding for full-width map */
    background: white;
    border-radius: 8px;
    overflow: hidden;
}

.chart-description {
    margin-top: 1rem;
    padding: 1rem;
    background-color: var(--bg-main);
    border-radius: 8px;
    border-left: 3px solid var(--secondary);
    font-size: 0.9rem;
    color: var(--text-light);
}

.chart-description strong {
    color: var(--text);
}

.chart-filter, .chart-filter-group, .fullscreen-toggle, .table-controls {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.chart-filter label, .chart-filter-group span, .fullscreen-toggle label {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--primary);
    white-space: nowrap;
}

.chart-filter-group label {
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.3rem;
    cursor: pointer;
    color: var(--text);
}

.chart-subtitle {
    font-size: 0.85rem;
    color: var(--text-light);
    margin-top: -0.75rem;
    margin-bottom: 1rem;
    display: block;
}

.table-helper-text {
    font-size: 0.85rem;
    color: var(--text-light);
    font-style: italic;
    margin-left: 0.5rem;
}

select, .btn {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background-color: var(--card-bg);
    color: var(--text);
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

select[multiple] {
    min-height: 60px;
    padding: 0.5rem;
}

select:hover, .btn:hover {
    border-color: var(--primary);
    background-color: var(--bg-main);
}

select:focus, .btn:focus {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.btn {
    background-color: var(--primary);
    color: white;
    border-color: var(--primary);
}

.btn:hover {
    background-color: #1d4ed8; /* Darker blue */
}

.btn.btn-secondary {
    background-color: transparent;
    border-color: var(--secondary);
    color: var(--secondary);
}

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

.table-controls {
    margin-top: 1rem;
}

/* FIX: Make table containers scrollable to prevent layout shifts */
#educationTableContainer, #regionTableContainer {
    margin-top: 1rem;
    background: white; /* White background for tables */
    border-radius: 8px;
    padding: 1rem;
    border: 1px solid var(--border);
    max-height: 250px; /* Constrain height */
    overflow-y: auto; /* Add vertical scroll */
}

#educationTable, #regionTable {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

#educationTable th, #educationTable td,
#regionTable th, #regionTable td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid #e5e7eb;
    color: #374151; /* Dark text for readability on white background */
}

#educationTable th, #regionTable th {
    font-weight: 600;
    color: #1f2937; /* Darker text for headers */
    background-color: #f3f4f6; /* Light gray background for headers */
}

#educationTable tbody tr:hover,
#regionTable tbody tr:hover {
    background-color: #f9fafb;
}

#educationTable tbody tr:last-child td,
#regionTable tbody tr:last-child td {
    border-bottom: none;
}

footer {
    background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 100%);
    color: white;
    padding: 2rem 1rem;
    margin-top: 3rem;
    text-align: center;
    box-shadow: 0 -4px 6px rgba(29, 78, 216, 0.2);
}

.footer-content p {
    margin-bottom: 0.5rem;
}

.footer-content a {
    color: #93c5fd;
    text-decoration: none;
    font-weight: 600;
}

.footer-content a:hover {
    text-decoration: underline;
}

.noscript-warning {
    padding: 1rem;
    background: #374151;
    color: #f9fafb;
    border-left: 4px solid var(--accent);
    margin: 1rem;
    border-radius: 6px;
}

@media (max-width: 768px) {
    header h1 { font-size: 2.2rem; }
    
    .intro-container {
        grid-template-columns: 1fr;
        gap: 1.5rem;
        padding: 1.5rem;
    }
    
    .about-section {
        grid-template-columns: 1fr;
        gap: 1rem;
        text-align: center;
    }
    
    .about-icon {
        width: 40px;
        height: 40px;
        font-size: 1.2rem;
        margin: 0 auto;
    }
    
    .stats-cards {
        grid-template-columns: 1fr;
        min-width: auto;
    }
    
    .map-container { min-height: 400px; }
    .chart-filter, .chart-filter-group {
        flex-direction: column;
        align-items: flex-start;
    }
}