/* ===========================
   ESTILOS GENERALES
=========================== */

body {
    margin: 0;
    font-family: "Inter", Arial, sans-serif;
    background: linear-gradient(180deg, #0a1f2f 0%, #0d2e3a 50%, #0f3f46 100%);
    color: #e6faff;
}

/* ===========================
   CABECERA NUEVA
=========================== */

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 28px;
    background: radial-gradient(circle at top left, #1e3a8a 0%, #0d2e3a 55%, #082026 100%);
    border-bottom: 1px solid rgba(255, 255, 255, 0.10);
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.45);
    position: sticky;
    top: 0;
    z-index: 100;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 14px;
}

.logo-img {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    object-fit: cover;
    padding: 6px;
    background: rgba(0, 0, 0, 0.85);
    border: 2px solid rgba(255, 255, 255, 0.55);
    box-shadow:
        0 0 12px rgba(255, 255, 255, 0.35),
        0 0 18px rgba(34, 197, 94, 0.35); /* verde suave */
}

.topbar-title h1 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
}

.topbar-title span {
    display: block;
    margin-top: 2px;
    font-size: 12px;
    color: rgba(226, 242, 255, 0.75);
}

/* ===========================
   NAVEGACIÓN
=========================== */

.topbar-nav {
    display: flex;
    gap: 8px;
}

.nav-btn {
    padding: 10px 18px;
    border-radius: 8px;
    background: transparent;
    border: 1px solid rgba(255,255,255,0.18);
    color: #d9faff;
    cursor: pointer;
    transition: all 0.25s ease;
    font-size: 14px;
}

.nav-btn:hover {
    background: rgba(255,255,255,0.10);
    transform: translateY(-1px);
    border-color: rgba(255,255,255,0.25);
}

.nav-btn.active {
    background: linear-gradient(90deg, #3b82f6, #22c55e); /* azul → verde */
    color: white;
    border-color: transparent;
    box-shadow: 0 0 12px rgba(34,197,94,0.45), 0 0 18px rgba(59,130,246,0.35);
    transform: translateY(-1px);
}

/* ===========================
   SECCIONES
=========================== */

.section {
    animation: fadeSection 0.35s ease;
}

@keyframes fadeSection {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

.section {
    display: none;
    padding: 20px 28px;
}

.section.visible {
    display: block;
}

/* ===========================
   TARJETAS Y CONTENIDO
=========================== */

#cards-container {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 10px;
    margin-top: 15px;
}

/* ===========================
   TARJETAS MODERNAS
=========================== */

.card {
    background: linear-gradient(135deg, #0f2f3a 0%, #134e4a 100%); /* azul verdoso */
    padding: 8px 10px;
    border-radius: 8px;
    box-shadow: 0 0 6px rgba(0,0,0,0.25);
    color: #e0faff;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.card:hover {
    transform: translateY(-3px);
    box-shadow: 0 0 12px rgba(0,150,136,0.35); /* verde agua */
}

.card-title {
    font-size: 0.85rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 4px;
    margin-bottom: 2px;
}

.card-value {
    font-size: 1.1rem;
    font-weight: bold;
    line-height: 1.1;
}

.card-icon {
    font-size: 22px;
}

/* Colores según tipo */
.card-et0 { border-left: 5px solid #22c55e; }
.card-estres { border-left: 5px solid #4ade80; }
.card-humedad { border-left: 5px solid #3b82f6; }

.card-temp { border-left: 5px solid #0ea5e9; }
.card-rad { border-left: 5px solid #38bdf8; }
.card-viento { border-left: 5px solid #22d3ee; }

.card-dir { border-left: 5px solid #14b8a6; }
.card-presion { border-left: 5px solid #16a34a; }
.card-nubes { border-left: 5px solid #60a5fa; }
.card-lluvia { border-left: 5px solid #0284c7; }


/* ===========================
   GRAFICOS
=========================== */

/* GRÁFICAS EN FILA */
.graficas-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 22px;
    margin-top: 20px;
}

/* TARJETAS DE GRÁFICA */
.grafica-card {
    background: linear-gradient(135deg, rgba(14,165,233,0.12), rgba(34,197,94,0.12));
    padding: 20px;
    border-radius: 18px;
    border: 1px solid rgba(59,130,246,0.25); /* azul suave */
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45);
}

/* CANVAS */
.grafica-card canvas {
    width: 100% !important;
    height: 260px !important;
}

/* PANEL IA */
.panel-ia {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 18px;
    margin-top: 30px;
}

.panel-ia-card {
    background: linear-gradient(135deg, rgba(14,165,233,0.10), rgba(34,197,94,0.10));
    padding: 18px;
    border-radius: 16px;
    border: 1px solid rgba(34,197,94,0.25); /* verde suave */
    box-shadow: 0 8px 22px rgba(0,0,0,0.35);
    display: flex;
    gap: 12px;
    align-items: center;
}

.panel-ia-icono {
    font-size: 32px;
    color: #3b82f6; /* azul cielo */
}

/* ===========================
   RECOMENDACIONES
=========================== */

/* Título */
#recomendaciones h2 {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 10px;
    color: #a7f3d0; /* verde menta */
}

/* Grid */
#recs-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 14px;
    margin-top: 10px;
}

/* Card premium */
.recomendacion-card {
    padding: 16px 18px;
    border-radius: 14px;
    background: rgba(13, 42, 56, 0.85); /* azul profundo */
    border: 1px solid rgba(59,130,246,0.25); /* azul suave */
    display: flex;
    gap: 14px;
    align-items: flex-start;
    animation: fadeIn 0.4s ease;
}

/* Icono grande */
.recomendacion-icono {
    font-size: 26px;
    margin-top: 2px;
    color: #22c55e; /* verde */
}

/* Texto */
.recomendacion-texto {
    font-size: 15px;
    line-height: 1.45;
    color: #e0faff;
}

/* Colores según prioridad */
.rec-verde   { border-left: 4px solid #22c55e; background: rgba(34,197,94,0.18); }
.rec-amarillo{ border-left: 4px solid #eab308; background: rgba(234,179,8,0.18); }
.rec-naranja { border-left: 4px solid #f97316; background: rgba(249,115,22,0.18); }
.rec-rojo    { border-left: 4px solid #ef4444; background: rgba(239,68,68,0.18); }
.rec-morado  { border-left: 4px solid #a855f7; background: rgba(168,85,247,0.18); }

/* Animación */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Texto explicativo dentro de cada recomendación */
.recomendacion-base,
.recomendacion-razon {
    font-size: 14px;
    opacity: 0.85;
    margin-top: 6px;
    line-height: 1.4;
    color: #d9faff;
}

.recomendacion-base em,
.recomendacion-razon em {
    font-style: normal;
    font-weight: 600;
    color: #22c55e; /* verde */
}

.recomendacion-card strong {
    display: block;
    font-size: 15px;
    margin-bottom: 4px;
    color: #a7f3d0; /* verde menta */
}


/* ===========================
   ALERTAS
=========================== */

.alertas-wrapper {
    margin-top: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.alerta {
    padding: 14px;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(59,130,246,0.25); /* azul suave */
    background: linear-gradient(135deg, rgba(14,165,233,0.12), rgba(34,197,94,0.12));
}

.alerta-icono {
    font-size: 20px;
    color: #3b82f6; /* azul cielo */
}

.alerta-verde   { background: rgba(34,197,94,0.25); border-left: 4px solid #22c55e; }
.alerta-amarillo{ background: rgba(234,179,8,0.25); border-left: 4px solid #eab308; }
.alerta-naranja { background: rgba(249,115,22,0.25); border-left: 4px solid #f97316; }
.alerta-rojo    { background: rgba(239,68,68,0.25); border-left: 4px solid #ef4444; }
.alerta-azul    { background: rgba(59,130,246,0.25); border-left: 4px solid #3b82f6; }

.sin-alertas {
    opacity: 0.7;
    font-style: italic;
}


/* ===========================
   RIESGO ACUMULADO
=========================== */

#riesgo h2 {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 6px;
    color: #a7f3d0; /* verde menta */
}

.subtitulo-seccion {
    opacity: 0.8;
    margin-bottom: 18px;
    color: #d9faff;
}

#riesgo-bar {
    width: 100%;
    height: 22px;
    background: rgba(59,130,246,0.20); /* azul suave */
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 8px;
}

#riesgo-bar-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #22c55e, #3b82f6); /* verde → azul */
    transition: width 0.6s ease;
}

#riesgo-bar-text {
    font-size: 14px;
    opacity: 0.9;
    margin-bottom: 20px;
    color: #e0faff;
}

#riesgo-detalles {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 14px;
}

.riesgo-card {
    padding: 14px 16px;
    border-radius: 12px;
    background: rgba(13,42,56,0.85); /* azul profundo */
    border: 1px solid rgba(59,130,246,0.25);
    animation: fadeIn 0.4s ease;
    color: #e0faff;
}

.riesgo-card h3 {
    margin-bottom: 6px;
    font-size: 16px;
    font-weight: 600;
    color: #a7f3d0; /* verde menta */
}

.riesgo-card p {
    font-size: 14px;
    opacity: 0.85;
    color: #d9faff;
}


/* ===========================
   BOTÓN PDF
=========================== */

.btn-pdf {
    padding: 12px 26px;
    background: linear-gradient(90deg, #3b82f6, #22c55e);
    border: none;
    border-radius: 8px;
    color: white;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.25s ease;
    box-shadow: 0 0 12px rgba(34,197,94,0.45), 0 0 18px rgba(59,130,246,0.35);
}

.btn-pdf:hover {
    transform: translateY(-2px);
    box-shadow: 0 0 18px rgba(34,197,94,0.55), 0 0 24px rgba(59,130,246,0.45);
}


/* ===========================
   BOTÓN APAGAR
=========================== */

.nav-btn-apagar-round {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: linear-gradient(135deg, #ef4444, #dc2626);
    border: none;
    color: white;
    font-size: 20px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    padding: 0;
    transform: translateY(1px);
    transition: all 0.25s ease;
    box-shadow: 0 0 12px rgba(239,68,68,0.45), 0 0 18px rgba(220,38,38,0.35);
}

.nav-btn-apagar-round:hover {
    transform: translateY(-1px) scale(1.05);
    box-shadow: 0 0 18px rgba(239,68,68,0.55), 0 0 24px rgba(220,38,38,0.45);
}

.nav-btn-apagar-round:active {
    transform: scale(0.92);
}


/* ============================================
   ESTILO PREMIUM PARA INFORME AGRONÓMICO
   (solo estética, no rompe nada)
============================================ */

/* ===================================================
   CONTENEDOR GENERAL
====================================================== */
#informe-contenido {
    font-family: "Inter", "Segoe UI", sans-serif;
    line-height: 1.6;
    color: #1f2937;
    padding: 30px;
    background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
    border-radius: 18px;
    box-shadow: 0 6px 22px rgba(0,0,0,0.08);
    max-width: 900px;
    margin: 0 auto;
}

/* ===================================================
   CABECERA Y TÍTULOS
====================================================== */
.informe-titulo {
    font-size: 34px;
    font-weight: 800;
    text-align: center;
    margin-bottom: 6px;
    color: #0f172a;
    letter-spacing: -0.5px;
}

.informe-subtitulo {
    text-align: center;
    font-size: 15px;
    color: #64748b;
    margin-bottom: 35px;
}

/* ===================================================
   ESTRUCTURA DE DOS COLUMNAS (GRID MODERNO)
====================================================== */
.informe-grid {
    display: flex;
    gap: 20px;
    width: 100%;
    margin-top: 0px;
}

.informe-columna {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 20px; /* Controla la separación vertical dentro de las columnas */
}

/* ===================================================
   TARJETAS DE SECCIÓN (ESTILO BASE)
====================================================== */
.informe-seccion {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    padding: 22px 26px;
    border-radius: 14px;
    margin-bottom: 20px; /* Margen por defecto para bloques fuera del grid */
    box-shadow: 0 3px 10px rgba(0,0,0,0.04);
    transition: 0.2s ease;
}

/* Las secciones dentro del grid no necesitan margen inferior propio, lo maneja el contenedor */
.informe-columna .informe-seccion {
    margin-bottom: 0 !important;
}

.informe-seccion:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(0,0,0,0.08);
}

.informe-seccion h3 {
    margin-top: 0;
    margin-bottom: 14px;
    font-size: 20px;
    font-weight: 700;
    color: #0f172a;
    border-left: 5px solid #3b82f6;
    padding-left: 12px;
}

.informe-seccion p {
    margin: 0;
    font-size: 15px;
    color: #334155;
}

/* Formatos de texto específicos */
.informe-seccion strong {
    color: #0f172a;
    font-weight: 700;
}

.informe-seccion p br {
    line-height: 1.9;
}

/* Aseguramos que el indicador de riesgo grande mantenga tu color verde */
.indicador-riesgo-box .valor-riesgo {
    color: #16a34a !important;
    font-size: 32px !important;
    font-weight: 800;
    text-align: center;
    margin-top: 15px;
}

/* Variación para la caja de alertas */
.alertas-caja {
    margin-top: 20px;
    margin-bottom: 0 !important;
}

/* ===================================================
   LOGOS Y BOTONES
====================================================== */

.btn-pdf {
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    color: white;
    border: none;
    padding: 10px 18px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 15px;
    font-weight: 600;
    transition: 0.2s ease;
    margin-bottom: 20px;
}

.btn-pdf:hover {
    background: linear-gradient(135deg, #1d4ed8, #1e40af);
    transform: translateY(-1px);
}

/* ===================================================
   ASIGNACIÓN DE COLORES HISTÓRICOS POR SECCIÓN
====================================================== */
/* 1. Resumen Ejecutivo (Fuera del grid) */
#informe-contenido > .informe-seccion:nth-of-type(1) {
    background: #f0f9ff;
    border-left: 5px solid #38bdf8;
}

/* Columna Izquierda */
.informe-columna:nth-child(1) .informe-seccion:nth-of-type(1) { background: #fefce8; border-left: 5px solid #facc15; } /* Análisis del Mes */
.informe-columna:nth-child(1) .informe-seccion:nth-of-type(2) { background: #f0fdf4; border-left: 5px solid #4ade80; } /* Tendencias Climáticas */
.informe-columna:nth-child(1) .informe-seccion:nth-of-type(3) { background: #ecfdf5; border-left: 5px solid #34d399; } /* Riesgo Agronómico Acumulado */

/* Columna Derecha */
.informe-columna:nth-child(2) .informe-seccion:nth-of-type(1) { background: #fef2f2; border-left: 5px solid #f87171; } /* Resumen Mensual Real */
.informe-columna:nth-child(2) .informe-seccion:nth-of-type(2) { background: #f5f3ff; border-left: 5px solid #a78bfa; } /* Recomendaciones Estratégicas */

/* Alertas Relevantes (Fuera del grid, al final) */
.alertas-caja {
    background: #fff7ed !important;
    border-left: 5px solid #fb923c !important;
}


/* ===================================================
   OPTIMIZACIÓN DE IMPRESIÓN (FORZADO A 1 PÁGINA A4)
====================================================== */
@media print {
    #informe-contenido {
        font-size: 12px !important;
        line-height: 1.3 !important;
        padding: 0 !important;
        box-shadow: none !important;
        background: transparent !important;
    }

    /* Mantenemos estrictamente las dos columnas en el PDF */
    .informe-grid {
        display: flex !important;
        flex-direction: row !important;
        gap: 12px !important;
        margin-top: 10px !important;
    }

    .informe-columna {
        flex: 1 !important;
        display: flex !important;
        flex-direction: column !important;
        gap: 12px !important;
    }

    /* Reducción de espacios para compresión en una página */
    .informe-seccion {
        margin-bottom: 0 !important;
        padding: 12px 16px !important;
        border-radius: 8px !important;
        page-break-inside: avoid !important; /* Evita roturas feas */
    }

    .alertas-caja {
        margin-top: 12px !important;
    }

    .informe-seccion h3 {
        font-size: 14px !important;
        margin-bottom: 6px !important;
        padding-left: 8px !important;
    }

    .informe-seccion p {
        font-size: 12px !important;
    }

    .informe-titulo {
        font-size: 22px !important;
        margin-bottom: 4px !important;
    }

    .informe-subtitulo {
        font-size: 11px !important;
        margin-bottom: 15px !important;
    }

    .indicador-riesgo-box .valor-riesgo {
        font-size: 22px !important;
        margin-top: 5px !important;
    }

}