/* CONTROL FLOTA RENTAMAQ - SISTEMA DE DISEÑO SAAS ENTERPRISE */
/* Inspirado en la estética moderna de Linear, Vercel y plataformas de telemetría industrial */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600;700&display=swap');

/* ========================================================
   VARIABLES DE TEMA (LIGHT & DARK MODE)
   ======================================================== */
:root {
  /* Modo Claro (SaaS Enterprise Limpio) */
  --bg-app: #f8fafc;
  --bg-surface: #ffffff;
  --bg-surface-elevated: #f1f5f9;
  --bg-surface-subtle: #f8fafc;
  --bg-sidebar: #ffffff;
  --bg-header: rgba(255, 255, 255, 0.88);
  
  --border-subtle: #f1f5f9;
  --border-medium: #e2e8f0;
  --border-strong: #cbd5e1;
  
  --text-main: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --text-faint: #94a3b8;
  
  --brand-primary: #f97316;
  --brand-hover: #ea580c;
  --brand-gradient: linear-gradient(135deg, #f97316 0%, #ea580c 100%);
  --brand-glow: rgba(249, 115, 22, 0.25);
  
  --card-bg: #ffffff;
  --card-border: #e2e8f0;
  --card-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.05), 0 1px 2px -1px rgba(0, 0, 0, 0.05);
  --card-shadow-hover: 0 10px 25px -5px rgba(0, 0, 0, 0.08), 0 8px 10px -6px rgba(0, 0, 0, 0.04);
  
  --input-bg: #ffffff;
  --input-border: #cbd5e1;
  --input-text: #0f172a;
  --input-focus-ring: rgba(249, 115, 22, 0.2);

  --badge-bg: #f1f5f9;
  --badge-text: #334155;
  
  --scrollbar-thumb: #cbd5e1;
  --scrollbar-hover: #94a3b8;
}

html.dark {
  /* Modo Oscuro (Deep Obsidian / Industrial Pro) */
  --bg-app: #090d16;
  --bg-surface: #0f172a;
  --bg-surface-elevated: #1e293b;
  --bg-surface-subtle: #131b2e;
  --bg-sidebar: #0d121f;
  --bg-header: rgba(13, 18, 31, 0.88);
  
  --border-subtle: rgba(255, 255, 255, 0.04);
  --border-medium: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.15);
  
  --text-main: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --text-faint: #475569;
  
  --brand-primary: #f97316;
  --brand-hover: #ea580c;
  --brand-gradient: linear-gradient(135deg, #f97316 0%, #ea580c 100%);
  --brand-glow: rgba(249, 115, 22, 0.35);
  
  --card-bg: rgba(15, 23, 42, 0.75);
  --card-border: rgba(255, 255, 255, 0.08);
  --card-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.4), 0 8px 10px -6px rgba(0, 0, 0, 0.3);
  --card-shadow-hover: 0 20px 30px -10px rgba(0, 0, 0, 0.6), 0 10px 15px -5px rgba(0, 0, 0, 0.4);
  
  --input-bg: #030712;
  --input-border: #334155;
  --input-text: #f9fafb;
  --input-focus-ring: rgba(249, 115, 22, 0.3);

  --badge-bg: #1e293b;
  --badge-text: #e2e8f0;
  
  --scrollbar-thumb: #334155;
  --scrollbar-hover: #475569;
}

/* ========================================================
   BASE Y TIPOGRAFÍA
   ======================================================== */
* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  transition: background-color 0.25s ease, color 0.2s ease;
}

body {
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background-color: var(--bg-app);
  color: var(--text-main);
  transition: background-color 0.25s ease, color 0.2s ease;
}

.font-mono {
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

/* ========================================================
   TARJETAS Y CONTENEDORES SAAS
   ======================================================== */
.glass-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 1rem;
  box-shadow: var(--card-shadow);
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

html.dark .glass-card {
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.glass-card:hover {
  box-shadow: var(--card-shadow-hover);
  border-color: rgba(249, 115, 22, 0.25);
}

/* Banner Hero del Dashboard */
.hero-banner {
  background: linear-gradient(135deg, rgba(249, 115, 22, 0.08) 0%, rgba(234, 88, 12, 0.02) 100%);
  border: 1px solid rgba(249, 115, 22, 0.2);
  border-radius: 1rem;
  padding: 1.5rem;
}

html.dark .hero-banner {
  background: linear-gradient(135deg, rgba(249, 115, 22, 0.12) 0%, rgba(15, 23, 42, 0.8) 100%);
  border-color: rgba(249, 115, 22, 0.3);
}

/* ========================================================
   BOTONES
   ======================================================== */
.btn-primary {
  background: var(--brand-gradient);
  color: #ffffff !important;
  font-weight: 600;
  padding: 0.55rem 1.15rem;
  border-radius: 0.625rem;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 2px 10px rgba(249, 115, 22, 0.3);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  cursor: pointer;
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.btn-primary:hover {
  filter: brightness(1.08);
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(249, 115, 22, 0.45);
}

/* Botón bloqueado (formulario incompleto) */
.btn-primary:disabled {
  background: #475569;
  color: #cbd5e1 !important;
  box-shadow: none;
  cursor: not-allowed;
  opacity: 0.6;
  filter: none;
  transform: none;
}

.btn-secondary {
  background-color: var(--bg-surface);
  color: var(--text-main);
  font-weight: 600;
  padding: 0.55rem 1.15rem;
  border-radius: 0.625rem;
  border: 1px solid var(--border-medium);
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  cursor: pointer;
}

.btn-secondary:hover {
  background-color: var(--bg-surface-elevated);
  border-color: var(--border-strong);
  color: var(--brand-primary);
}

/* ========================================================
   NAVEGACIÓN (SIDEBAR & CATEGORÍAS)
   ======================================================== */
.nav-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.65rem 0.875rem;
  border-radius: 0.625rem;
  font-size: 0.875rem;
  color: var(--text-secondary);
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  border: 1px solid transparent;
  text-decoration: none;
  font-weight: 500;
}

.nav-item:hover {
  color: var(--text-main);
  background-color: var(--bg-surface-elevated);
}

.nav-item.active {
  color: var(--brand-primary) !important;
  background-color: rgba(249, 115, 22, 0.1) !important;
  border-color: rgba(249, 115, 22, 0.25) !important;
  font-weight: 600;
  box-shadow: inset 3px 0 0 var(--brand-primary);
}

.category-tab {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  border-radius: 0.625rem;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-muted);
  background-color: var(--bg-surface-subtle);
  border: 1px solid var(--border-medium);
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  cursor: pointer;
}

.category-tab:hover {
  color: var(--text-main);
  background-color: var(--bg-surface-elevated);
  border-color: var(--border-strong);
}

.category-tab.active {
  color: #ffffff;
  background: var(--brand-gradient);
  border-color: transparent;
  box-shadow: 0 2px 8px rgba(249, 115, 22, 0.3);
}

/* ========================================================
   COMPATIBILIDAD CON CLASES TAILWIND EN MODO CLARO
   ======================================================== */
html:not(.dark) {
  background-color: var(--bg-app) !important;
  color: var(--text-main) !important;
}

html:not(.dark) body {
  background-color: var(--bg-app) !important;
  color: var(--text-main) !important;
}

/* Ajustes de Textos en Modo Claro */
html:not(.dark) .text-white {
  color: #0f172a !important;
}

html:not(.dark) .text-slate-100 {
  color: #0f172a !important;
}

html:not(.dark) .text-slate-200 {
  color: #1e293b !important;
}

html:not(.dark) .text-slate-300 {
  color: #334155 !important;
}

html:not(.dark) .text-slate-400 {
  color: #64748b !important;
}

html:not(.dark) .text-slate-500 {
  color: #64748b !important;
}

/* Ajustes de Fondos en Modo Claro */
html:not(.dark) aside {
  background-color: #ffffff !important;
  border-color: #e2e8f0 !important;
}

html:not(.dark) header {
  background-color: rgba(255, 255, 255, 0.88) !important;
  border-color: #e2e8f0 !important;
}

html:not(.dark) .bg-\[\#090d16\] {
  background-color: #f8fafc !important;
}

html:not(.dark) .bg-\[\#0f172a\] {
  background-color: #ffffff !important;
}

html:not(.dark) .bg-slate-950 {
  background-color: #ffffff !important;
  border-color: #e2e8f0 !important;
}

html:not(.dark) .bg-slate-950\/40,
html:not(.dark) .bg-slate-950\/60 {
  background-color: #f8fafc !important;
}

html:not(.dark) .bg-slate-900 {
  background-color: #ffffff !important;
}

html:not(.dark) .bg-slate-900\/60,
html:not(.dark) .bg-slate-900\/80,
html:not(.dark) .bg-slate-900\/90 {
  background-color: #f8fafc !important;
}

html:not(.dark) .bg-slate-800 {
  background-color: #f1f5f9 !important;
  color: #334155 !important;
}

html:not(.dark) .bg-slate-800\/60,
html:not(.dark) .bg-slate-800\/80 {
  background-color: #f1f5f9 !important;
}

html:not(.dark) .hover\:bg-slate-800:hover {
  background-color: #f1f5f9 !important;
}

html:not(.dark) .hover\:bg-slate-700:hover {
  background-color: #e2e8f0 !important;
}

/* Bordes en Modo Claro */
html:not(.dark) .border-slate-800,
html:not(.dark) .border-slate-800\/80,
html:not(.dark) .border-slate-800\/60 {
  border-color: #e2e8f0 !important;
}

html:not(.dark) .border-slate-700,
html:not(.dark) .border-slate-700\/80 {
  border-color: #cbd5e1 !important;
}

/* Inputs y Selects */
html:not(.dark) input,
html:not(.dark) select,
html:not(.dark) textarea {
  background-color: #ffffff !important;
  color: #0f172a !important;
  border-color: #cbd5e1 !important;
}

html:not(.dark) input:focus,
html:not(.dark) select:focus,
html:not(.dark) textarea:focus {
  border-color: #f97316 !important;
  box-shadow: 0 0 0 2px rgba(249, 115, 22, 0.2) !important;
}

/* Modales y Overlays */
html:not(.dark) #modal-root > div > div,
html:not(.dark) .modal-content-box {
  background-color: #ffffff !important;
  border-color: #e2e8f0 !important;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.15) !important;
  color: #0f172a !important;
}

/* ========================================================
   ANIMACIONES Y SCROLLBAR
   ======================================================== */
@keyframes fadeIn {
  from { opacity: 0; transform: scale(0.98); }
  to { opacity: 1; transform: scale(1); }
}

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

.animate-fade-in {
  animation: fadeIn 0.2s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.animate-slide-in {
  animation: slideIn 0.25s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* Scrollbar Personalizado */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb);
  border-radius: 9999px;
}

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

/* ========================================================
   LEAFLET MAPS & GEOCERCAS
   ======================================================== */
.leaflet-container {
  background: var(--bg-app) !important;
  font-family: inherit;
  border-radius: 0.75rem;
}

.leaflet-popup-content-wrapper {
  background: var(--bg-surface) !important;
  color: var(--text-main) !important;
  border: 1px solid var(--border-medium) !important;
  border-radius: 0.875rem !important;
  box-shadow: var(--card-shadow-hover) !important;
}

html.dark .leaflet-popup-content-wrapper {
  background: rgba(15, 23, 42, 0.95) !important;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  color: #f8fafc !important;
  border: 1px solid rgba(255, 255, 255, 0.12) !important;
}

.leaflet-popup-tip {
  background: var(--bg-surface) !important;
}

html.dark .leaflet-popup-tip {
  background: #0f172a !important;
}

.leaflet-popup-content {
  margin: 12px 14px !important;
  line-height: 1.5 !important;
}

/* Marcadores Personalizados de Vehículos */
.vehicle-marker-pin {
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 9999px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4);
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  position: relative;
}

.vehicle-marker-pin:hover {
  transform: scale(1.25);
  z-index: 1000 !important;
}

.marker-pulse-moving {
  position: absolute;
  inset: -5px;
  border-radius: 9999px;
  background-color: rgba(16, 185, 129, 0.4);
  animation: markerPulse 1.8s infinite;
  pointer-events: none;
}

.marker-pulse-idle {
  position: absolute;
  inset: -4px;
  border-radius: 9999px;
  background-color: rgba(245, 158, 11, 0.35);
  animation: markerPulse 2.4s infinite;
  pointer-events: none;
}

@keyframes markerPulse {
  0% { transform: scale(0.9); opacity: 0.8; }
  50% { transform: scale(1.4); opacity: 0.2; }
  100% { transform: scale(1.8); opacity: 0; }
}

/* Tooltip de Geocercas en Leaflet */
.geofence-tooltip {
  background: var(--bg-surface) !important;
  border: 1px solid var(--border-medium) !important;
  color: var(--text-main) !important;
  font-weight: 700 !important;
  font-size: 11px !important;
  border-radius: 6px !important;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15) !important;
  padding: 4px 8px !important;
}

html.dark .geofence-tooltip {
  background: rgba(15, 23, 42, 0.9) !important;
  border-color: rgba(255, 255, 255, 0.15) !important;
  color: #f1f5f9 !important;
}

.fuel-gauge-bar {
  background: linear-gradient(90deg, #ef4444 0%, #f59e0b 35%, #10b981 100%);
}

/* Campos de fecha: ícono y calendario visibles en modo oscuro */
html.dark input[type="date"] {
  color-scheme: dark;
}
input[type="date"] {
  cursor: pointer;
}