/* --- assets/css/climaNew.css (V3 - FINAL) --- */

/* ==========================================================================
   1. LAYOUT PRINCIPAL Y HEADER
   ========================================================================== */
html,
body {
    overflow-x: hidden;
    /* Evitar scroll horizontal por animaciones que salen */
}

#header {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
}

#info-container {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    margin-top: 1rem;
}

#chartContainer {
    margin-top: 2rem;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 12px;
    padding: 1rem;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
    width: 100%;
    max-width: 1100px;
}

#iotChart {
    width: 100%;
    height: 400px;
}

/* ==========================================================================
   2. BANNER GEOGRÁFICO
   ========================================================================== */
.geo-capsule {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(5px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-bottom: 2px solid #1cb495;
    border-radius: 50px;
    padding: 10px 30px;
    margin-bottom: 2rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
    white-space: nowrap;
}

.geo-item {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #fff;
    font-size: 1rem;
    font-weight: 600;
}

.geo-item i {
    color: #f5c842;
    font-size: 1.1em;
}

.geo-divider {
    width: 1px;
    height: 18px;
    background-color: rgba(255, 255, 255, 0.3);
}

@media (max-width: 700px) {
    .geo-capsule {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 10px;
        padding: 12px;
        border-radius: 20px;
        width: 95%;
        height: auto;
    }

    .geo-divider {
        display: none;
    }
}

/* ==========================================================================
   3. TARJETAS DE DATOS (SENSOR)
   ========================================================================== */
.info-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    background-color: rgba(20, 20, 20, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 2rem;
    gap: 2rem;
    width: 100%;
    max-width: 1200px;
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.5);
    text-align: center;
}

.card-header {
    width: 100%;
    flex-basis: 100%;
    text-align: center;
    padding-bottom: 1.5rem;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.card-header h2 {
    color: #f5c842;
    font-size: 1.8em;
    margin: 0 0 0.2em 0;
    font-weight: 800;
    letter-spacing: 1px;
    text-transform: uppercase;
}

.card-header h3 {
    font-size: 0.9em;
    font-weight: 700;
    color: #fff;
    margin: 0;
}

.card-header h4 {
    font-size: 0.8em;
    color: rgba(255, 255, 255, 0.6);
    margin-top: 5px;
}

/* -- BLOQUES DE MÉTRICAS -- */
.info-block {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 120px;
    transition: transform 0.3s;
}

.info-block h1 {
    font-family: 'Roboto', sans-serif;
    font-size: 3.5em;
    font-weight: 900;
    color: #fff;
    margin: 0;
    line-height: 1;
    letter-spacing: -2px;
}

.info-block h1 .unit {
    font-size: 0.4em;
    color: rgba(255, 255, 255, 0.5);
    font-weight: 300;
    margin-left: 4px;
    vertical-align: top;
    position: relative;
    top: 0.1em;
}

.info-block h2 {
    font-size: 0.9em;
    color: #f5c842;
    margin: 0 0 8px 0;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* --- ESTILOS DE ALERTA Y FEATURED (RECUPERADOS) --- */
.text-danger {
    color: #ff3e4d !important;
    text-shadow: 0 0 15px rgba(255, 62, 77, 0.4);
}

.text-info {
    color: #3498db !important;
}

/* Cajas de Alerta (Borde Rojo/Azul) */
.alert-high {
    border: 2px solid #ff3e4d;
    background-color: rgba(255, 62, 77, 0.1);
    border-radius: 12px;
    padding: 10px;
    box-shadow: 0 0 15px rgba(255, 62, 77, 0.2);
}

.alert-low {
    border: 2px solid #3498db;
    background-color: rgba(52, 152, 219, 0.1);
    border-radius: 12px;
    padding: 10px;
}

/* Métrica Principal (Temperatura Grande) */
.featured-metric h1 {
    font-size: 5em !important;
    text-shadow: 0 0 20px rgba(255, 255, 255, 0.4), 0 0 10px rgba(255, 255, 255, 0.2);
    margin-bottom: 5px;
}

.featured-metric h1 .unit {
    font-size: 0.3em;
    top: 0.3em;
    color: #f5c842;
}

/* Sub-bloques */
.metrics-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    width: 100%;
}

.metric-sub-block {
    background-color: rgba(255, 255, 255, 0.03);
    border-radius: 12px;
    padding: 1.5rem;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.metric-sub-block h3 {
    text-align: center;
    color: #f5c842;
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: uppercase;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 0.8rem;
    margin-bottom: 1.5rem;
    letter-spacing: 1px;
}

.sub-block-grid {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 3rem;
}

@media (max-width: 768px) {
    .metrics-container {
        grid-template-columns: 1fr;
    }

    .info-block h1 {
        font-size: 2.5em;
    }
}

/* ==========================================================================
   4. ALERTA AEMET
   ========================================================================== */
.aemet-alert-card {
    width: 96%;
    max-width: 900px;
    background: rgba(10, 10, 10, 0.85);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 1.2rem;
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.5);
    animation: slideInAlert 0.6s ease-out;
    margin-bottom: 1rem;
}

@keyframes slideInAlert {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.aemet-level-amarillo {
    border-left: 4px solid #f1c40f;
}

.aemet-level-naranja {
    border-left: 4px solid #e67e22;
    animation: pulseBorderOrange 3s infinite;
}

.aemet-level-rojo {
    border-left: 4px solid #ff3e4d;
    animation: pulseBorderRed 2s infinite;
}

@keyframes pulseBorderOrange {
    50% {
        border-left-color: #d35400;
    }
}

@keyframes pulseBorderRed {
    50% {
        border-left-color: #c0392b;
        box-shadow: 0 0 20px rgba(255, 62, 77, 0.3) inset;
    }
}

.aemet-title {
    font-weight: 800;
    text-transform: uppercase;
    display: flex;
    gap: 10px;
    font-size: 1.1rem;
}

.aemet-level-amarillo .aemet-title {
    color: #f1c40f;
}

.aemet-level-naranja .aemet-title {
    color: #e67e22;
}

.aemet-level-rojo .aemet-title {
    color: #ff3e4d;
}

.aemet-body {
    display: flex;
    flex-wrap: wrap;
    gap: 2rem;
    font-size: 0.9rem;
    color: #ddd;
    align-items: center;
}

.zone-badge {
    font-size: 0.75rem;
    background: rgba(255, 255, 255, 0.15);
    padding: 3px 8px;
    border-radius: 4px;
    color: #fff;
}

/* ==========================================================================
   5. METEOBOT AI & ROBOT AVATAR (RECUPERADO COMPLETO)
   ========================================================================== */
#ai-container {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-top: 1rem;
}

.info-row.ai-card {
    width: 96%;
    max-width: 1200px;
    border-left: 4px solid #f5c842;
    background: rgba(15, 15, 15, 0.9);
    align-items: center;
    text-align: left;
    padding: 1rem;
    min-height: auto;
}

.ai-layout {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    width: 100%;
}

.ai-header {
    display: flex;
    justify-content: space-between;
    border-bottom: 1px solid rgba(245, 200, 66, 0.3);
    width: 100%;
    color: #f5c842;
    font-family: 'Courier New', monospace;
    font-weight: bold;
    margin-bottom: 5px;
}

.ai-body p {
    font-family: 'Courier New', monospace;
    color: #e0e0e0;
    margin: 0;
    font-size: 1rem;
    line-height: 1.5;
}

.ai-body p::after {
    content: '▋';
    animation: blink 1s step-end infinite;
    color: #f5c842;
}

@keyframes blink {
    50% {
        opacity: 0;
    }
}

/* --- AVATAR ROBOT (COMPLETO) --- */
.bot-avatar {
    width: 50px;
    height: 50px;
    min-width: 50px;
    background: #1a1a1a;
    border: 2px solid #f5c842;
    border-radius: 10px;
    position: relative;
    box-shadow: 0 0 10px rgba(245, 200, 66, 0.2);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: transform 0.3s;
}

.bot-avatar::after {
    content: '';
    position: absolute;
    top: -8px;
    left: 50%;
    transform: translateX(-50%);
    width: 4px;
    height: 4px;
    background: #f5c842;
    border-radius: 50%;
    animation: pulseAntenna 2s infinite;
}

.bot-eyes {
    display: flex;
    gap: 8px;
    margin-bottom: 5px;
}

.eye {
    width: 8px;
    height: 8px;
    background: #f5c842;
    animation: blinkEye 4s infinite;
    border-radius: 1px;
}

.bot-mouth {
    width: 18px;
    height: 3px;
    background: #f5c842;
    border-radius: 2px;
}

/* Animación de Giro (Click) */
.bot-spin {
    animation: spinBot 0.5s ease-in-out;
}

@keyframes spinBot {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* Estados de Ánimo */
.mode-danger {
    border-color: #ff3e4d;
    box-shadow: 0 0 15px rgba(255, 62, 77, 0.5);
}

.mode-danger .eye,
.mode-danger .bot-mouth,
.mode-danger::after {
    background: #ff3e4d;
}

.mode-sleep {
    border-color: #555;
}

.mode-sleep .eye {
    height: 2px;
    background: #555;
    animation: none;
}

/* Modo Crash (Error) */
.bot-avatar.mode-crash {
    border-color: #00a8ff !important;
    background: #000044 !important;
    box-shadow: 0 0 15px #00a8ff !important;
    transform: scale(0.95);
}

.bot-avatar.mode-crash .eye {
    background: transparent;
    box-shadow: none;
    width: 8px;
    height: 8px;
    border-radius: 0;
    transform: rotate(0deg);
    animation: none;
}

.bot-avatar.mode-crash .eye::before,
.bot-avatar.mode-crash .eye::after {
    content: '';
    position: absolute;
    background: #00a8ff;
    border-radius: 1px;
}

.bot-avatar.mode-crash .eye::before {
    width: 100%;
    height: 2px;
    top: 50%;
    left: 0;
    transform: translateY(-50%) rotate(45deg);
}

.bot-avatar.mode-crash .eye::after {
    width: 100%;
    height: 2px;
    top: 50%;
    left: 0;
    transform: translateY(-50%) rotate(-45deg);
}

.bot-avatar.mode-crash .bot-mouth {
    background: #00a8ff;
    width: 18px;
    height: 2px;
    border-radius: 0;
    margin-top: 2px;
}

@keyframes pulseAntenna {
    50% {
        opacity: 1;
        box-shadow: 0 0 8px #f5c842;
    }
}

@keyframes blinkEye {
    97% {
        transform: scaleY(0.1);
    }
}

/* ==========================================================================
   6. JUGUETES INTERACTIVOS (CULIS, LÁSER, AGUJERO NEGRO)
   ========================================================================== */
#toy-container {
    position: fixed;
    bottom: 50px;
    right: 30px;
    z-index: 10000;
    pointer-events: none;
    display: flex;
    justify-content: center;
    align-items: flex-end;
}

.interactive-toy {
    font-size: 2.5rem;
    cursor: pointer;
    pointer-events: auto;
    color: #aaa;
    transition: color 0.3s;
    user-select: none;
    z-index: 10001;
}

.interactive-toy:hover {
    color: #fff;
    text-shadow: 0 0 10px #fff;
}

/* El Cohete */
.toy-rocket {
    transform: rotate(-45deg);
    animation: engineIdle 0.2s infinite alternate;
}

@keyframes engineIdle {
    0% {
        transform: rotate(-45deg) translateY(0px);
    }

    100% {
        transform: rotate(-45deg) translateY(1px);
    }
}

/* Objetivos (Culis) */
.culi-target {
    position: absolute;
    width: 40px;
    z-index: 9998;
    cursor: crosshair;
    animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes popIn {
    0% {
        transform: scale(0) rotate(0deg);
        opacity: 0;
    }

    100% {
        transform: scale(1) rotate(10deg);
        opacity: 1;
    }
}

/* Culi Dorado (Gira Locamente) */
.culi-target.golden {
    width: 50px !important;
    filter: sepia(100%) saturate(1000%) hue-rotate(360deg) brightness(1.2) drop-shadow(0 0 10px #ffd700);
    z-index: 9999;
    animation: popIn 0.3s ease-out, spinCrazy 2s linear infinite !important;
}

@keyframes spinCrazy {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* Culi Oscuro (Glitch) */
.culi-target.dark {
    width: 40px !important;
    filter: invert(1) hue-rotate(180deg) drop-shadow(0 0 8px #9c27b0);
    z-index: 9999;
    animation: popIn 0.3s ease-out, glitchShake 0.2s infinite !important;
}

@keyframes glitchShake {
    0% {
        transform: translate(1px, 1px) rotate(0deg);
    }

    25% {
        transform: translate(-1px, -2px) rotate(-1deg);
    }

    50% {
        transform: translate(-3px, 0px) rotate(1deg);
    }

    75% {
        transform: translate(3px, 2px) rotate(-1deg);
    }

    100% {
        transform: translate(1px, -1px) rotate(0deg);
    }
}

/* Explosión */
.culi-explosion {
    position: absolute;
    width: 50px;
    height: 50px;
    background: radial-gradient(circle, #ffeb3b, transparent 70%);
    border-radius: 50%;
    animation: boom 0.3s ease-out forwards;
    z-index: 9999;
}

@keyframes boom {
    0% {
        transform: scale(0.5);
        opacity: 1;
    }

    100% {
        transform: scale(3);
        opacity: 0;
    }
}

/* Láser del Robot */
.laser-beam {
    position: absolute;
    height: 4px;
    background: #ff3e4d;
    box-shadow: 0 0 5px #ff3e4d, 0 0 10px #ff3e4d, 0 0 20px #fff;
    z-index: 9997;
    transform-origin: 0 50%;
    pointer-events: none;
    animation: laserFlash 0.3s ease-out forwards;
}

@keyframes laserFlash {
    0% {
        width: 0;
        opacity: 1;
    }

    20% {
        width: 100%;
        opacity: 1;
    }

    100% {
        width: 100%;
        opacity: 0;
    }
}

/* Agujero Negro */
#black-hole {
    position: fixed;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    background: radial-gradient(circle, #000 0%, #1a0033 40%, #9c27b0 70%, transparent 72%);
    box-shadow: 0 0 50px #9c27b0;
    z-index: 20000;
    pointer-events: none;
    transition: width 0.5s ease-out, height 0.5s ease-out;
}

#black-hole.active {
    width: 150vmax;
    height: 150vmax;
    animation: holeSpin 4s linear infinite;
    opacity: 0.95;
}

@keyframes holeSpin {
    0% {
        transform: translate(-50%, -50%) rotate(0deg);
    }

    100% {
        transform: translate(-50%, -50%) rotate(360deg);
    }
}

.sucked-in {
    transition: all 0.8s cubic-bezier(0.55, 0.055, 0.675, 0.19) !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) scale(0) rotate(720deg) !important;
    opacity: 0;
}

/* ==========================================================================
   7. CONTROLES Y SELECTORES
   ========================================================================== */
.controls-row {
    display: grid;
    grid-template-columns: minmax(220px, 1fr) minmax(260px, 1fr) minmax(420px, 2fr) auto;
    column-gap: 1.5rem;
    row-gap: 1rem;
    align-items: end;
    justify-items: center;
    max-width: 1100px;
    margin: 2rem auto 0 auto;
    width: 100%;
}

.control {
    display: grid;
    grid-template-columns: 100px 1fr;
    align-items: center;
    width: 100%;
}

.control label {
    text-align: right;
    margin-right: 15px;
    color: #f5c842;
    font-weight: bold;
    font-size: 0.9rem;
}

.metric-group {
    display: flex !important;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.metric-chip input {
    display: none;
}

.metric-chip label {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 36px;
    padding: 0 16px;
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.7);
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
}

.metric-chip label:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

.metric-chip input:checked+label {
    background: rgba(28, 180, 149, 0.25);
    border-color: #1cb495;
    color: #fff;
    box-shadow: 0 0 10px rgba(28, 180, 149, 0.4);
    font-weight: bold;
}

.select-wrapper {
    position: relative;
    width: 100%;
}

select {
    width: 100%;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    color: #fff;
    padding: 0.7rem 1rem;
    outline: none;
    font-size: 0.95rem;
    appearance: none;
    cursor: pointer;
}

select:hover {
    border-color: #f5c842;
}

select option {
    background: #1b1b1b;
}

#btnLoadStats {
    background: #1cb495;
    color: #000;
    border: none;
    border-radius: 8px;
    height: 44px;
    padding: 0 25px;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-weight: 800;
    text-transform: uppercase;
    font-family: 'Roboto', sans-serif;
    transition: all 0.3s ease;
}

#btnLoadStats:hover {
    background: #fff;
    box-shadow: 0 0 15px rgba(28, 180, 149, 0.5);
}

@media (max-width: 900px) {
    .controls-row {
        grid-template-columns: 1fr 1fr;
    }

    .metric-panel,
    .control-button {
        grid-column: 1 / span 2;
        justify-self: center;
        width: 100%;
    }

    .control {
        grid-template-columns: 1fr;
        gap: 5px;
    }

    .control label {
        text-align: left;
    }
}

/* ==========================================================================
   8. VENTANA EMERGENTE (MODAL GLOSARIO)
   ========================================================================== */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.85);
    z-index: 3000;
    backdrop-filter: blur(5px);
    overflow: auto;
    animation: fadeInModal 0.3s ease-out;
}

@keyframes fadeInModal {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.modal-content {
    background-color: #151515;
    margin: 5% auto;
    padding: 2rem;
    border: 1px solid #1cb495;
    border-radius: 12px;
    width: 90%;
    max-width: 900px;
    box-shadow: 0 0 50px rgba(0, 0, 0, 0.8);
    position: relative;
    color: #e0e0e0;
}

.modal-content h2 {
    color: #fff;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 10px;
}

.close-modal {
    position: absolute;
    top: 15px;
    right: 20px;
    color: #aaa;
    font-size: 2rem;
    cursor: pointer;
    line-height: 0.8;
    z-index: 10;
}

.close-modal:hover {
    color: #ff3e4d;
}

.glossary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 1.5rem;
    text-align: left;
}

.glossary-item {
    background: rgba(255, 255, 255, 0.05);
    padding: 1.2rem;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.glossary-item h3 {
    color: #1cb495;
    margin-bottom: 0.5rem;
    font-weight: bold;
    font-size: 1.1rem;
}

.glossary-item p {
    font-size: 0.9em;
    color: #ccc;
    line-height: 1.5;
    margin: 0;
}

#btnOpenGlossary {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 36px;
    padding: 0 20px;
    margin: 0 auto 1.5rem auto;
    font-size: 0.8rem;
    border-radius: 50px;
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: #ccc;
    cursor: pointer;
    transition: all 0.3s;
}

#btnOpenGlossary:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    border-color: #fff;
}

/* ==========================================================================
   9. EXTRAS: BADGE (Robé)
   ========================================================================== */
#eventBadge {
    position: fixed;
    top: 20px;
    left: 20px;
    z-index: 990;
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(4px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 10px 15px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
}

#eventBadge:hover {
    transform: scale(1.05);
    background: rgba(0, 0, 0, 0.6);
    border-color: rgba(255, 255, 255, 0.3);
}

.badge-icon i {
    font-size: 2.2rem;
    margin-bottom: 4px;
}

.event-badge.mode-mourning .badge-icon i {
    color: #e0e0e0;
}

.badge-text span {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    color: #ccc;
}

.event-badge.playing .badge-icon i {
    color: #fff;
    animation: musicPulse 1.5s infinite;
}

@keyframes musicPulse {
    50% {
        transform: scale(1.2);
        text-shadow: 0 0 15px rgba(255, 255, 255, 0.8);
    }
}