/*
#floatingChart {
    display: none;
    position: absolute;
    bottom: 80px;
    right: 20px;
    width: 50%;
    height: 450px;
    background: white;
    border-radius: 10px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.3);
    z-index: 1051;
    padding: 10px;
    border: 1px solid #ccc;
    cursor: grab;
}

#floatingChart.dragging {
    cursor: grabbing;
}

#chartHeader {
    cursor: grab;
    user-select: none;
}
*/

#floatingChart {
    display: none;
    position: absolute;
    bottom: 80px;
    right: 20px;
    width: 55%;               /* Un poco más amplio para el dashboard */
    max-height: 80vh;          /* Crece hasta el 80% de la altura de la pantalla */
    height: auto;              /* Se adapta al contenido automáticamente */
    background: white;
    border-radius: 10px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.3);
    z-index: 1051;
    padding: 15px;
    border: 1px solid #ccc;
    
    /* Habilitar scroll interno suave */
    overflow-y: auto;
    overflow-x: hidden;
}

/* Fijar el encabezado en la parte superior al hacer scroll (Sticky) */
#chartHeader {
    cursor: grab;
    user-select: none;
    position: sticky;
    top: 0;
    background: #ffffff;
    z-index: 10;
    padding-bottom: 5px;
    border-bottom: 1px solid #eee;
}

#chartHeader:active {
    cursor: grabbing;
}

/* Estilos para limpiar la toolbar extendida */
.state-toolbar {
    margin-top: 5px;
    margin-bottom: 10px;
    padding: 8px;
    background-color: #f8f9fa;
    border-radius: 6px;
}

/* Ajuste de altura dinámica para el contenedor de la gráfica */
#chartContainer {
    min-height: 350px;
    width: 100%;
}

/* --- Aislamiento del Dashboard de Temperatura --- */

.temp-dash-wrapper {
    background-color: #f4f6f9;
    padding: 20px;
    border-radius: 0 0 10px 10px;
    color: #2c3e50;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* Toolbar Azul Oscuro Superior */
.temp-dash-nav {
    background-color: #1a365d;
    color: #ffffff;
    padding: 14px 20px;
    border-radius: 8px 8px 0 0;
}

.temp-dash-nav-inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.temp-dash-nav-title {
    font-size: 1.3rem !important;
    font-weight: 700 !important;
    color: #ffffff !important;
    margin: 0 !important;
    line-height: 1.2;
}

.temp-dash-nav-subtitle {
    font-size: 0.75rem;
    color: #cbd5e0;
}

/* Botones de la Toolbar */
.temp-dash-btn {
    font-size: 0.8rem;
    font-weight: 600;
    padding: 6px 14px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.temp-dash-btn-light {
    background-color: #ffffff;
    color: #1a365d;
    border: none;
    margin-right: 8px;
}

.temp-dash-btn-light:hover {
    background-color: #edf2f7;
}

.temp-dash-btn-outline {
    background-color: transparent;
    color: #ffffff;
    border: 1px solid #ffffff;
}

.temp-dash-btn-outline:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

/* Títulos del Dashboard */
.temp-dash-header {
    margin-bottom: 24px;
}

/* Etiquetas de Sección (VISIÓN GENERAL, CAMBIO CLIMÁTICO, ETC) */
.temp-dash-section-tag {
    display: block;
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    color: #4a5568;
    margin: 24px 0 12px 0;
    text-transform: uppercase;
}

/* Tarjetas (Cards Blancas) */
.temp-dash-card {
    background: #ffffff;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
    border: 1px solid #e2e8f0;
}

.temp-dash-card-header {
    margin-bottom: 15px;
}

.temp-dash-card-title {
    font-size: 1.15rem !important;
    font-weight: 700 !important;
    color: #1a202c !important;
    margin: 0 0 4px 0 !important;
}

.temp-dash-card-sub {
    font-size: 0.8rem;
    color: #718096;
    margin: 0;
}

/* Grillas KPI e Indicadores */
.temp-dash-kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
}

.temp-dash-kpi-card {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 12px 16px;
}

/* Cajas de Gráficos */
.temp-dash-chart-box {
    width: 100%;
    min-height: 280px;
}

/* Controles e Inputs */
.temp-dash-controls label {
    font-size: 0.8rem;
    color: #4a5568;
    font-weight: 600;
}

.temp-dash-input {
    width: 70px;
    padding: 3px 6px;
    border: 1px solid #cbd5e0;
    border-radius: 4px;
    font-size: 0.8rem;
}

/* Corregir posición del header para que no se flote ni traslape */
header.temp-dash-header {
    position: relative !important;
    top: auto !important;
    left: auto !important;
    transform: none !important;
    margin-top: 15px !important;
    margin-bottom: 20px !important;
    padding: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    z-index: 1 !important;
    display: block !important;
}

.temp-dash-main-title {
    font-size: 1.5rem !important;
    font-weight: 800 !important;
    color: #1a202c !important;
    margin: 0 0 6px 0 !important;
    line-height: 1.2 !important;
}

.temp-dash-main-desc {
    font-size: 0.88rem !important;
    color: #718096 !important;
    margin: 0 !important;
    line-height: 2 !important;
}

/* --- CORRECCIÓN DE TARJETAS E INDICADORES EN EL DASHBOARD --- */
.indicator {
    display: flex !important;
    flex-direction: column !important;
    gap: 4px !important;
    padding: 12px 14px !important;
    background: #fbfdff !important;
    border: 1px solid #e2e8f0 !important;
    border-radius: 10px !important;
}

.indicator span {
    display: block !important;
    font-size: 12px !important;
    font-weight: 700 !important;
    color: #64748b !important;
    margin-bottom: 2px !important;
    line-height: 1.3 !important;
}

.indicator strong {
    display: block !important;
    font-size: 20px !important;
    font-weight: 800 !important;
    color: #172033 !important;
    line-height: 1.1 !important;
    margin: 2px 0 !important;
}

.indicator small {
    display: block !important;
    font-size: 11px !important;
    color: #526174 !important;
    margin-top: 2px !important;
}

/* =========================================================================
   REPARACIÓN DEFINITIVA: LÍNEAS TRANSPARENTES, HEATMAP Y TOOLTIPS
   ========================================================================= */
/*
svg text {
    fill: #1e293b !important;
    opacity: 1 !important;
    visibility: visible !important;
    display: inline !important;
    pointer-events: none !important;
}

.tick text, .axis text, .label text, text.label, text.axis-title {
    fill: #334155 !important;
    font-size: 11px !important;
    font-weight: 600 !important;
}

svg path {
    fill: none !important;
}

.spider-svg path,
.spider-svg .spider-area {
    fill-opacity: 0.15 !important;
    stroke-width: 2.5px !important;
}

.spider-svg polygon,
.spider-svg .grid, 
.spider-svg .grid-strong,
.series-svg .grid,
.dash-svg .grid {
    fill: none !important;
    stroke: #cbd5e1 !important;
    stroke-width: 1px !important;
}

#chartContainer,
#chartContainer svg,
.rtc-svg, 
.spider-svg, 
.series-svg, 
.dash-svg {
    cursor: default !important;
}

svg rect,
svg circle,
circle.point,
.point,
.cell,
.heatmap-cell,
svg path {
    pointer-events: all !important;
    cursor: pointer !important;
}


svg rect:hover,
.cell:hover,
.heatmap-cell:hover {
    stroke: #000000 !important;
    stroke-width: 1.5px !important;
    opacity: 0.85 !important;
}

circle.point:hover,
svg circle:hover {
    r: 6.5px !important;
    stroke: #ffffff !important;
    stroke-width: 2px !important;
}


.rtc-tooltip, 
.dash-tooltip,
.chart-tooltip,
.tooltip,
#chartTooltip,
#tooltip,
div[class*="tooltip"] {
    position: fixed !important;
    z-index: 99999999 !important;
    pointer-events: none !important;
    background: #0f172a !important;
    color: #ffffff !important;
    padding: 8px 12px !important;
    border-radius: 6px !important;
    font-size: 12px !important;
    font-weight: 600 !important;
    line-height: 1.4 !important;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.5) !important;
    border: 1px solid rgba(255, 255, 255, 0.2) !important;
}
*/

/* =========================================================================
   CORRECCIÓN FINAL: FONDO RADAR Y ESPIRAL TEMPORAL
   ========================================================================= */

/* 1. VISIBILIDAD DE ETIQUETAS Y TEXTOS SVG */
#chartContainer svg text,
.temp-dash-wrapper svg text {
    fill: #1e293b !important;
    opacity: 1 !important;
    visibility: visible !important;
    display: inline !important;
    pointer-events: none !important;
}

#chartContainer .tick text, 
#chartContainer .axis text, 
#chartContainer .label text, 
.temp-dash-wrapper .tick text, 
.temp-dash-wrapper .axis text {
    fill: #334155 !important;
    font-size: 11px !important;
    font-weight: 600 !important;
}

/* 2. REGLAS DE RELLENO (FILL) ESPECÍFICAS PARA CADA TIPO DE GRÁFICA */

/* Quitar fondo negro a los polígonos/redes del Radar (Máxima y Mínima) */
svg polygon,
.spider-svg polygon,
.spider-bg,
polygon.grid {
    fill: none !important;
    stroke: #e2e8f0 !important;
    stroke-width: 1px !important;
}

/* Permitir relleno de color en los trazos de la Espiral Radial (Temperatura mensual) */
.rtc-svg path,
.rtc-svg circle,
.rtc-svg rect {
    fill-opacity: 1 !important;
    stroke: none;
}

/* Líneas de series de tiempo (Ciclos, Medias, etc.) sin relleno negro */
.series-svg path:not(.spider-area),
.dash-svg path:not(.spider-area) {
    fill: none !important;
}

/* Relleno tenue para las áreas del Radar */
.spider-svg path.spider-area {
    fill-opacity: 0.15 !important;
    stroke-width: 2px !important;
}

/* 3. CURSORES E INTERACTIVIDAD */
#chartContainer,
#chartContainer svg,
.temp-dash-wrapper svg {
    cursor: default !important;
}

#chartContainer svg rect,
#chartContainer svg circle,
#chartContainer svg path,
.temp-dash-wrapper svg rect,
.temp-dash-wrapper svg circle,
.cell,
.heatmap-cell {
    pointer-events: all !important;
    cursor: pointer !important;
}

#chartContainer svg circle:hover,
.temp-dash-wrapper svg circle:hover {
    r: 6px !important;
    stroke: #ffffff !important;
    stroke-width: 2px !important;
}

/* 4. TOOLTIP FLOTANTE */
.rtc-tooltip, 
.dash-tooltip,
.chart-tooltip,
#chartTooltip {
    position: fixed !important;
    z-index: 99999999 !important;
    pointer-events: none !important;
    background: #0f172a !important;
    color: #ffffff !important;
    padding: 8px 12px !important;
    border-radius: 6px !important;
    font-size: 12px !important;
    font-weight: 600 !important;
    line-height: 1.4 !important;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.5) !important;
    border: 1px solid rgba(255, 255, 255, 0.2) !important;
}


/* =========================================================================
   ESTILOS EXCLUSIVOS PARA IMPRESIÓN / GUARDAR EN PDF
   ========================================================================= */
@media print {
    /* 1. Ocultar todo lo demás */
    body * {
        visibility: hidden !important;
    }

    /* 2. Mostrar únicamente el contenedor y sus hijos */
    #floatingChart, 
    #floatingChart * {
        visibility: visible !important;
    }

    /* 3. DESBLOCAR SCROLL Y ALTURA PARA IMPRESIÓN COMPLETA */
    html, body {
        height: auto !important;
        overflow: visible !important;
    }

    #floatingChart {
        position: absolute !important;
        left: 0 !important;
        top: 0 !important;
        width: 100% !important;
        
        /* Eliminar restricciones de scroll y altura */
        height: auto !important;
        max-height: none !important;
        overflow: visible !important;
        
        box-shadow: none !important;
        border: none !important;
        background: white !important;
        padding: 0 !important;
    }

    /* 4. Forzar a que los contenedores INTERNOS con scroll también se expandan */
    #floatingChart div,
    #floatingChart .chart-container,
    #floatingChart .modal-body,
    #floatingChart .content {
        height: auto !important;
        max-height: none !important;
        overflow: visible !important;
    }

    /* 5. Evitar que las gráficas se corten por la mitad entre páginas */
    #floatingChart svg,
    #floatingChart .chart-item,
    #floatingChart canvas {
        page-break-inside: avoid !important;
        break-inside: avoid !important;
    }

    /* 6. Ocultar botones de cierre y controles en la impresión */
    #chartHeader .btn-close,
    .temp-dash-btn,
    .state-toolbar,
    button,
    .no-print {
        display: none !important;
    }
}