/* Base Styles */
:root {
    --primary-color: #2c3e50;
    --secondary-color: #34495e;
    --accent-color: #3498db;
    --background-color: #f5f6fa;
    --text-color: #2c3e50;
}

body {
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: #f5f6fa;
}

.header-fixed {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background-color: #2c3e50;
    color: white;
    z-index: 1000;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.header-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: 25px 20px;
}

.header-content h1 {
    margin: 0;
    font-size: 24px;
    margin-bottom: 30px;
}

.controls {
    display: flex;
    gap: 20px;
    align-items: center;
    flex-wrap: wrap;
    background: transparent;
    padding: 15px 0;
}

.control-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.control-group label {
    color: #fff;
    font-weight: 500;
}

.control-group select {
    padding: 8px 12px;
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    background-color: #34495e;
    color: white;
    min-width: 200px;
    cursor: pointer;
}

.control-group select option {
    background-color: #34495e;
    color: white;
}

.dashboard {
    max-width: 1400px;
    margin: 0 auto;
    padding: 10px;
    padding-top: 200px;
}

.visualization-container {
    background: white;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    position: relative;
}

.visualization-container h2 {
    margin-top: 45px;
    margin-bottom: 20px;
    color: #2c3e50;
    font-size: 22px;
    font-weight: 600;
    padding-left: 20px;
}

/* Visualization Areas */
.visualization {
    width: 100%;
    height: 300px;
    position: relative;
}

#map-viz, #bar-chart, #scatter-plot {
    width: 100%;
    height: 500px;
    margin-bottom: 20px;
    overflow: visible;
}

/* Legend and Controls */
.legend, .controls {
    margin-top: 0.8rem;
    padding: 0.5rem;
    font-size: 0.8rem;
    background: var(--background-color);
    border-radius: 4px;
}

/* Footer */
footer {
    text-align: center;
    padding: 1rem;
    background: var(--primary-color);
    color: white;
    font-size: 0.8rem;
}

/* Media Queries */
@media (min-width: 768px) {
    header {
        padding: 1rem 2rem;
    }

    header h1 {
        font-size: 1.8rem;
        text-align: left;
    }

    .selector-panel {
        flex-direction: row;
        justify-content: flex-start;
        gap: 2rem;
    }

    .selector-group {
        flex: 0 1 auto;
    }

    select {
        width: auto;
    }

    .dashboard {
        padding: 2rem;
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 2rem;
    }

    .visualization-container:first-child {
        grid-column: 1 / -1;
        margin-bottom: 2rem;
        padding-top: 20px;
    }

    .visualization-container:not(:first-child) {
        grid-column: span 1;
    }

    #map-viz {
        height: 600px;
    }

    #bar-chart, #scatter-plot {
        height: 400px;
    }
}

.tooltip {
    position: absolute;
    background: white;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    pointer-events: none;
    font-size: 12px;
    z-index: 1000;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.back-button {
    position: absolute;
    top: 30px;
    left: 20px;
    padding: 8px 12px;
    background-color: #2c3e50;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 14px;
    transition: background-color 0.2s;
    z-index: 10;
}

.back-button:hover {
    background-color: #34495e;
}

/* Add axis styling */
.axis-label {
    font-size: 12px;
    fill: #666;
    font-weight: 500;
}

.tick line {
    stroke: #ddd;
}

.tick text {
    fill: #666;
}

.domain {
    stroke: #999;
}

/* Adjust visualization margins */
.visualization-container {
    padding: 30px;
}

#map-viz {
    margin-top: 10px;
}

/* Update chart dimensions */
#bar-chart, #scatter-plot {
    height: 450px;
}

/* Update selector styles */
.controls {
    display: flex;
    gap: 20px;
    align-items: center;
    flex-wrap: wrap;
    background: transparent;
    padding: 15px 0;
}

.control-group select {
    padding: 8px 12px;
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    background-color: #34495e;
    color: white;
    min-width: 200px;
    cursor: pointer;
}

/* Increase space between header and content */
.dashboard {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
    padding-top: 200px;
}

/* Fix bar chart x-axis visibility */
.x-axis path,
.x-axis line,
.y-axis path,
.y-axis line {
    stroke: #999;
    stroke-width: 1px;
}

.x-axis text,
.y-axis text {
    fill: #666;
    font-size: 12px;
}

/* Ensure axis labels are visible */
.axis-label {
    font-size: 12px;
    fill: #666;
    font-weight: 500;
}

/* Update header spacing */
.header-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: 25px 20px;
}

.header-content h1 {
    margin: 0;
    font-size: 24px;
    margin-bottom: 30px;
}

/* Add media queries for better mobile responsiveness */
@media screen and (max-width: 768px) {
    .dashboard {
        padding-top: 250px;
        margin-top: 0;
        display: block;
    }

    .visualization-container {
        width: 100%;
        margin-bottom: 20px;
        padding: 15px;
    }

    .visualization-container:first-child {
        grid-column: auto;
        padding-top: 20px;
    }

    .header-fixed {
        position: fixed;
        width: 100%;
    }

    .header-content {
        padding: 15px;
    }

    .controls {
        flex-direction: column;
        gap: 10px;
        width: 100%;
    }

    .control-group {
        width: 100%;
    }

    .control-group select {
        width: 100%;
    }

    #map-viz {
        margin-top: 10px;
        height: auto;
        min-height: 300px;
    }
}

/* Reset grid layout for desktop */
@media screen and (min-width: 769px) {
    .dashboard {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 2rem;
        padding-top: 150px;
    }

    .visualization-container:first-child {
        grid-column: 1 / -1;
    }
}

/* Add styles for the new visualization */
.full-width {
    grid-column: 1 / -1 !important;  /* Ensure it spans full width */
}

#rankings-chart {
    width: 95%;
    height: 600px;
    overflow-y: auto;
}

.visualization-container.full-width {
    grid-column: 1 / -1;
    width: 95%;
}

@media screen and (max-width: 768px) {
    #rankings-chart {
        height: 400px;  /* Slightly shorter on mobile */
    }
}