/* =====================================================
   TERREMOTOS ANDALUCÍA - ESTILOS PRINCIPALES
   ===================================================== */

/* Variables CSS */
:root {
    --color-bg-primary: #0a0e17;
    --color-bg-secondary: #111827;
    --color-bg-tertiary: #1f2937;
    --color-accent-primary: #3b82f6;
    --color-accent-secondary: #8b5cf6;
    --color-accent-gradient: linear-gradient(135deg, #3b82f6 0%, #8b5cf6 100%);
    --color-text-primary: #f9fafb;
    --color-text-secondary: #9ca3af;
    --color-text-muted: #6b7280;
    --color-success: #10b981;
    --color-warning: #f59e0b;
    --color-danger: #ef4444;
    --color-mag-low: #22c55e;
    --color-mag-medium: #eab308;
    --color-mag-high: #f97316;
    --color-mag-severe: #dc2626;
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --border-radius-sm: 8px;
    --border-radius-md: 12px;
    --border-radius-lg: 16px;
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.5);
    --glass-bg: rgba(17, 24, 39, 0.85);
    --glass-border: rgba(255, 255, 255, 0.1);
    --transition-fast: 0.15s ease;
    --transition-normal: 0.3s ease;
}

/* Reset y Base */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-family);
    background: var(--color-bg-primary);
    color: var(--color-text-primary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

/* =====================================================
   HEADER
   ===================================================== */
.header {
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--glass-border);
    padding: 1rem 1.5rem;
    position: sticky;
    top: 0;
    z-index: 1000;
}

.header-content {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.logo {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.logo-image {
    width: 60px;
    height: auto;
    object-fit: contain;
    /* Efecto sutil de brillo para que destaque sobre fondo oscuro */
    filter: drop-shadow(0 0 5px rgba(59, 130, 246, 0.3));
}

.title-container {
    display: flex;
    flex-direction: column;
}

.logo h1 {
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1.1;
    background: var(--color-accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.author-subtitle {
    font-size: 0.75rem;
    color: var(--color-text-secondary);
    margin-top: 0.2rem;
    font-weight: 400;
}

.author-subtitle a {
    color: var(--color-accent-primary);
    text-decoration: none;
    transition: color calc(var(--transition-fast));
}

.author-subtitle a:hover {
    color: var(--color-accent-secondary);
}

.header-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* Botón de Información */
.info-btn {
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid rgba(59, 130, 246, 0.3);
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--transition-fast);
    color: var(--color-accent-primary);
    margin-right: 0.5rem;
}

.info-btn:hover {
    background: rgba(59, 130, 246, 0.2);
    transform: scale(1.05);
}

.info-icon {
    font-size: 1.2rem;
    line-height: 1;
}

.live-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--color-success);
}

.pulse {
    width: 10px;
    height: 10px;
    background: var(--color-success);
    border-radius: 50%;
    animation: pulse-live 1.5s ease-in-out infinite;
}

@keyframes pulse-live {
    0% {
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
    }

    70% {
        box-shadow: 0 0 0 10px rgba(16, 185, 129, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
    }
}

.date-range {
    font-size: 0.875rem;
    color: var(--color-text-secondary);
    padding: 0.5rem 1rem;
    background: var(--color-bg-tertiary);
    border-radius: var(--border-radius-sm);
    border: 1px solid var(--glass-border);
}

/* =====================================================
   STATS BAR
   ===================================================== */
.stats-bar {
    background: var(--color-bg-secondary);
    border-bottom: 1px solid var(--glass-border);
    padding: 1rem 1.5rem;
    display: flex;
    justify-content: center;
    gap: 2rem;
    flex-wrap: wrap;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    padding: 0.5rem 1.5rem;
    background: var(--color-bg-tertiary);
    border-radius: var(--border-radius-md);
    border: 1px solid var(--glass-border);
    min-width: 120px;
    transition: transform var(--transition-normal), box-shadow var(--transition-normal);
}

.stat-item:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    background: var(--color-accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.stat-label {
    font-size: 0.75rem;
    color: var(--color-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* =====================================================
   MAIN CONTENT
   ===================================================== */
.main-content {
    flex: 1;
    position: relative;
    display: flex;
}

#map {
    flex: 1;
    min-height: 500px;
    height: calc(100vh - 280px);
    z-index: 1;
}

/* =====================================================
   LEGEND
   ===================================================== */
.legend {
    position: absolute;
    bottom: 30px;
    left: 20px;
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: var(--border-radius-md);
    padding: 1rem;
    z-index: 1000;
    box-shadow: var(--shadow-md);
}

.legend h3 {
    font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
    color: var(--color-text-primary);
}

.legend-items {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8rem;
    color: var(--color-text-secondary);
}

.legend-circle {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.3);
}

.legend-circle.mag-low {
    background: var(--color-mag-low);
}

.legend-circle.mag-medium {
    background: var(--color-mag-medium);
}

.legend-circle.mag-high {
    background: var(--color-mag-high);
}

.legend-circle.mag-severe {
    background: var(--color-mag-severe);
}

/* =====================================================
   INFO MODAL
   ===================================================== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 3000;
    opacity: 1;
    transition: opacity var(--transition-normal);
}

.modal-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.modal-content {
    background: var(--color-bg-secondary);
    border: 1px solid var(--glass-border);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 2rem;
    max-width: 500px;
    width: 90%;
    position: relative;
    transform: translateY(0);
    transition: transform var(--transition-normal);
}

.modal-overlay.hidden .modal-content {
    transform: translateY(20px);
}

.close-modal {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: none;
    border: none;
    color: var(--color-text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
    transition: color var(--transition-fast);
}

.close-modal:hover {
    color: var(--color-text-primary);
}

.modal-content h2 {
    font-size: 1.5rem;
    margin-bottom: 1.5rem;
    color: var(--color-text-primary);
    background: var(--color-accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.modal-body {
    color: var(--color-text-secondary);
    line-height: 1.6;
}

.info-list {
    list-style: none;
    margin: 1.5rem 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.info-list li {
    display: flex;
    gap: 1rem;
    align-items: flex-start;
    padding: 0.75rem;
    background: var(--color-bg-tertiary);
    border-radius: var(--border-radius-sm);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.info-list .icon {
    font-size: 1.5rem;
    flex-shrink: 0;
}

.info-list strong {
    color: var(--color-text-primary);
    display: block;
    margin-bottom: 0.2rem;
}

.modal-footer-text {
    text-align: center;
    font-size: 0.8rem;
    color: var(--color-text-muted);
    margin-top: 1.5rem;
    border-top: 1px solid var(--glass-border);
    padding-top: 1rem;
}

/* =====================================================
   LOADING OVERLAY
   ===================================================== */
.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(10, 14, 23, 0.9);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    opacity: 1;
    transition: opacity var(--transition-normal);
}

.loading-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.loader {
    position: relative;
    width: 80px;
    height: 80px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.seismic-wave {
    position: absolute;
    width: 20px;
    height: 20px;
    background: var(--color-accent-primary);
    border-radius: 50%;
    animation: seismic 1.5s ease-out infinite;
}

.seismic-wave:nth-child(2) {
    animation-delay: 0.5s;
}

.seismic-wave:nth-child(3) {
    animation-delay: 1s;
}

@keyframes seismic {
    0% {
        transform: scale(0.5);
        opacity: 1;
    }

    100% {
        transform: scale(4);
        opacity: 0;
    }
}

.loading-overlay p {
    margin-top: 2rem;
    font-size: 1rem;
    color: var(--color-text-secondary);
}

/* =====================================================
   ERROR MESSAGE
   ===================================================== */
.error-message {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    border: 1px solid var(--color-danger);
    border-radius: var(--border-radius-md);
    padding: 2rem;
    text-align: center;
    z-index: 1500;
    display: none;
}

.error-message.visible {
    display: block;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.9);
    }

    to {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}

.error-icon {
    font-size: 3rem;
    display: block;
    margin-bottom: 1rem;
}

.error-message p {
    color: var(--color-text-secondary);
}

/* =====================================================
   POPUP ESTILOS (Leaflet customization)
   ===================================================== */
.leaflet-popup-content-wrapper {
    background: var(--glass-bg) !important;
    backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border) !important;
    border-radius: var(--border-radius-md) !important;
    box-shadow: var(--shadow-lg) !important;
    padding: 0 !important;
}

.leaflet-popup-content {
    margin: 0 !important;
    color: var(--color-text-primary) !important;
    font-family: var(--font-family) !important;
    min-width: 280px;
}

.leaflet-popup-tip {
    background: var(--glass-bg) !important;
    border: 1px solid var(--glass-border) !important;
}

.leaflet-popup-close-button {
    color: var(--color-text-secondary) !important;
    font-size: 24px !important;
    padding: 8px 12px !important;
    transition: color var(--transition-fast);
}

.leaflet-popup-close-button:hover {
    color: var(--color-text-primary) !important;
}

/* Custom Popup Content */
.earthquake-popup {
    padding: 1.25rem;
}

.popup-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--glass-border);
}

.popup-magnitude {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    font-weight: 700;
    color: white;
    flex-shrink: 0;
}

.popup-magnitude.mag-low {
    background: var(--color-mag-low);
}

.popup-magnitude.mag-medium {
    background: var(--color-mag-medium);
}

.popup-magnitude.mag-high {
    background: var(--color-mag-high);
}

.popup-magnitude.mag-severe {
    background: var(--color-mag-severe);
}

.popup-title {
    flex: 1;
}

.popup-title h4 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
    line-height: 1.3;
}

.popup-title span {
    font-size: 0.8rem;
    color: var(--color-text-secondary);
}

.popup-details {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

.popup-detail {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.popup-detail-label {
    font-size: 0.7rem;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.popup-detail-value {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--color-text-primary);
}

.popup-footer {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--glass-border);
    text-align: center;
}

.popup-link {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: var(--color-accent-gradient);
    color: white;
    text-decoration: none;
    border-radius: var(--border-radius-sm);
    font-size: 0.85rem;
    font-weight: 500;
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.popup-link:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(59, 130, 246, 0.4);
}

/* =====================================================
   FOOTER
   ===================================================== */
.footer {
    background: var(--color-bg-secondary);
    border-top: 1px solid var(--glass-border);
    padding: 1.5rem;
    text-align: center;
}

.footer p {
    font-size: 0.875rem;
    color: var(--color-text-secondary);
    margin-bottom: 0.5rem;
}

.footer a {
    color: var(--color-accent-primary);
    text-decoration: none;
    transition: color var(--transition-fast);
}

.footer a:hover {
    color: var(--color-accent-secondary);
}

.footer .disclaimer {
    font-size: 0.75rem;
    color: var(--color-text-muted);
}

/* =====================================================
   CUSTOM MARKERS
   ===================================================== */
.earthquake-marker {
    border-radius: 50%;
    border: 3px solid rgba(255, 255, 255, 0.5);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    transition: transform var(--transition-fast);
    cursor: pointer;
}

.earthquake-marker:hover {
    transform: scale(1.2);
    z-index: 1000 !important;
}

.earthquake-marker.recent {
    animation: marker-pulse 2s infinite;
}

@keyframes marker-pulse {

    0%,
    100% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7);
    }

    50% {
        box-shadow: 0 0 20px 10px rgba(239, 68, 68, 0);
    }
}

/* =====================================================
   RESPONSIVE
   ===================================================== */
.mobile-title {
    display: none;
    font-size: 1.25rem;
    font-weight: 700;
    background: var(--color-accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    width: 100%;
    text-align: center;
    margin-bottom: 0.5rem;
}

@media (max-width: 768px) {
    .header-content {
        justify-content: center;
        text-align: center;
    }

    .logo h1 {
        font-size: 1.25rem;
    }

    .header-info {
        width: 100%;
        justify-content: center;
    }

    .stats-bar {
        gap: 1rem;
        padding: 1rem;
    }

    .stat-item {
        min-width: 100px;
        padding: 0.5rem 1rem;
    }

    .stat-value {
        font-size: 1.25rem;
    }

    #map {
        height: calc(100vh - 320px);
    }

    .legend {
        bottom: 20px;
        left: 10px;
        right: 10px;
        max-width: none;
    }

    .legend-items {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: space-between;
    }

    .leaflet-popup-content {
        min-width: 250px;
    }

    .modal-content {
        width: 95%;
        padding: 1.5rem;
    }
}

@media (max-width: 480px) {
    .header-content {
        gap: 0.5rem;
    }

    .logo {
        flex-direction: column;
        gap: 0.5rem;
    }

    .stats-bar {
        display: grid;
        grid-template-columns: 1fr 1fr;
    }

    .stat-item {
        width: 100%;
    }

    .date-range {
        font-size: 0.75rem;
        padding: 0.4rem 0.8rem;
    }

    .title-container {
        align-items: center;
    }
}

/* =====================================================
   DARK MAP TILES STYLING
   ===================================================== */
.leaflet-tile-pane {
    filter: brightness(0.9) saturate(1.1);
}

/* Leaflet Control Styling */
.leaflet-control-zoom a {
    background: var(--glass-bg) !important;
    color: var(--color-text-primary) !important;
    border: 1px solid var(--glass-border) !important;
    backdrop-filter: blur(10px);
}

.leaflet-control-zoom a:hover {
    background: var(--color-bg-tertiary) !important;
}

.leaflet-control-attribution {
    background: var(--glass-bg) !important;
    color: var(--color-text-muted) !important;
    backdrop-filter: blur(10px);
}

.leaflet-control-attribution a {
    color: var(--color-accent-primary) !important;
}

/* Animación para la carga de ubicación */
.location-loading {
    display: inline-block;
    font-size: 0.8rem;
    color: var(--color-accent-primary);
    font-style: italic;
    animation: flash 1.5s infinite;
}

@keyframes flash {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

.original-region {
    display: block;
    font-size: 0.75rem;
    color: var(--color-text-muted);
    margin-top: 0.2rem;
    font-weight: normal;
}