/* ============================================================================
   ESTILOS GLOBALES
   ============================================================================ */

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: #f5f7fa;
    color: #2c3e50;
    line-height: 1.6;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

/* ============================================================================
   HEADER
   ============================================================================ */

.header {
    text-align: center;
    margin-bottom: 30px;
    padding: 20px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.header h1 {
    font-size: 2rem;
    color: #2c3e50;
    margin-bottom: 8px;
}

.subtitle {
    font-size: 1.1rem;
    color: #7f8c8d;
    font-weight: 400;
}

/* ============================================================================
   CONTROLS
   ============================================================================ */

.controls {
    display: flex;
    gap: 20px;
    justify-content: center;
    align-items: center;
    margin-bottom: 20px;
    padding: 15px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

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

.control-group label {
    font-weight: 600;
    color: #34495e;
}

.select {
    padding: 8px 16px;
    border: 2px solid #e0e6ed;
    border-radius: 6px;
    background: white;
    font-size: 0.95rem;
    cursor: pointer;
    transition: border-color 0.2s;
}

.select:hover {
    border-color: #3498db;
}

.select:focus {
    outline: none;
    border-color: #2980b9;
}

.button {
    padding: 8px 20px;
    background: #3498db;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.button:hover {
    background: #2980b9;
}

.button:active {
    transform: translateY(1px);
}

/* ============================================================================
   MAP CONTAINER
   ============================================================================ */

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

#world-map {
    width: 100%;
    height: 600px;
    display: block;
}

/* ============================================================================
   COUNTRIES (SVG)
   ============================================================================ */

.country {
    stroke: #ffffff;
    stroke-width: 0.5px;
    cursor: pointer;
    transition: stroke-width 0.2s, opacity 0.2s;
}

.country:hover {
    stroke: #2c3e50;
    stroke-width: 2px;
    opacity: 0.9;
}

.country.no-data {
    fill: #CCCCCC;
    stroke: #999999;
}

/* ============================================================================
   TOOLTIP
   ============================================================================ */

/* ── TOOLTIP ─────────────────────────────────────────────────── */
#tooltip {
    display: none;
    position: fixed;
    /* fixed = relativo al viewport, no a la página */
    z-index: 1000;
    min-width: 200px;
    max-width: 280px;
    background: #ffffff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    font-family: inherit;
    font-size: 14px;
    pointer-events: all;
    /* permite click en el botón cerrar */
    overflow: hidden;
}

.tooltip-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px 8px;
    background: #f8f9fa;
    border-bottom: 1px solid #e0e0e0;
}

.tooltip-country {
    font-weight: 700;
    font-size: 15px;
    color: #1a1a2e;
}

.tooltip-close {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 14px;
    color: #999;
    padding: 0 0 0 8px;
    line-height: 1;
    flex-shrink: 0;
}

.tooltip-close:hover {
    color: #333;
}

.tooltip-body {
    padding: 10px 12px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.tooltip-label {
    font-size: 12px;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.tooltip-value {
    font-size: 20px;
    font-weight: 700;
    color: #1a1a2e;
}

.tooltip-source {
    font-size: 11px;
    color: #999;
    margin-top: 4px;
}

/* Cursor pointer en países interactivos */
.country {
    cursor: pointer;
}

/* ============================================================================
   LEGEND
   ============================================================================ */

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

.legend-container h3 {
    margin-bottom: 15px;
    color: #2c3e50;
    font-size: 1.1rem;
}

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

.legend-item {
    display: flex;
    align-items: center;
    gap: 12px;
}

.legend-color {
    width: 40px;
    height: 24px;
    border-radius: 4px;
    border: 1px solid #ddd;
    flex-shrink: 0;
}

.legend-label {
    font-size: 0.9rem;
    color: #555;
}

/* ============================================================================
   INFO PANEL
   ============================================================================ */

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

.info-panel h3 {
    margin-bottom: 15px;
    color: #2c3e50;
    font-size: 1.1rem;
}

.info-panel p {
    margin: 8px 0;
    font-size: 0.9rem;
    color: #555;
}

.info-panel strong {
    color: #2c3e50;
    font-weight: 600;
}

/* ============================================================================
   FOOTER
   ============================================================================ */

.footer {
    text-align: center;
    padding: 20px;
    color: #7f8c8d;
    font-size: 0.85rem;
}

/* ============================================================================
   RESPONSIVE
   ============================================================================ */

@media (max-width: 768px) {
    .header h1 {
        font-size: 1.5rem;
    }

    .controls {
        flex-direction: column;
        gap: 10px;
        padding: 10px;
    }

    .control-group {
        width: 100%;
        justify-content: center;
    }

    .select,
    .button {
        width: 100%;
        text-align: center;
    }

    .map-container {
        padding: 8px;
    }

    #world-map {
        height: auto;
        min-height: 300px;
    }

    .legend-container,
    .info-panel {
        padding: 15px;
    }

    .legend {
        font-size: 0.85rem;
    }

    .footer {
        font-size: 0.75rem;
        padding: 15px;
    }
}

/* ── MOBILE NOTICE ─────────────────────────────────────────── */
#mobile-notice {
    display: none;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 16px;
    background: #fff3cd;
    border-bottom: 1px solid #ffc107;
    color: #856404;
    font-size: 13px;
    line-height: 1.4;
    z-index: 2000;
}

#mobile-notice button {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 16px;
    color: #856404;
    flex-shrink: 0;
    padding: 0 4px;
}

@media (max-width: 767px) {
    #mobile-notice {
        display: flex;
    }
}

@media (min-width: 768px) and (max-width: 1024px) {
    #world-map {
        height: auto;
    }
}

/* ============================================================================
   LOADING STATE
   ============================================================================ */

.loading {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 600px;
    font-size: 1.2rem;
    color: #7f8c8d;
}

.loading::after {
    content: '...';
    animation: dots 1.5s steps(4, end) infinite;
}

@keyframes dots {

    0%,
    20% {
        content: '.';
    }

    40% {
        content: '..';
    }

    60%,
    100% {
        content: '...';
    }
}

/* ============================================================================
   ERROR STATE
   ============================================================================ */

.error {
    background: #fee;
    border: 2px solid #f88;
    border-radius: 8px;
    padding: 20px;
    margin: 20px 0;
    color: #c00;
}

.error h3 {
    margin-bottom: 10px;
}