/* ================================================
   MotoXpress v3.5.2 - San Juan Edition
   DRIVER SUB-HEADER - PIXEL PERFECT
   Mobile-First, Floating Actions & Safe Areas
   ================================================ */

.driver-sub-header {
  position: fixed !important;
  /* FIX CRÍTICO: var(--header-total-height) mantiene unión acoplada exacta con env() */
  top: var(--header-total-height) !important;
  left: 0 !important;
  right: 0 !important;
  height: 90px !important;
  width: 100% !important;
  z-index: 850; /* Layer estratégico: Bajo Header (900), Sobre Mapa (0) */
  overflow: visible !important; /* CRÍTICO: Permitir que los triggers salgan por debajo del borde */

  box-sizing: border-box !important;

  display: flex !important;
  flex-direction: row !important;
  flex-wrap: nowrap !important;
  justify-content: space-between !important;
  align-items: center !important;
  /* gap: 10px; */ /* Reducido el gap para evitar desbordamientos en pantallas pequeñas */

  padding: 8px 15px 0 15px !important; /* Padding lateral ajustado */
  margin: 0 !important;

  /* UX/UI Upgrade: Glassmorphism High-Saturation (Efecto Hielo Oscuro) */
  background: rgba(18, 18, 18, 0.7) !important;
  backdrop-filter: blur(15px) saturate(180%);
  -webkit-backdrop-filter: blur(15px) saturate(180%);
  border-bottom: 1px solid rgba(255, 215, 0, 0.2);

  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5) !important;

  /* Estado Base (Salida) */
  transform: translateY(-120%);
  opacity: 0;
  pointer-events: none;
  transition:
    transform 0.5s cubic-bezier(0.19, 1, 0.22, 1),
    opacity 0.4s ease;
}

/* Animación de entrada estilo iOS */
.slide-in-top {
  transform: translateY(0) !important;
  opacity: 1 !important;
  pointer-events: auto !important;
}

/* Estado Visible (Legacy support) */
.driver-sub-header.reveal {
  transform: translateY(0) !important;
  opacity: 1 !important;
  pointer-events: auto !important;
}

/* --- Barra de Progreso --- */
.proximity-progress-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 3px;
  background: linear-gradient(90deg, #f1c40f, #f39c12);
  width: 0%;
  transition: width 0.5s linear;
  box-shadow: 0 0 10px rgba(241, 196, 15, 0.5);
  z-index: 851;
}

/* --- Avatar --- */
.driver-avatar-container {
  flex-shrink: 0;
  width: 55px;
  height: 55px;
  border-radius: 50%;
  overflow: hidden;
  border: 2px solid var(--primary);
  box-shadow: 0 4px 15px rgba(255, 215, 0, 0.2);
  margin-right: 12px;
}

.driver-avatar {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* --- Info Central --- */
.driver-info-compact {
  flex: 1;
  min-width: 0; /* Permite que el flex item se encoja más allá de su contenido */
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding-right: 8px;
  overflow: hidden; /* Crítico para ellipsis */
}

.driver-name-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 3px;
}

.driver-name {
  font-family: "Montserrat", sans-serif;
  font-size: 1.1rem;
  font-weight: 700; /* Bold */
  font-style: italic; /* Italic solicitado */
  color: #ffffff;
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: -0.5px;
}

.rating-badge-inline {
  font-size: 0.85rem;
  color: #ffd700;
  font-weight: 700;
}

.driver-plate {
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.7);
  margin: 0;
  font-weight: 500;
  text-transform: none; /* Destino normal */
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* --- Botón de Estado / Pago --- */
.driver-status-btn {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 6px 12px;
  background: rgba(255, 215, 0, 0.1);
  border: 1px solid rgba(255, 215, 0, 0.3);
  border-radius: 12px;
  min-width: 60px;
}

.status-row-bottom {
  display: flex;
  align-items: center;
  gap: 6px;
}

.driver-status-label {
  font-size: 0.65rem;
  font-weight: 800;
  color: #ffd700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  line-height: 1;
}

/* ==========================================================================
   FLOATING ACTION BAR (DRIVER CONTROLS)
   ========================================================================== */
.floating-action-bar {
  position: fixed;
  /* FIX: Elevación Final (150px) - 70px sobre Publicidad de 80px */
  bottom: calc(150px + env(safe-area-inset-bottom)) !important;
  left: 0 !important;
  right: 0 !important;
  width: 100% !important;

  display: flex !important;
  justify-content: center !important; /* Centrado forzado del hijo en flujo (Finalizar) */
  align-items: center !important;
  padding: 0 !important;
  margin: 0 !important;
  z-index: 900 !important;
  pointer-events: none;
  transform: translateY(
    -5px
  ) !important; /* Ajuste fino eje Y: Elevación limpia */

  /* UX: Transición elástica para modo inmersivo */
  transition:
    transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1),
    opacity 0.3s ease !important;
}

/* Estado oculto durante interacción con mapa (Immersive Mode) */
.floating-action-bar.map-hidden {
  transform: translateY(150px) !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

/* Botones interactivos */
.floating-action-bar button {
  pointer-events: auto;
  touch-action: manipulation; /* Fix delay 300ms Android */
  margin-bottom: 0 !important; /* Garantizar cálculo de altura exacto */
}

/* Botón Cancelar (Flotante, Rojo, Circular) */
.btn-floating-cancel {
  position: absolute !important; /* SACADO DEL FLUJO FLEX */
  left: 15px !important;
  width: 48px !important;
  height: 48px !important;
  border-radius: 50%;
  background: linear-gradient(135deg, #ff416c, #ff4b2b);
  border: none;
  color: white;
  font-size: 1.2rem;
  font-weight: bold;
  box-shadow: 0 4px 15px rgba(255, 75, 43, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
  flex-shrink: 0;
  margin: 0 !important;
}

.btn-floating-cancel:active {
  transform: scale(0.9);
}

/* Botón Finalizar (Flotante, Principal, Pill) - REFACTORIZADO v7.2.2 GPU-SAFE */
.btn-floating-complete {
  /* En flujo normal -> Centrado por el padre */
  flex: 0 1 auto !important;
  width: 100% !important;
  max-width: 190px !important;
  margin: 0 auto !important;
  padding: 0 20px !important;

  height: 48px !important; /* GEOMETRÍA: Altura sincronizada */
  
  /* --- Fondo Sólido Alfa (Sin backdrop-filter — GPU-Safe para Safari) --- */
  background: rgba(18, 18, 18, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-top: 1px solid var(--glass-border);
  border-radius: 24px; /* Pill shape ajustado a height/2 */
  
  color: var(--text-main, #ffffff);
  font-family: "Montserrat", sans-serif;
  font-weight: 900;
  font-style: italic;
  font-size: 1rem;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  
  /* Sombra única (sin repintados multi-capa) */
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  transition:
    transform 0.3s cubic-bezier(0.4, 0, 0.2, 1),
    border-color 0.3s ease,
    box-shadow 0.3s ease;
  will-change: transform;
  
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* --- Clases Utilitarias Auras (Estáticas — GPU-Safe v7.2.2) --- */
/* Transiciones estáticas de border-color + box-shadow en lugar de animaciones infinitas.
   Safari repinta box-shadow en CADA frame de animación. Con transition, solo se ejecuta
   una vez al cambiar de clase (.glow-red ↔ .glow-green). */

.glow-red {
  border-color: rgba(255, 77, 77, 0.45) !important;
  box-shadow: 0 8px 24px rgba(255, 77, 77, 0.25), 0 4px 12px rgba(0, 0, 0, 0.3) !important;
}

.glow-green {
  border-color: rgba(46, 204, 113, 0.45) !important;
  box-shadow: 0 8px 24px rgba(46, 204, 113, 0.25), 0 4px 12px rgba(0, 0, 0, 0.3) !important;
}

.btn-floating-complete:active {
  transform: scale(0.95);
}

/* Estado oculto */
.hidden {
  display: none !important;
}

/* Media Query para pantallas muy pequeñas (iPhone SE, etc) */
@media (max-width: 360px) {
  .driver-sub-header {
    padding: 8px 10px 0 10px !important;
  }
  .driver-avatar-container {
    width: 45px;
    height: 45px;
  }
  .driver-name {
    font-size: 1rem;
  }
  .btn-floating-cancel {
    width: 48px;
    height: 48px;
    font-size: 1.2rem;
  }
  .btn-floating-complete {
    height: 48px;
    font-size: 0.9rem;
  }
}

/* ==========================================================================
   SUBHEADER DRAWER (v6.2.3)
   ========================================================================== */
.drawer-trigger {
  position: absolute;
  bottom: -24px;
  left: 20px; /* Separación respecto a la pantalla izquierda y avatar */
  min-width: 48px;
  min-height: 24px;
  padding: 4px 12px;
  background: rgba(
    18,
    18,
    18,
    0.7
  ); /* Transparencia acorde al subheader padre */
  border: 1px solid rgba(255, 255, 255, 0.15); /* Glass border sutil separado */
  border-top: none;
  border-bottom-left-radius: 12px;
  border-bottom-right-radius: 12px;
  color: var(--primary, #ffd700);
  font-size: 0.75rem;
  font-weight: 800;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 849;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  pointer-events: auto !important; /* Permitir taps */
}

.ride-details-drawer {
  position: absolute;
  top: 100%; /* Inicia justo debajo del borde de 90px */
  left: 0;
  width: 100%;
  background: rgba(
    18,
    18,
    18,
    0.7
  ); /* Transparencia Glassmorphism sincronizada */
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-bottom: 1px solid rgba(255, 215, 0, 0.2);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.7);
  z-index: 848; /* Debajo del subheader principal y trigger */

  max-height: 0;
  overflow: hidden;
  transition: max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: auto; /* Permitir scroll dentro */
}

.ride-details-drawer.drawer-open {
  max-height: 250px;
}

.drawer-content-box {
  padding: 15px 20px 25px 20px;
  text-align: center;
}

.drawer-title {
  margin: 0;
  font-size: 0.75rem;
  font-weight: bold;
  color: var(--primary, #ffd700);
  letter-spacing: 1.5px;
}

.drawer-data {
  margin: 4px 0;
  font-size: 1.1rem;
  font-weight: bold;
  color: #ffffff;
  word-wrap: break-word;
  hyphens: auto;
  overflow-wrap: break-word;
}

.drawer-ref-scroll {
  max-height: 150px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
  margin-top: 4px;
}

.drawer-ref-scroll::-webkit-scrollbar {
  width: 4px;
}
.drawer-ref-scroll::-webkit-scrollbar-track {
  background: transparent;
}
.drawer-ref-scroll::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 4px;
}
.ref-text {
  font-size: 1rem;
  font-style: italic;
  font-weight: normal;
}

/* ==========================================================================
   PROXIMITY TRACKER (v6.2.2)
   ========================================================================== */
.proximity-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  margin-top: 15px;
  padding: 0 10px;
  box-sizing: border-box;
}

.prox-icon {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.9;
}

.moto-icon-circle {
  width: 28px;
  height: 28px;
  background: transparent;
  opacity: 1; /* Override proxy icon opacity */
  display: flex;
  align-items: center;
  justify-content: center;
}

.prox-icon svg {
  filter: drop-shadow(0px 2px 2px rgba(0, 0, 0, 0.5));
}

.proximity-bar-wrapper {
  flex-grow: 1;
  height: 6px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
  margin: 0 15px;
  overflow: hidden;
  position: relative;
}

.proximity-fill {
  height: 100%;
  width: 0%;
  background: var(--primary, #ffd700);
  transition: width 1s linear;
  border-radius: 3px;
}
