/*!
 * =====================================================================
 * TUCNAY OPS - SISTEMA DE DISEÑO GLOBAL (UI/UX)
 * =====================================================================
 * Archivo: theme_global.css
 * Descripción: Hoja de estilos centralizada. Contiene variables de 
 * color, efectos Glassmorphism, animaciones y diseño 
 * base para PWA Logística y TV Wallboard.
 * Versión: 2.0.0
 * Última Modificación: 27 de Abril, 2026
 * =====================================================================
 */

/* =====================================================================
   0. PALETA DE COLORES Y VARIABLES GLOBALES
   ===================================================================== */
:root {
    /* Paleta Base PWA y Wallboard */
    --bg-dark: #1a1a2e;
    --bg-card: #16213e;
    --accent: #4ecca3;
    --text-main: #ffffff;
    --text-muted: #8892b0;
    
    /* Estados Operativos (Máquina de Estados) */
    --danger: #FF3B30;      /* Detenido / Taller / Offline */
    --warning: #FFCC00;     /* Cargando / Validando */
    --success: #34C759;     /* Activo / Liquidado */
    --info: #007AFF;        /* Apto Médico / Circulación */
    --accent-alt: #AF52DE;  /* Pólizas / Destino */
}

/* =====================================================================
   1. ESTILOS BASE Y TIPOGRAFÍA (ALTA DEFINICIÓN)
   ===================================================================== */
body, html { 
    margin: 0; padding: 0; height: 100%; width: 100%; 
    background-color: var(--bg-dark); /* Adaptado al modo oscuro PWA */
    color: var(--text-main);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif; 
    
    /* Suavizado de fuentes de Alta Fidelidad */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

/* Tipografía Estructurada: Evita que los números "brinquen" al cambiar */
#reloj-wallboard, .kpi-value, .valor-principal, .dato-numero, .card-indicators span, .map-pin-unit, .offline-time {
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.02em;
}

/* =====================================================================
   2. CRISTAL ESMERILADO (GLASSMORPHISM) Y COMPONENTES BASE
   ===================================================================== */
.glass-panel {
    background: rgba(28, 28, 30, 0.65) !important; /* Tono oscuro translúcido de iOS */
    backdrop-filter: blur(25px) saturate(200%) !important;
    -webkit-backdrop-filter: blur(25px) saturate(200%) !important;
    border: 1px solid rgba(255, 255, 255, 0.15) !important;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2) !important;
    border-radius: 20px;
    color: #FFFFFF !important;
}

/* Limpieza: Si tienes otra clase .glass-panel en theme_logistica.css, bórrala para evitar conflictos. */

.btn-primary {
    width: 100%; padding: 15px; background: var(--accent); color: #1a1a2e;
    border: none; border-radius: 8px; font-weight: 900; font-size: 1rem;
    cursor: pointer; margin-top: 10px; transition: background 0.3s;
}
.btn-primary:hover { filter: brightness(1.1); }

/* =====================================================================
   3. MODALES BOTTOM SHEET (ESTILO iOS PWA)
   ===================================================================== */
.modal-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.6); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
    z-index: 999; opacity: 0; visibility: hidden; transition: all 0.3s ease;
}
.modal-overlay.active { opacity: 1; visibility: visible; }

.bottom-sheet {
    position: fixed; bottom: -100%; left: 0; width: 100%;
    background: var(--bg-dark); border-radius: 24px 24px 0 0;
    z-index: 1000; padding: 20px; box-sizing: border-box;
    transition: bottom 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.1);
    box-shadow: 0 -10px 25px rgba(0,0,0,0.5);
}
.bottom-sheet.active { bottom: 0; }

.sheet-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.sheet-header h3 { margin: 0; color: var(--accent); }
.close-btn { background: none; border: none; color: var(--text-muted); font-size: 24px; cursor: pointer; }

/* Controles de Formulario Móvil */
.form-group { margin-bottom: 15px; }
.form-group label { display: block; font-size: 0.85rem; color: var(--text-muted); margin-bottom: 5px; font-weight: 600; }
.form-control { 
    width: 100%; padding: 12px; border-radius: 8px; border: 1px solid rgba(255,255,255,0.1); 
    background: var(--bg-card); color: white; font-size: 1rem; box-sizing: border-box;
}

/* =====================================================================
   4. MARCADORES DE MAPA Y ANIMACIONES (TELEMETRÍA)
   ===================================================================== */
.map-pin-container { position: relative; display: flex; flex-direction: column; align-items: center; pointer-events: none; transition: transform 0.5s ease; }
.map-pin-bubble { background: rgba(255, 255, 255, 1); padding: 8px 14px; border-radius: 12px; display: flex; flex-direction: column; align-items: center; box-shadow: 0 8px 25px rgba(0,0,0,0.2); border: 1px solid rgba(0,0,0,0.05); position: absolute; bottom: 22px; white-space: nowrap; z-index: 3; }
.map-pin-bubble::after { content: ''; position: absolute; bottom: -6px; left: 50%; transform: translateX(-50%); border-width: 6px 6px 0; border-style: solid; border-color: rgba(255, 255, 255, 1) transparent transparent transparent; }
.map-pin-unit { font-size: 18px; font-weight: 900; color: #1C1C1E; line-height: 1; letter-spacing: -0.5px; }
.map-pin-status { font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.5px; margin-top: 4px; padding: 2px 6px; border-radius: 4px; line-height: 1; transition: background-color 0.5s, color 0.5s; }

/* Efecto de Pulso Radar */
.map-pin-dot { width: 16px; height: 16px; border-radius: 50%; border: 3px solid white; box-shadow: 0 3px 8px rgba(0,0,0,0.3); position: relative; z-index: 2; transition: background-color 0.5s; }
.map-pin-pulse { position: absolute; top: -6px; left: -6px; right: -6px; bottom: -6px; border-radius: 50%; border: 2px solid currentColor; opacity: 0.6; animation: pinPulse 2s infinite cubic-bezier(0.215, 0.61, 0.355, 1); z-index: 1; }
@keyframes pinPulse { 
    0% { transform: scale(0.8); opacity: 0.8; border-width: 2px; } 
    50% { opacity: 0.5; }
    100% { transform: scale(2.8); opacity: 0; border-width: 0px; } 
}

/* Limpieza de Leaflet para Clusters personalizados */
.leaflet-div-icon { background: transparent !important; border: none !important; }

.map-pin-bubble-container { transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.3s ease; transform-origin: bottom center; }
.map-pin-bubble-container:hover { transform: translateX(-50%) translateY(-4px) scale(1.02) !important; box-shadow: 0 12px 32px rgba(0,0,0,0.18) !important; z-index: 9999 !important; }

/* =====================================================================
   5. TARJETAS DE VIAJE Y BLOQUEOS (CARRUSEL & PWA)
   ===================================================================== */
.card-viaje { 
    height: 115px; width: 275px; margin-bottom: 20px; flex-shrink: 0; 
    background: rgba(255, 255, 255, 1); border-radius: 16px; padding: 12px 15px; 
    box-sizing: border-box; border-left: 6px solid #ccc; transform-origin: left center; 
    display: flex; flex-direction: column; justify-content: space-between; 
    box-shadow: 0 6px 24px rgba(0,0,0,0.06); overflow: hidden; 
    transition: transform 0.8s cubic-bezier(0.65, 0, 0.35, 1), opacity 0.8s ease, height 0.4s ease, border-color 0.5s ease; 
}
.card-unidad-titulo { font-size: 20px; font-weight: 900; color: #1C1C1E; line-height: 1; letter-spacing: -0.3px; }
.card-chofer-nombre { font-size: 11px; font-weight: 600; color: #8E8E93; margin-top: 5px; }

/* Estado Bloqueado / Alerta Documental */
.bloqueo-salida {
    display: flex; align-items: center; width: 100%;
    background-color: rgba(255, 59, 48, 0.08); border: 1px dashed rgba(255, 59, 48, 0.4);
    border-radius: 8px; padding: 6px 12px; gap: 12px; margin-top: -2px; 
}
.bloqueo-icon { color: var(--danger); font-size: 16px; animation: latido 2s infinite; }
.bloqueo-title { color: var(--danger); font-size: 11px; font-weight: 900; letter-spacing: 0.5px; }
.bloqueo-desc { color: #8E8E93; font-size: 9px; font-weight: 800; text-transform: uppercase; }

@keyframes latido {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.15); opacity: 0.7; }
}

/* =====================================================================
   6. BITÁCORA DE NOTIFICACIONES (BURBUJAS)
   ===================================================================== */
.burbuja-mensaje { 
    padding: 8px 14px !important; display: flex; align-items: center; gap: 12px; 
    box-sizing: border-box; overflow: hidden; background: rgba(255, 255, 255, 0.98); 
    backdrop-filter: blur(15px); -webkit-backdrop-filter: blur(15px);
    border-radius: 12px; border: 1px solid rgba(255, 255, 255, 1); 
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.04); flex-shrink: 0; 
    height: 52px !important; margin-bottom: 6px !important; 
}
.burbuja-anim { animation: slideInRight 0.7s cubic-bezier(0.175, 0.885, 0.32, 1.27) forwards; }

@keyframes slideInRight { 
    0% { opacity: 0; transform: translateX(110%); max-height: 0; margin-bottom: 0; } 
    40% { opacity: 0; transform: translateX(110%); max-height: 52px; margin-bottom: 6px; } 
    100% { opacity: 1; transform: translateX(0); max-height: 52px; margin-bottom: 6px; } 
}

/* =====================================================================
   7. WIDGETS FINANCIEROS Y KPIs (DASHBOARD)
   ===================================================================== */
.kpi-dashboard-container { display: flex; gap: 24px; align-items: center; }

.kpi-glass-card {
    background: rgba(255, 255, 255, 0.85); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 1); border-radius: 20px;
    padding: 16px 24px 16px 16px; display: flex; align-items: center; gap: 20px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.06); transition: transform 0.3s ease, box-shadow 0.3s ease; flex: 1;
}
.kpi-glass-card:hover { transform: translateY(-4px); box-shadow: 0 12px 40px rgba(0, 0, 0, 0.12); }

/* SVG Circular Progress */
.kpi-svg-container { position: relative; width: 76px; height: 76px; }
.kpi-svg-container svg { position: absolute; top: 0; left: 0; width: 100%; height: 100%; transform: rotate(-90deg); }
.kpi-base-circle { fill: none; stroke: rgba(0, 0, 0, 0.04); stroke-width: 8; }
.kpi-dynamic-circle { 
    fill: none; stroke-width: 8; stroke-linecap: round; 
    stroke-dasharray: 326.7; stroke-dashoffset: 326.7; 
    transition: stroke-dashoffset 1.5s cubic-bezier(0.175, 0.885, 0.32, 1.275); 
}
.kpi-value-center { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); font-size: 26px; font-weight: 900; color: #1C1C1E; letter-spacing: -1.5px; }

/* =====================================================================
   8. COMPONENTES DEL SISTEMA (ALERTAS DE RED)
   ===================================================================== */
#offline-overlay { display: none; position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; background: rgba(15, 23, 42, 0.90); backdrop-filter: blur(15px); -webkit-backdrop-filter: blur(15px); z-index: 9999; justify-content: center; align-items: center; flex-direction: column; color: white; text-align: center; pointer-events: auto; }
.offline-icon { font-size: 90px; color: var(--danger); margin-bottom: 30px; animation: pulseRed 2s infinite cubic-bezier(0.4, 0, 0.2, 1); filter: drop-shadow(0 0 25px rgba(239, 68, 68, 0.5)); }
.offline-title { font-size: 56px; font-weight: 900; margin: 0; letter-spacing: -0.04em; }

@keyframes pulseRed { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: 0.7; transform: scale(0.97); } }

/* Indicador LED en Línea */
#led-conexion { animation: ledPulse 2s infinite ease-in-out; transform-origin: center; }
@keyframes ledPulse { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: 0.3; transform: scale(0.8); } }

/* Scrollbars Ocultos para Listas Dinámicas */
#lista-cobranza::-webkit-scrollbar, .hide-scroll::-webkit-scrollbar { display: none; }
#lista-cobranza, .hide-scroll { -ms-overflow-style: none; scrollbar-width: none; }

/* =====================================================================
   SISTEMA DE CONTENEDORES - TUCNAY UI
   ===================================================================== */

/* 1. CONTENEDOR INVISIBLE (Esqueleto / Posición) */
.ui-wrapper {
    position: absolute;
    pointer-events: none; /* Permite interactuar con el mapa a través del contenedor vacío */
    z-index: 2000;
}

/* 2. DISEÑO APPLE GLASS (Blanco / visionOS) */
.apple-glass {
    background: rgba(255, 255, 255, 0.65) !important; /* Blanco esmerilado translúcido */
    backdrop-filter: blur(30px) saturate(150%) !important;
    -webkit-backdrop-filter: blur(30px) saturate(150%) !important;
    
    /* Borde blanco sólido para dar el efecto de una placa de cristal cortada */
    border: 1px solid rgba(255, 255, 255, 0.9) !important; 
    
    /* Sombra muy suave y difuminada para separar el cristal del mapa sin mancharlo */
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.08) !important; 
    
    color: #1D1D1F !important; /* Gris ultra oscuro de Apple para el texto */
    pointer-events: auto;
}

/* BOTONES DE ACCIÓN REALISTAS */
.btn-apple-action {
    background: white !important;
    border: none;
    padding: 18px;
    border-radius: 24px;
    display: flex;
    align-items: center;
    gap: 15px;
    width: 100%;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0,0,0,0.03);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-apple-action:active {
    transform: scale(0.96);
    background: #F2F2F7 !important;
}

/* El cuadro del icono con color dinámico */
.btn-icon-box {
    width: 45px;
    height: 45px;
    background: var(--btn-color);
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.2rem;
    box-shadow: 0 8px 15px -5px var(--btn-color);
}

.btn-text-box {
    flex: 1;
    display: flex;
    flex-direction: column;
    text-align: left;
}

.btn-title {
    font-weight: 900;
    font-size: 0.95rem;
    color: #1D1D1F;
    letter-spacing: -0.3px;
}

.btn-subtitle {
    font-size: 0.75rem;
    font-weight: 600;
    color: #8E8E93;
}

.btn-arrow {
    color: #D1D1D6;
    font-size: 0.8rem;
}

/* NAVEGACIÓN ÍTEMS */
.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    font-size: 0.65rem;
    font-weight: 900;
    text-transform: uppercase;
}

.nav-icon-bg {
    width: 40px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}