/**
 * Sistema QR Vehículos Municipales - DIDECO Arica
 * Estilos personalizados con Bootstrap 5.3
 * v2.0 — Diseño premium con animaciones y glassmorphism
 */

/* ============================================
   VARIABLES DE COLORES
   ============================================ */
:root {
  /* Colores principales */
  --primary-color: #0d47a1;
  --secondary-color: #1976d2;
  --success-color: #2e7d32;
  --danger-color: #c62828;
  --warning-color: #f57c00;
  --info-color: #0288d1;

  /* Colores neutros */
  --dark-color: #212121;
  --light-color: #f5f5f5;
  --white-color: #ffffff;

  /* Gradientes */
  --gradient-primary: linear-gradient(135deg, #0d47a1 0%, #1976d2 100%);
  --gradient-success: linear-gradient(135deg, #2e7d32 0%, #43a047 100%);
  --gradient-danger: linear-gradient(135deg, #c62828 0%, #e53935 100%);
  --gradient-warning: linear-gradient(135deg, #ef6c00 0%, #fb8c00 100%);
  --gradient-info: linear-gradient(135deg, #0277bd 0%, #039be5 100%);

  /* Glassmorphism */
  --glass-bg: rgba(255, 255, 255, 0.7);
  --glass-border: rgba(255, 255, 255, 0.3);
  --glass-shadow: 0 8px 32px rgba(31, 38, 135, 0.15);

  /* Sombras */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);
  --shadow-xl: 0 16px 48px rgba(0, 0, 0, 0.15);
}

/* ============================================
   ESTILOS GENERALES
   ============================================ */
body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family:
    "Inter",
    "Segoe UI",
    -apple-system,
    BlinkMacSystemFont,
    sans-serif;
  background-color: var(--light-color);
  color: #334155;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

main {
  flex: 1;
}

.footer {
  margin-top: auto;
}

/* ============================================
   SCROLLBAR PERSONALIZADA (Webkit)
   ============================================ */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: #f1f5f9;
  border-radius: 4px;
}
::-webkit-scrollbar-thumb {
  background: linear-gradient(
    180deg,
    var(--primary-color),
    var(--secondary-color)
  );
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--primary-color);
}

/* Firefox */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--secondary-color) #f1f5f9;
}

/* ============================================
   NAVBAR PERSONALIZADO
   ============================================ */
.navbar-dark.bg-primary {
  background: var(--gradient-primary) !important;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.navbar-brand {
  font-weight: 600;
  font-size: 1.25rem;
}

/* ============================================
   CARDS Y CONTAINERS
   ============================================ */
.card {
  border: none;
  border-radius: 16px;
  box-shadow: var(--shadow-md);
  transition:
    transform 0.3s cubic-bezier(0.4, 0, 0.2, 1),
    box-shadow 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
}

.card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
}

.card-header {
  background: var(--gradient-primary);
  color: white;
  border-radius: 16px 16px 0 0 !important;
  font-weight: 600;
  padding: 1rem 1.5rem;
}

/* ============================================
   CARDS DE ESTADÍSTICAS (Dashboard)
   ============================================ */
.stat-card {
  border: none;
  border-radius: 16px;
  overflow: hidden;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
}

.stat-card::before {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  width: 80px;
  height: 80px;
  border-radius: 0 0 0 80px;
  background: rgba(255, 255, 255, 0.15);
  transition: transform 0.4s ease;
}

.stat-card:hover {
  transform: translateY(-6px) scale(1.02);
  box-shadow: var(--shadow-xl);
}

.stat-card:hover::before {
  transform: scale(1.5);
}

.stat-card .card-body {
  position: relative;
  z-index: 1;
}

.stat-card .stat-icon {
  font-size: 2.5rem;
  opacity: 0.9;
  margin-bottom: 0.5rem;
  display: block;
}

.stat-card .stat-number {
  font-size: 2.25rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.stat-card .stat-label {
  font-size: 0.85rem;
  font-weight: 500;
  opacity: 0.9;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* Variantes de color */
.stat-card.stat-primary {
  background: var(--gradient-primary);
  color: #fff;
}
.stat-card.stat-success {
  background: var(--gradient-success);
  color: #fff;
}
.stat-card.stat-danger {
  background: var(--gradient-danger);
  color: #fff;
}
.stat-card.stat-warning {
  background: var(--gradient-warning);
  color: #fff;
}
.stat-card.stat-info {
  background: var(--gradient-info);
  color: #fff;
}

/* ============================================
   GLASSMORPHISM
   ============================================ */
.glass-card {
  background: var(--glass-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow);
  border-radius: 16px;
}

/* ============================================
   VISTA CONSULTA PÚBLICA (Solo Patente)
   ============================================ */
.consulta-publica-container {
  min-height: 80vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.qr-habilitado {
  background: var(--gradient-success);
  color: white;
}

.qr-deshabilitado {
  background: var(--gradient-danger);
  color: white;
}

.patente-display {
  font-size: 4rem;
  font-weight: 900;
  letter-spacing: 0.5rem;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
  font-family: "Courier New", monospace;
  background: rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  padding: 2rem 3rem;
  border-radius: 20px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  animation: patenteFadeIn 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes patenteFadeIn {
  from {
    opacity: 0;
    transform: scale(0.9) translateY(20px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.vehiculo-icon {
  font-size: 8rem;
  opacity: 0.9;
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.05);
  }
}

/* ============================================
   VISTA SIN GPS
   ============================================ */
.sin-gps-container {
  min-height: 80vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--gradient-warning);
  color: white;
  border-radius: 20px;
  padding: 2rem;
}

.gps-icon {
  font-size: 6rem;
  margin-bottom: 2rem;
  animation: gpsShake 1.5s ease-in-out infinite;
}

@keyframes gpsShake {
  0%,
  100% {
    transform: translateY(0);
  }
  25% {
    transform: translateY(-8px) rotate(-3deg);
  }
  75% {
    transform: translateY(-8px) rotate(3deg);
  }
}

.sin-gps-message {
  font-size: 2rem;
  font-weight: 600;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
}

/* ============================================
   FORMULARIOS
   ============================================ */
.form-control,
.form-select {
  border-radius: 10px;
  border: 1.5px solid #e2e8f0;
  padding: 0.65rem 1rem;
  transition: all 0.25s ease;
  font-size: 0.95rem;
}

.form-control:focus,
.form-select:focus {
  border-color: var(--secondary-color);
  box-shadow: 0 0 0 3px rgba(25, 118, 210, 0.15);
  transform: translateY(-1px);
}

.form-label {
  font-weight: 600;
  color: var(--dark-color);
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
}

.required-field::after {
  content: " *";
  color: var(--danger-color);
}

/* Password toggle */
.password-toggle {
  position: relative;
}
.password-toggle .toggle-btn {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: #94a3b8;
  cursor: pointer;
  padding: 0;
  font-size: 1.1rem;
  transition: color 0.2s;
}
.password-toggle .toggle-btn:hover {
  color: var(--primary-color);
}

/* ============================================
   BOTONES
   ============================================ */
.btn {
  border-radius: 10px;
  font-weight: 600;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  padding: 0.5rem 1.25rem;
  font-size: 0.95rem;
}

.btn-primary {
  background: var(--gradient-primary);
  border: none;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(13, 71, 161, 0.35);
}

.btn-success {
  background: var(--gradient-success);
  border: none;
}
.btn-success:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(46, 125, 50, 0.35);
}

.btn-danger {
  background: var(--gradient-danger);
  border: none;
}
.btn-danger:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(198, 40, 40, 0.35);
}

.btn-warning {
  background: var(--gradient-warning);
  border: none;
  color: white;
}
.btn-warning:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(239, 108, 0, 0.35);
  color: white;
}

.btn-outline-primary:hover,
.btn-outline-success:hover,
.btn-outline-danger:hover,
.btn-outline-warning:hover {
  transform: translateY(-2px);
}

/* ============================================
   BADGES
   ============================================ */
.badge {
  font-weight: 600;
  padding: 0.45rem 0.85rem;
  border-radius: 8px;
  font-size: 0.78rem;
  letter-spacing: 0.02em;
  animation: badgeSlideIn 0.3s ease-out;
}

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

.badge-pendiente {
  background-color: #ff9800;
  color: white;
}

.badge-asignado {
  background-color: #4caf50;
  color: white;
}

.badge-inactivo {
  background-color: #9e9e9e;
  color: white;
}

/* ============================================
   TABLAS
   ============================================ */
.table {
  border-radius: 12px;
  overflow: hidden;
}

.table thead th {
  background: var(--gradient-primary);
  color: white;
  border: none;
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.8rem;
  padding: 0.85rem 1rem;
  letter-spacing: 0.04em;
}

.table tbody tr {
  transition: all 0.2s ease;
  border-bottom: 1px solid #f1f5f9;
}

.table tbody tr:hover {
  background-color: rgba(13, 71, 161, 0.04);
  transform: scale(1.002);
}

.table tbody td {
  padding: 0.75rem 1rem;
  vertical-align: middle;
}

/* Zebra stripes suaves */
.table-striped > tbody > tr:nth-of-type(odd) > td {
  background-color: rgba(248, 250, 252, 0.6);
}

/* ============================================
   LOADING SPINNER & OVERLAY
   ============================================ */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(15, 23, 42, 0.75);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.loading-overlay.active {
  display: flex;
}

.loading-overlay .spinner-container {
  text-align: center;
  color: white;
}

.loading-overlay .spinner-container p {
  margin-top: 1rem;
  font-size: 1.1rem;
  font-weight: 500;
}

/* ============================================
   CÓDIGO DE CONFIRMACIÓN
   ============================================ */
.codigo-input {
  font-size: 2rem;
  text-align: center;
  letter-spacing: 1rem;
  font-weight: 700;
  font-family: "Courier New", monospace;
  padding: 1rem;
  border-radius: 12px;
  border: 2px dashed var(--primary-color);
  background: #f8fafc;
}

.codigo-input:focus {
  border-style: solid;
  background: #fff;
}

/* ============================================
   INSPECTOR - FICHA COMPLETA
   ============================================ */
.inspector-ficha {
  background: white;
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
}

.inspector-ficha .section-title {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--primary-color);
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 3px solid var(--primary-color);
}

.data-row {
  padding: 0.75rem 0;
  border-bottom: 1px solid #f1f5f9;
  transition: background-color 0.2s;
}

.data-row:hover {
  background-color: #f8fafc;
}

.data-row:last-child {
  border-bottom: none;
}

.data-label {
  font-weight: 600;
  color: #64748b;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.data-value {
  font-size: 1.05rem;
  color: var(--dark-color);
  font-weight: 500;
}

/* ============================================
   LOGS Y TIMELINE
   ============================================ */
.timeline {
  position: relative;
  padding-left: 2rem;
}

.timeline::before {
  content: "";
  position: absolute;
  left: 0.5rem;
  top: 0;
  bottom: 0;
  width: 2px;
  background: linear-gradient(
    to bottom,
    var(--primary-color),
    var(--secondary-color)
  );
}

.timeline-item {
  position: relative;
  padding-bottom: 1.5rem;
}

.timeline-item::before {
  content: "";
  position: absolute;
  left: -1.45rem;
  top: 0.25rem;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--primary-color);
  border: 3px solid white;
  box-shadow: 0 0 0 2px var(--primary-color);
}

/* ============================================
   LOGIN PAGE
   ============================================ */
.login-wrapper {
  min-height: 80vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(
    135deg,
    #0d47a1 0%,
    #1565c0 35%,
    #1976d2 65%,
    #1e88e5 100%
  );
  position: relative;
  overflow: hidden;
}

.login-wrapper::before {
  content: "";
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background:
    radial-gradient(
      ellipse at 20% 50%,
      rgba(255, 255, 255, 0.08) 0%,
      transparent 50%
    ),
    radial-gradient(
      ellipse at 80% 20%,
      rgba(255, 255, 255, 0.06) 0%,
      transparent 40%
    );
  animation: bgShift 15s ease-in-out infinite;
}

@keyframes bgShift {
  0%,
  100% {
    transform: translate(0, 0);
  }
  50% {
    transform: translate(-2%, 2%);
  }
}

.login-card {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 24px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
  overflow: hidden;
  position: relative;
  z-index: 1;
  max-width: 420px;
  width: 100%;
}

.login-card .login-header {
  background: var(--gradient-primary);
  padding: 2rem;
  text-align: center;
  color: white;
}

.login-card .login-header .login-icon {
  font-size: 3.5rem;
  animation: breathe 3s ease-in-out infinite;
}

@keyframes breathe {
  0%,
  100% {
    transform: scale(1);
    opacity: 0.9;
  }
  50% {
    transform: scale(1.08);
    opacity: 1;
  }
}

.login-card .login-body {
  padding: 2rem;
}

.login-card .login-footer {
  background: #f8fafc;
  text-align: center;
  padding: 1rem 2rem;
  border-top: 1px solid #e2e8f0;
}

/* ============================================
   MODALS MEJORADOS
   ============================================ */
.modal-content {
  border: none;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: var(--shadow-xl);
}

.modal-header {
  border-bottom: none;
  padding: 1.25rem 1.5rem;
}

.modal-footer {
  border-top: 1px solid #f1f5f9;
  padding: 1rem 1.5rem;
}

/* ============================================
   ALERTS MEJORADOS
   ============================================ */
.alert {
  border: none;
  border-radius: 12px;
  padding: 1rem 1.25rem;
  font-size: 0.92rem;
}

.alert-info {
  background: #e3f2fd;
  color: #0d47a1;
}

.alert-success {
  background: #e8f5e9;
  color: #2e7d32;
}

.alert-danger {
  background: #ffebee;
  color: #c62828;
}

.alert-warning {
  background: #fff3e0;
  color: #e65100;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
  .patente-display {
    font-size: 2.5rem;
    letter-spacing: 0.3rem;
    padding: 1.5rem 2rem;
  }

  .vehiculo-icon {
    font-size: 5rem;
  }

  .sin-gps-message {
    font-size: 1.5rem;
  }

  .codigo-input {
    font-size: 1.5rem;
    letter-spacing: 0.5rem;
  }

  .stat-card .stat-number {
    font-size: 1.75rem;
  }

  .stat-card .stat-icon {
    font-size: 2rem;
  }

  .login-card {
    margin: 1rem;
    border-radius: 16px;
  }
}

/* ============================================
   ANIMACIONES GENERALES
   ============================================ */
.fade-in {
  animation: fadeIn 0.5s ease-out;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.slide-in-up {
  animation: slideInUp 0.5s ease-out;
}

@keyframes slideInUp {
  from {
    opacity: 0;
    transform: translateY(40px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Staggered animation para cards */
.stagger-1 {
  animation-delay: 0.05s;
}
.stagger-2 {
  animation-delay: 0.1s;
}
.stagger-3 {
  animation-delay: 0.15s;
}
.stagger-4 {
  animation-delay: 0.2s;
}

/* ============================================
   UTILIDADES
   ============================================ */
.text-gradient {
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.backdrop-blur {
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
