/**
 * Estilos Mejorados del Módulo de Indicadores Ambientales - RESPONSIVE
 * Ubicación: /modules/ambientales/assets/css/ambientales.css
 * 
 * Diseño responsive que mantiene el estilo del dashboard principal
 */

/* ============================================
   VARIABLES Y CONFIGURACIÓN GLOBAL
   ============================================ */
:root {
    --ambiental-primary: #27ae60;
    --ambiental-secondary: #16a085;
    --ambiental-light: #d5f4e6;
    --ambiental-dark: #1e7e34;
    
    /* Colores del sistema */
    --dashboard-blue: #2c3e50;
    --dashboard-blue-light: #34495e;
    --border-color: #e0e0e0;
    --text-dark: #2c3e50;
    --text-muted: #000000;
    
    /* Espaciado consistente */
    --container-max-width: 1400px;
    --spacing-xs: 0.5rem;
    --spacing-sm: 1rem;
    --spacing-md: 1.5rem;
    --spacing-lg: 2rem;
    --spacing-xl: 3rem;
}

/* Reset y configuración base */
* {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 0;
    padding-bottom: 80px; /* Espacio para footer fijo */
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f5f6fa;
    color: var(--text-dark);
}

/* ============================================
   HEADER - Estilo del Dashboard Principal
   ============================================ */
.dashboard-header {
    background: linear-gradient(135deg, #27ae60 0%, #16a085 100%);
    color: white;
    padding: var(--spacing-lg) 0;
    margin-bottom: var(--spacing-lg);
    box-shadow: 0 2px 10px rgba(0,0,0,0.15);
}

.dashboard-header .container {
    max-width: var(--container-max-width);
    margin: 0 auto;
    padding: 0 var(--spacing-md);
}

.dashboard-header h1 {
    font-size: 2rem;
    font-weight: 700;
    margin: 0 0 var(--spacing-xs) 0;
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.dashboard-header h1 i {
    color: var(--ambiental-primary);
}

.dashboard-header p {
    font-size: 1rem;
    opacity: 0.9;
    margin: 0;
}

.dashboard-header .btn-light {
    background: white;
    color: var(--dashboard-blue);
    border: none;
    padding: 0.6rem 1.5rem;
    border-radius: 5px;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: var(--spacing-xs);
}

.dashboard-header .btn-light:hover {
    background: var(--ambiental-light);
    color: var(--ambiental-dark);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

/* ============================================
   CONTENEDOR PRINCIPAL CON MÁRGENES LATERALES
   ============================================ */
.container-fluid {
    max-width: var(--container-max-width);
    margin: 0 auto;
    padding: 0 var(--spacing-lg);
}

/* Para pantallas muy anchas, aumentar márgenes */
@media (min-width: 1600px) {
    .container-fluid {
        max-width: 1600px;
        padding: 0 var(--spacing-xl);
    }
}

/* ============================================
   SECCIÓN DE KPIS
   ============================================ */
section.mb-4 {
    margin-bottom: var(--spacing-lg) !important;
}

.section-title {
    color: var(--ambiental-primary);
    border-bottom: 3px solid var(--ambiental-secondary);
    padding-bottom: var(--spacing-xs);
    margin-bottom: var(--spacing-md);
    font-weight: 600;
    font-size: 1.3rem;
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

/* KPI Cards - Estilo consistente con dashboard principal */
.kpi-card {
    background: white;
    border-radius: 8px;
    padding: 1.5rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    transition: all 0.3s ease;
    border-left: 4px solid #3498db;
    height: 100%;
    min-height: 120px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.kpi-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

/* Colores de borde para KPIs */
.kpi-card.border-success { border-left-color: var(--ambiental-primary) !important; }
.kpi-card.border-info { border-left-color: #17a2b8 !important; }
.kpi-card.border-warning { border-left-color: #f39c12 !important; }
.kpi-card.border-danger { border-left-color: #e74c3c !important; }
.kpi-card.border-primary { border-left-color: #3498db !important; }

.kpi-card small {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 500;
}

.kpi-number {
    font-size: 2rem;
    font-weight: 700;
    margin: var(--spacing-xs) 0 0 0;
    line-height: 1;
}

/* Colores de texto para KPIs */
.text-success { color: var(--ambiental-primary) !important; }
.text-info { color: #17a2b8 !important; }
.text-warning { color: #f39c12 !important; }
.text-danger { color: #e74c3c !important; }
.text-primary { color: #3498db !important; }

/* ============================================
   CONTENEDORES DE GRÁFICOS
   ============================================ */
.chart-container {
    background: white;
    border-radius: 10px;
    padding: var(--spacing-lg);
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    transition: all 0.3s ease;
    height: 100%;
    min-height: 400px;
    margin-bottom: var(--spacing-md);
}

.chart-container:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.12);
    transform: translateY(-2px);
}

.chart-container h5 {
    font-weight: 600;
    color: var(--text-dark);
    margin-bottom: var(--spacing-md);
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    padding-bottom: var(--spacing-sm);
    border-bottom: 2px solid var(--border-color);
}

.chart-container h5 i {
    font-size: 1.2rem;
}

/* Canvas de gráficos */
canvas {
    max-height: 350px;
    width: 100% !important;
    height: auto !important;
}

/* ============================================
   GRIDS RESPONSIVE CON ESPACIOS CONSISTENTES
   ============================================ */
.row {
    margin-left: calc(var(--spacing-sm) * -1);
    margin-right: calc(var(--spacing-sm) * -1);
}

.row > [class*='col-'] {
    padding-left: var(--spacing-sm);
    padding-right: var(--spacing-sm);
}

.row.g-3 {
    --bs-gutter-x: 1rem;
    --bs-gutter-y: 1rem;
}

.mb-4 {
    margin-bottom: var(--spacing-lg) !important;
}

/* ============================================
   FOOTER FIJO
   ============================================ */
.footer-responsive {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 50px;
    background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
    z-index: 999;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Segoe UI', Arial, sans-serif;
    font-size: 0.85rem;
    color: white;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.2);
    text-align: center;
    padding: 0 var(--spacing-md);
}

.footer-responsive a {
    color: var(--ambiental-light);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.3s ease;
}

.footer-responsive a:hover {
    color: white;
    text-decoration: underline;
}

.footer-responsive strong {
    margin-right: var(--spacing-xs);
}

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

/* Tablets grandes y escritorio (≥992px) */
@media (min-width: 992px) {
    .chart-container {
        min-height: 450px;
    }
    
    canvas {
        max-height: 380px;
    }
}

/* Tablets (768px - 991px) */
@media (max-width: 991px) and (min-width: 768px) {
    .dashboard-header h1 {
        font-size: 1.8rem;
    }
    
    .container-fluid {
        padding: 0 var(--spacing-md);
    }
    
    .chart-container {
        min-height: 380px;
        padding: var(--spacing-md);
    }
    
    canvas {
        max-height: 320px;
    }
    
    .kpi-number {
        font-size: 1.8rem;
    }
}

/* Móviles grandes (576px - 767px) */
@media (max-width: 767px) and (min-width: 576px) {
    .dashboard-header {
        padding: var(--spacing-md) 0;
    }
    
    .dashboard-header h1 {
        font-size: 1.5rem;
    }
    
    .dashboard-header p {
        font-size: 0.9rem;
    }
    
    .container-fluid {
        padding: 0 var(--spacing-md);
    }
    
    .chart-container {
        min-height: 350px;
        padding: var(--spacing-md);
        margin-bottom: var(--spacing-md);
    }
    
    canvas {
        max-height: 280px;
    }
    
    .kpi-card {
        min-height: 100px;
        padding: var(--spacing-md);
    }
    
    .kpi-number {
        font-size: 1.6rem;
    }
    
    .section-title {
        font-size: 1.1rem;
    }
    
    /* Stack KPIs en 2 columnas en móviles */
    .col-md-2 {
        flex: 0 0 50%;
        max-width: 50%;
    }
}

/* Móviles pequeños (<576px) */
@media (max-width: 575px) {
    .dashboard-header {
        padding: var(--spacing-sm) 0;
    }
    
    .dashboard-header h1 {
        font-size: 1.3rem;
    }
    
    .dashboard-header h1 i {
        font-size: 1.1rem;
    }
    
    .dashboard-header p {
        font-size: 0.85rem;
    }
    
    .dashboard-header .btn-light {
        padding: 0.5rem 1rem;
        font-size: 0.85rem;
    }
    
    .container-fluid {
        padding: 0 var(--spacing-sm);
    }
    
    .chart-container {
        min-height: 320px;
        padding: var(--spacing-sm);
        margin-bottom: var(--spacing-sm);
        border-radius: 8px;
    }
    
    .chart-container h5 {
        font-size: 0.95rem;
        margin-bottom: var(--spacing-sm);
    }
    
    canvas {
        max-height: 250px;
    }
    
    .kpi-card {
        min-height: 90px;
        padding: var(--spacing-sm);
        margin-bottom: var(--spacing-sm);
    }
    
    .kpi-card small {
        font-size: 0.7rem;
    }
    
    .kpi-number {
        font-size: 1.4rem;
    }
    
    .section-title {
        font-size: 1rem;
        margin-bottom: var(--spacing-sm);
    }
    
    /* Stack KPIs en 1 columna en móviles pequeños */
    .col-md-2 {
        flex: 0 0 100%;
        max-width: 100%;
    }
    
    .footer-responsive {
        font-size: 0.7rem;
        height: 60px;
        line-height: 1.2;
    }
    
    body {
        padding-bottom: 70px;
    }
}

/* ============================================
   ANIMACIONES Y TRANSICIONES
   ============================================ */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.chart-container,
.kpi-card {
    animation: fadeIn 0.5s ease-out;
}

/* Stagger animation para múltiples elementos */
.kpi-card:nth-child(1) { animation-delay: 0s; }
.kpi-card:nth-child(2) { animation-delay: 0.1s; }
.kpi-card:nth-child(3) { animation-delay: 0.2s; }
.kpi-card:nth-child(4) { animation-delay: 0.3s; }
.kpi-card:nth-child(5) { animation-delay: 0.4s; }
.kpi-card:nth-child(6) { animation-delay: 0.5s; }

/* ============================================
   ESTILOS PARA IMPRESIÓN
   ============================================ */
@media print {
    .dashboard-header,
    .footer-responsive,
    .btn-light {
        display: none !important;
    }
    
    .chart-container {
        page-break-inside: avoid;
        box-shadow: none;
        border: 1px solid var(--border-color);
    }
    
    body {
        padding-bottom: 0;
        background: white;
    }
    
    .container-fluid {
        max-width: 100%;
        padding: 0;
    }
}

/* ============================================
   UTILIDADES ADICIONALES
   ============================================ */
.text-muted {
    color: var(--text-muted) !important;
}

/* Smooth scroll */
html {
    scroll-behavior: smooth;
}

/* Personalización de scrollbar (webkit) */
::-webkit-scrollbar {
    width: 10px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
    background: var(--ambiental-primary);
    border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--ambiental-secondary);
}

/* Mejoras de accesibilidad */
*:focus-visible {
    outline: 2px solid var(--ambiental-primary);
    outline-offset: 2px;
}

/* Loading state (opcional) */
.loading {
    opacity: 0.6;
    pointer-events: none;
    cursor: wait;
}

/* Estados de vacío */
.chart-container.empty::after {
    content: 'No hay datos disponibles';
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-muted);
    font-style: italic;
}
