/* ===== RESET & VARIABLES ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg-dark: #0a0a0f;
    --bg-card: #14141f;
    --text-primary: #f0f0f5;
    --text-secondary: #8888a0;
    --accent: #fa0032;
    --accent-light: #ff4d6d;
    --border: #2a2a3a;
}

/* ===== BASE ===== */
body {
    background: var(--bg-dark);
    color: var(--text-primary);
    font-family: "DM Sans", -apple-system, BlinkMacSystemFont, sans-serif;
    min-height: 100vh;
    overflow-x: hidden;
}

/* ===== HEADER ===== */
header {
    text-align: center;
    padding: 2rem 1rem 1rem;
    background: linear-gradient(
        180deg,
        rgba(79, 140, 255, 0.08) 0%,
        transparent 100%
    );
}

h1 {
    font-size: clamp(1.8rem, 5vw, 2.8rem);
    font-weight: 600;
    letter-spacing: -0.02em;
    margin-bottom: 0.5rem;
}

h1 .year {
    color: var(--accent);
    font-weight: 700;
}

.subtitle {
    color: var(--text-secondary);
    font-size: clamp(0.9rem, 2vw, 1.1rem);
    max-width: 600px;
    margin: 0 auto;
}

/* ===== TOGGLE BUTTONS ===== */
.toggle-container {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 1.5rem;
}

.toggle-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.7rem 1.2rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.25s ease;
}

.toggle-btn:hover {
    border-color: var(--accent);
    color: var(--text-primary);
}

.toggle-btn.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.toggle-btn.active .toggle-icon {
    opacity: 1;
}

.toggle-icon {
    font-size: 1.1rem;
    opacity: 0.7;
}

.toggle-label {
    font-weight: 500;
}

/* ===== MAIN ===== */
main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem;
    position: relative;
}

/* ===== SEARCH ===== */
.search-container {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    width: 100%;
    max-width: 400px;
    padding: 0 1rem;
}

#search {
    width: 100%;
    padding: 0.9rem 1.2rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 1rem;
    transition: all 0.25s ease;
    background-image: url("data:image/svg+xml,%3Csvg fill='%238888a0' xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24'%3E%3Cpath d='M10 2a8 8 0 015.292 13.708l4 4a1 1 0 01-1.414 1.414l-4-4A8 8 0 1110 2zm0 2a6 6 0 100 12 6 6 0 000-12z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
}

#search:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(250, 0, 50, 0.15);
}

#search::placeholder {
    color: var(--text-secondary);
}

/* ===== MAP ===== */
#map {
    width: 100%;
    height: 55vh;
    max-height: 550px;
    min-height: 350px;
    margin: 0 auto;
    padding-top: 25px;
    border-radius: 16px;
    overflow: hidden;
    background: var(--bg-card);
    border: 1px solid var(--border);
}

.leaflet-container {
    background: var(--bg-card) !important;
    font-family: "DM Sans", sans-serif;
}

/* ===== LEGEND ===== */
.legend {
    position: absolute;
    bottom: 30px;
    left: 10px;
    background: rgba(20, 20, 31, 0.92);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 0.8rem 1rem;
    z-index: 1000;
    backdrop-filter: blur(8px);
}

.legend-title {
    font-size: 0.8rem;
    color: var(--text-secondary);
    display: block;
    margin-bottom: 0.5rem;
}

.legend-gradient {
    width: 150px;
    height: 10px;
    border-radius: 5px;
    background: linear-gradient(
        to right,
        #fef0d9,
        #fdcc8a,
        #fc8d59,
        #e34a33,
        #b30000
    );
}

.legend-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.7rem;
    color: var(--text-secondary);
    margin-top: 0.3rem;
    font-family: "JetBrains Mono", monospace;
}

.legend-scale {
    display: flex;
    flex-direction: column;
}

/* ===== TOOLTIP ===== */
.tooltip {
    position: fixed;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 0;
    min-width: 280px;
    max-width: 320px;
    box-shadow:
        0 20px 60px rgba(0, 0, 0, 0.5),
        0 0 0 1px rgba(255, 255, 255, 0.05);
    z-index: 10000;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: opacity 0.25s ease, transform 0.25s ease, visibility 0.25s ease;
    pointer-events: none;
}

.tooltip.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    pointer-events: auto;
}

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

.tooltip-name {
    font-weight: 600;
    font-size: 1.1rem;
    color: var(--text-primary);
}

.tooltip-close {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 1.3rem;
    line-height: 1;
    transition: all 0.2s ease;
}

.tooltip-close:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

.tooltip-rate {
    padding: 1.2rem;
    text-align: center;
    background: linear-gradient(
        180deg,
        rgba(79, 140, 255, 0.05) 0%,
        transparent 100%
    );
}

.rate-value {
    display: block;
    font-family: "JetBrains Mono", monospace;
    font-size: 2.8rem;
    font-weight: 600;
    color: var(--accent-light);
    line-height: 1;
    margin-bottom: 0.3rem;
}

.rate-unit {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.tooltip-chart {
    padding: 0.8rem 1rem 0.5rem;
    height: 140px;
}

#chartCanvas {
    width: 100% !important;
    height: 100% !important;
}

.tooltip-footer {
    padding: 0.8rem 1.2rem;
    border-top: 1px solid var(--border);
    text-align: center;
}

.evolution-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.evolution-label .positive {
    color: #b30000;
}

.evolution-label .negative {
    color: #4a7c4e;
}

.evolution-label .neutral {
    color: var(--text-secondary);
}

/* ===== LEAFLET CUSTOMIZATION ===== */
.leaflet-control-zoom {
    border: none !important;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3) !important;
}

.leaflet-control-zoom a {
    background: var(--bg-card) !important;
    color: var(--text-primary) !important;
    border: 1px solid var(--border) !important;
    width: 36px !important;
    height: 36px !important;
    line-height: 36px !important;
    font-size: 18px !important;
}

.leaflet-control-zoom a:hover {
    background: rgba(250, 0, 50, 0.1) !important;
    color: var(--accent) !important;
}

.leaflet-control-zoom-in {
    border-radius: 10px 10px 0 0 !important;
}

.leaflet-control-zoom-out {
    border-radius: 0 0 10px 10px !important;
    border-top: none !important;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 600px) {
    header {
        padding: 1.5rem 1rem 1rem;
    }

    main {
        padding: 0.5rem;
    }

    #map {
        height: 50vh;
        border-radius: 12px;
    }

    .search-container {
        max-width: 90%;
    }

    .tooltip {
        min-width: 260px;
        max-width: 90vw;
    }

    .rate-value {
        font-size: 2.2rem;
    }

    .legend {
        max-width: 180px;
    }

    .legend-gradient {
        width: 100%;
    }

    .toggle-container {
        flex-direction: column;
        align-items: center;
        gap: 0.5rem;
    }

    .toggle-btn {
        width: 100%;
        max-width: 280px;
        justify-content: center;
    }
}
