/* dashboard.css - Estilos compartidos para el dashboard meteorológico */

/* ========== FUENTE VARELA (MAUI) ========== */
@font-face {
    font-family: 'Varela Round';
    src: url('../fonts/VarelaRound-Regular.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
    font-display: block; /* Esperar a que cargue para evitar flash de fuente */
}

/* ========== VARIABLES CSS ========== */
:root {
    --primary-blue: #3b82f6;
    --light-blue: #e0f2fe;
    --dark-blue: #1e40af;
    --success-green: #10b981;
    --warning-yellow: #f59e0b;
    --error-red: #ef4444;
    --text-gray: #374151;
    --bg-gradient: linear-gradient(135deg, #e0f2fe 0%, #bbdefb 50%, #c5cae9 100%);
}

/* ========== RESET Y BASE ========== */
* {
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1.5;
    color: var(--text-gray);
}

/* ========== NAVEGACIÓN ========== */
.nav-btn {
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.nav-btn:hover {
    background-color: rgba(59, 130, 246, 0.05);
    transform: translateY(-1px);
}

.nav-btn.active {
    background-color: rgba(59, 130, 246, 0.1);
}

.nav-btn::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    width: 0;
    height: 2px;
    background: var(--primary-blue);
    transition: all 0.3s ease;
    transform: translateX(-50%);
}

.nav-btn:hover::after {
    width: 80%;
}

.nav-btn.active::after {
    width: 100%;
}

/* Scroll horizontal suave para navegación móvil */
.scrollbar-hide {
    -ms-overflow-style: none;
    scrollbar-width: none;
    scroll-behavior: smooth;
}

.scrollbar-hide::-webkit-scrollbar {
    display: none;
}

/* ========== TARJETAS METEOROLÓGICAS ========== */
.weather-card {
    background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
    border: 1px solid rgba(59, 130, 246, 0.1);
    border-radius: 12px;
    padding: 1rem;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.weather-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--primary-blue), var(--success-green));
    opacity: 0;
    transition: opacity 0.3s ease;
}

.weather-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(59, 130, 246, 0.15);
}

.weather-card:hover::before {
    opacity: 1;
}

/* Colores específicos para diferentes métricas */
.card-temperature {
    border-left: 4px solid #ef4444;
}

.card-humidity {
    border-left: 4px solid #3b82f6;
}

.card-wind {
    border-left: 4px solid #ec4899;
}

.card-pressure {
    border-left: 4px solid #10b981;
}

.card-rain {
    border-left: 4px solid #8b5cf6;
}

/* ========== GRÁFICAS ========== */
.chart-container {
    background: white;
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
    border: 1px solid rgba(59, 130, 246, 0.1);
    transition: all 0.3s ease;
}

.chart-container:hover {
    box-shadow: 0 8px 15px rgba(0, 0, 0, 0.1);
    transform: translateY(-1px);
}

.chart-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-gray);
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid #f1f5f9;
}

/* ========== ESTADOS DE CARGA ========== */
.loading {
    opacity: 0.7;
    pointer-events: none;
    position: relative;
}

.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid var(--primary-blue);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ========== ALERTAS Y NOTIFICACIONES ========== */
.alert {
    border-radius: 8px;
    padding: 12px 16px;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.875rem;
    transition: all 0.3s ease;
}

.alert-success {
    background-color: #d1fae5;
    border: 1px solid #a7f3d0;
    color: #065f46;
}

.alert-warning {
    background-color: #fef3c7;
    border: 1px solid #fcd34d;
    color: #92400e;
}

.alert-error {
    background-color: #fee2e2;
    border: 1px solid #fca5a5;
    color: #991b1b;
}

.alert-info {
    background-color: #dbeafe;
    border: 1px solid #93c5fd;
    color: #1e40af;
}

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

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.fade-in {
    animation: fadeIn 0.5s ease-out;
}

.slide-in {
    animation: slideIn 0.3s ease-out;
}

/* ========== SELECTORES DE FECHA ========== */
.date-picker {
    background: white;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 0.875rem;
    transition: all 0.3s ease;
    outline: none;
}

.date-picker:focus {
    border-color: var(--primary-blue);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* ========== BOTONES ========== */
.btn {
    padding: 8px 16px;
    border-radius: 8px;
    font-weight: 500;
    font-size: 0.875rem;
    transition: all 0.3s ease;
    cursor: pointer;
    border: none;
    outline: none;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-primary {
    background: var(--primary-blue);
    color: white;
}

.btn-primary:hover {
    background: var(--dark-blue);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(59, 130, 246, 0.3);
}

.btn-secondary {
    background: #6b7280;
    color: white;
}

.btn-secondary:hover {
    background: #4b5563;
    transform: translateY(-1px);
}

/* ========== DEBUG PANEL ========== */
.debug-panel {
    background: #111827;
    color: #10b981;
    border-radius: 8px;
    font-family: 'Fira Code', 'JetBrains Mono', monospace;
    font-size: 0.75rem;
    line-height: 1.4;
    max-height: 200px;
    overflow-y: auto;
}


.debug-panel::-webkit-scrollbar {
    width: 6px;
}

.debug-panel::-webkit-scrollbar-track {
    background: #1f2937;
}

.debug-panel::-webkit-scrollbar-thumb {
    background: #374151;
    border-radius: 3px;
}

/* ========== RESPONSIVE UTILITIES ========== */

/* Reducir márgenes de títulos en gráficas para TODAS las resoluciones */
.bg-white h2,
.bg-white h3 {
    margin-bottom: 0.5rem;
}

.bg-white h2.mb-4,
.bg-white h2.mb-3,
.bg-white h3.mb-4,
.bg-white h3.mb-3,
.bg-white h3.mb-2,
.bg-white h2.mb-2 {
    margin-bottom: 0.5rem !important;
}

/* Reducir padding superior de contenedores de canvas */
.bg-white > div[class*="h-"] {
    padding-top: 0;
}

@media (max-width: 640px) {
    .weather-card {
        padding: 0.5rem;
    }

    .chart-container {
        padding: 0.5rem;
    }

    /* Reducir padding horizontal del contenedor principal */
    .max-w-7xl.mx-auto.px-6 {
        padding-left: 0.5rem !important;
        padding-right: 0.5rem !important;
    }

    /* Reducir padding de contenedores de gráficas con máxima especificidad */
    div.bg-white.rounded-lg.p-6,
    .bg-white.rounded-lg.p-6,
    div.bg-white.p-6,
    .p-6 {
        padding: 0.375rem !important;
    }

    /* Reducir padding de contenedores de gráficas más pequeños */
    div.bg-white.rounded-lg.p-4,
    .bg-white.rounded-lg.p-4 {
        padding: 0.375rem !important;
    }

    div.bg-white.rounded-lg.p-3,
    .bg-white.rounded-lg.p-3 {
        padding: 0.25rem !important;
    }

    /* Reducir padding específicamente en contenedores de gráficas */
    .bg-white.shadow-lg,
    .bg-white.border {
        padding: 0.375rem !important;
    }

    /* Mejorar relación de aspecto de gráficas en móvil - más ancha que alta */
    .h-80 {
        height: 14rem !important; /* Reducir altura para aspecto más panorámico */
    }

    .h-60 {
        height: 12rem !important;
    }

    .h-64 {
        height: 13rem !important;
    }

    /* Reducir padding interno de gráficas en general */
    canvas {
        padding: 0 !important;
    }

    .nav-btn {
        padding: 12px 16px;
        font-size: 0.875rem;
    }

    /* Reducir gap entre tarjetas */
    .space-y-6 > * + * {
        margin-top: 1rem !important;
    }

    .gap-6 {
        gap: 1rem !important;
    }

    /* Reducir tamaño de títulos de gráficas */
    .chart-title {
        font-size: 0.95rem !important;
    }

    /* Reducir títulos h2, h3 en gráficas */
    .bg-white h2,
    .bg-white h3 {
        font-size: 1rem !important;
        margin-bottom: 0.25rem !important;
    }

    /* Reducir margen inferior de títulos de gráficas con clases específicas */
    .bg-white h2.mb-4,
    .bg-white h2.mb-3,
    .bg-white h3.mb-4,
    .bg-white h3.mb-3,
    .bg-white h3.mb-2,
    .bg-white h2.mb-2,
    .bg-white h3.mb-1 {
        margin-bottom: 0.25rem !important;
    }

    /* Reducir padding superior de contenedores de canvas */
    .bg-white > div[class*="h-"] {
        padding-top: 0 !important;
    }
}

@media (max-width: 480px) {
    .weather-card {
        min-width: unset;
    }
    
    .chart-title {
        font-size: 1rem;
    }
}

/* ========== UTILIDADES ESPECÍFICAS ========== */
.metric-value {
    font-size: 1.25rem;
    font-weight: 700;
    line-height: 1;
}

.metric-label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.metric-time {
    font-size: 0.75rem;
    opacity: 0.7;
}

.trend-up {
    color: #ef4444;
}

.trend-down {
    color: #3b82f6;
}

/* ========== MEJORAS DE ACCESIBILIDAD ========== */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ========== PRINT STYLES ========== */
@media print {
    .nav-btn,
    .debug-panel,
    .alert {
        display: none !important;
    }

    .weather-card,
    .chart-container {
        break-inside: avoid;
        box-shadow: none;
        border: 1px solid #ccc;
    }
}

/* ========== MODO SEGUIMIENTO (OVERLAYS MÓVIL) ========== */

/* Botones icono circulares para abrir overlays */
.modo-btn-icon {
    cursor: pointer;
    transition: all 0.15s ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.modo-btn-icon:hover {
    background: #e5e7eb !important;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
}

.modo-btn-icon:active {
    transform: scale(0.9);
    background: #1B4F72 !important;
    border-color: #1B4F72 !important;
}

.modo-btn-icon:active svg rect,
.modo-btn-icon:active svg path {
    fill: #E0F7FA;
}

.modo-btn-icon:active svg line {
    stroke: #0D1B2A;
}

/* Tarjetas modo ampliado (oscuro) */
.seg-card {
    border-radius: 0.75rem;
    padding: 0.75rem 1rem;
    border: 1px solid #2C3E50;
    box-shadow: 4px 4px 8px rgba(0, 0, 0, 0.3);
    min-height: 0; /* Para que flex-1 funcione correctamente */
}

/* Modo ampliado fullscreen */
#modo-ampliado-container .seg-card.flex-1 {
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Overlays fullscreen */
#modo-ampliado-container,
#modo-compacto-container {
    transition: opacity 0.2s ease;
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    margin: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    height: 100dvh !important;
}

/* En modo fullscreen nativo, no hay safe-area ni barra de navegador */
#modo-ampliado-container:fullscreen,
#modo-compacto-container:fullscreen {
    padding: 0 !important;
    top: 0 !important;
}

#modo-ampliado-container {
    background: #0D1B2A !important;
}

#modo-compacto-container {
    background: #ffffff !important;
}

#modo-ampliado-container.hidden,
#modo-compacto-container.hidden {
    display: none !important;
}

/* Cuando un overlay está visible, ocultar el header completamente */
body:has(#modo-ampliado-container:not(.hidden)) header,
body:has(#modo-compacto-container:not(.hidden)) header {
    display: none !important;
    visibility: hidden !important;
}

/* También ocultar cualquier nav-btn que pueda tener pseudo-elementos visibles */
body:has(#modo-ampliado-container:not(.hidden)) .nav-btn,
body:has(#modo-compacto-container:not(.hidden)) .nav-btn {
    display: none !important;
}

/* Fallback para navegadores sin soporte :has() - usa clase JS */
body.overlay-active header {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
}

body.overlay-active .nav-btn {
    display: none !important;
}

