:root {
  --red:     #E94B4D;
  --red-glow: rgba(233,75,77,0.35);
  --bg:      #0a0a0a;
  --bg2:     #141414;
  --bg3:     #1f1f1f;
  --border:  rgba(255,255,255,0.07);
  --text:    #F4F4F5;
  --muted:   #71717a;
  --success: #25D366;
  --warning: #F59E0B;
  --blue:    #3b82f6;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html, body {
  font-family: 'Outfit', sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100%;
  width: 100%;
  overflow: hidden;
  position: fixed;   /* previene scroll accidental en móvil */
}

/* ═══════════════════════════════════════════
   SCREENS
═══════════════════════════════════════════ */
.screen {
  display: none;
  flex-direction: column;
  width: 100%;
  height: 100dvh;
  position: absolute;
  inset: 0;
  overflow: hidden;
}
.screen.active { display: flex; }

/* Transición de entrada */
.screen.slide-in {
  animation: slideInRight 0.35s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}
.screen.slide-out {
  animation: slideOutLeft 0.3s ease forwards;
}
@keyframes slideInRight {
  from { transform: translateX(100%); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}
@keyframes slideOutLeft {
  from { transform: translateX(0);     opacity: 1; }
  to   { transform: translateX(-40px); opacity: 0; }
}

/* ═══════════════════════════════════════════
   SHARED COMPONENTS
═══════════════════════════════════════════ */
.icon-btn {
  width: 42px;
  height: 42px;
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 14px;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.18s;
  flex-shrink: 0;
}
.icon-btn:active { transform: scale(0.9); background: var(--bg2); }

/* ═══════════════════════════════════════════
   SCREEN 1 — LOGIN
═══════════════════════════════════════════ */
.login-bg {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 70% 55% at 50% -10%, rgba(168,85,247,0.28) 0%, transparent 70%),
    radial-gradient(ellipse 50% 40% at 90% 95%,  rgba(233,75,77,0.18) 0%, transparent 60%);
  pointer-events: none;
}
.login-content {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 56px 24px 40px;
  flex: 1;
  overflow-y: auto;
}
.login-logo {
  height: 70px;
  margin-bottom: 18px;
  filter: drop-shadow(0 4px 20px rgba(233,75,77,0.55));
}
.login-title {
  font-size: 30px;
  font-weight: 900;
  letter-spacing: -1px;
  margin-bottom: 5px;
}
.login-sub {
  color: var(--muted);
  font-size: 15px;
  margin-bottom: 36px;
}
.driver-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  width: 100%;
  max-width: 420px;
}
.driver-login-card {
  background: var(--bg2);
  border: 1.5px solid var(--border);
  border-radius: 20px;
  padding: 24px 16px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
  position: relative;
  overflow: hidden;
}
.driver-login-card::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(233,75,77,0.12), transparent 60%);
  opacity: 0;
  transition: opacity 0.3s;
  border-radius: inherit;
}
.driver-login-card:active { transform: scale(0.94); }
.driver-login-card:hover  { border-color: rgba(233,75,77,0.5); box-shadow: 0 8px 28px rgba(233,75,77,0.18); }
.driver-login-card:hover::after { opacity: 1; }
.driver-card-emoji { font-size: 38px; line-height: 1; position: relative; z-index: 1; }
.driver-card-name  { font-size: 13px; font-weight: 700; text-align: center; position: relative; z-index: 1; }
.driver-card-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  background: var(--red);
  color: white;
  font-size: 10px;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 50px;
  display: none;
  z-index: 2;
}
.driver-card-badge.visible { display: block; }

/* ═══════════════════════════════════════════
   SCREEN 2 — ORDERS LIST
═══════════════════════════════════════════ */
.delivery-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.driver-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(233,75,77,0.12);
  border: 1px solid rgba(233,75,77,0.3);
  border-radius: 50px;
  padding: 8px 18px;
  font-weight: 700;
  font-size: 14px;
  color: var(--red);
}
.online-dot {
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 10px var(--success);
  animation: pulse-dot 2s ease-in-out infinite;
}
@keyframes pulse-dot {
  0%, 100% { box-shadow: 0 0 6px var(--success); }
  50%       { box-shadow: 0 0 20px var(--success); }
}

/* Sin pedidos */
.no-orders-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 30px;
  text-align: center;
  position: relative;
}
.no-orders-icon {
  font-size: 64px;
  margin-bottom: 20px;
  animation: float 3s ease-in-out infinite;
}
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50%       { transform: translateY(-12px); }
}
.no-orders-state h2 { font-size: 22px; font-weight: 800; margin-bottom: 10px; }
.no-orders-state p  { color: var(--muted); font-size: 14px; max-width: 260px; line-height: 1.6; }
.pulse-ring {
  position: absolute;
  width: 160px; height: 160px;
  border-radius: 50%;
  border: 2px solid rgba(168,85,247,0.15);
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  animation: pulse-ring 2.5s ease-out infinite;
  pointer-events: none;
}
@keyframes pulse-ring {
  0%   { transform: translate(-50%, -50%) scale(0.5); opacity: 0.8; }
  100% { transform: translate(-50%, -50%) scale(2.2); opacity: 0; }
}

/* Lista de pedidos */
.delivery-list {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.delivery-list::-webkit-scrollbar { width: 4px; }
.delivery-list::-webkit-scrollbar-thumb { background: var(--bg3); border-radius: 10px; }

/* Cards de pedido */
.delivery-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 20px;
  overflow: hidden;
  animation: slideIn 0.35s cubic-bezier(0.22, 1, 0.36, 1) forwards;
  box-shadow: 0 4px 20px rgba(0,0,0,0.35);
}
@keyframes slideIn {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}
.card-banner {
  background: linear-gradient(135deg, #b91c1c, var(--red));
  padding: 13px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.card-banner-id   { font-size: 12px; font-weight: 800; color: rgba(255,255,255,0.85); letter-spacing: 1px; text-transform: uppercase; }
.card-banner-time { font-size: 11px; color: rgba(255,255,255,0.55); }

.card-body { padding: 18px; display: flex; flex-direction: column; gap: 14px; }

.info-block { display: flex; gap: 12px; align-items: flex-start; }
.info-icon {
  width: 38px; height: 38px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 17px; flex-shrink: 0;
}
.info-icon.phone   { background: rgba(37,211,102,0.12); }
.info-icon.address { background: rgba(168,85,247,0.12); }
.info-icon.order   { background: rgba(233,75,77,0.12); }
.info-label { font-size: 10px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); font-weight: 800; margin-bottom: 2px; }
.info-value { font-size: 15px; font-weight: 700; line-height: 1.35; }
.info-value.phone-val { color: var(--success); font-size: 17px; }

.items-summary { display: flex; flex-direction: column; gap: 5px; margin-top: 4px; }
.item-line { display: flex; justify-content: space-between; font-size: 13px; gap: 8px; }
.item-line-left { display: flex; gap: 7px; flex: 1; }
.item-qty-badge {
  background: rgba(233,75,77,0.15);
  color: var(--red);
  font-size: 10px; font-weight: 800;
  padding: 2px 7px; border-radius: 50px;
  height: fit-content; white-space: nowrap; align-self: flex-start; margin-top: 1px;
}
.item-name-text { font-weight: 600; }
.item-meta-text { font-size: 11px; color: var(--muted); display: block; margin-top: 1px; }
.item-price-text { font-weight: 700; color: var(--success); white-space: nowrap; }

.card-divider { height: 1px; background: var(--border); }

.card-total-row {
  display: flex; justify-content: space-between; align-items: center;
  padding-top: 12px; border-top: 1px solid var(--border);
}
.card-total-label  { font-size: 12px; color: var(--muted); font-weight: 600; }
.card-total-amount { font-size: 22px; font-weight: 900; color: var(--success); }
.payment-pill {
  display: inline-flex; align-items: center; gap: 5px;
  background: rgba(245,158,11,0.1); border: 1px solid rgba(245,158,11,0.3);
  color: var(--warning); font-size: 11px; font-weight: 700;
  padding: 4px 11px; border-radius: 50px;
}

/* Botón navegar */
.nav-btn {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; padding: 15px;
  background: linear-gradient(135deg, #b91c1c, var(--red));
  color: white; border: none; border-radius: 14px;
  font-family: inherit; font-size: 15px; font-weight: 800;
  cursor: pointer; transition: transform 0.15s, filter 0.15s;
  letter-spacing: 0.3px;
}
.nav-btn:active { transform: scale(0.97); filter: brightness(0.88); }

.call-btn {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; padding: 13px;
  background: rgba(37,211,102,0.1);
  border: 1px solid rgba(37,211,102,0.3);
  color: var(--success); border-radius: 14px;
  font-family: inherit; font-size: 14px; font-weight: 700;
  cursor: pointer; text-decoration: none;
  transition: background 0.2s;
}
.call-btn:active { background: rgba(37,211,102,0.2); }

/* ═══════════════════════════════════════════
   SCREEN 3 — GPS NAVIGATION
═══════════════════════════════════════════ */
#screen-nav { position: fixed; inset: 0; z-index: 500; }

/* El mapa ocupa todo */
#nav-map {
  position: absolute;
  inset: 0;
  z-index: 1;
  background: #111;
}

/* Leaflet dark tile */
#screen-nav .leaflet-tile {
  filter: brightness(0.75) saturate(1.2) hue-rotate(180deg) invert(1);
}
#screen-nav .leaflet-container { background: #1a1a2e !important; }
#screen-nav .leaflet-control-attribution { display: none !important; }

/* Barra superior — instrucción activa */
.nav-top-bar {
  position: absolute;
  top: 0; left: 0; right: 0;
  z-index: 10;
  padding: 52px 16px 16px;   /* espacio status bar */
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: linear-gradient(to bottom, rgba(0,0,0,0.95) 0%, rgba(0,0,0,0.6) 60%, transparent 100%);
  transition: all 0.5s ease;
}
.nav-close-btn {
  background: rgba(255,255,255,0.12);
  border-color: rgba(255,255,255,0.15);
  margin-top: 2px;
  flex-shrink: 0;
}
.nav-instruction {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 14px;
  background: rgba(20,20,20,0.85);
  backdrop-filter: blur(16px);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 18px;
  padding: 14px 16px;
}
.nav-inst-icon { font-size: 28px; flex-shrink: 0; }
.nav-inst-main { font-size: 16px; font-weight: 800; line-height: 1.25; }
.nav-inst-sub  { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* Botón recentrar */
.recenter-btn {
  position: absolute;
  right: 16px;
  bottom: 320px;            /* encima del bottom sheet */
  z-index: 10;
  width: 50px; height: 50px;
  border-radius: 50%;
  background: var(--bg2);
  border: 1px solid var(--border);
  color: white; font-size: 22px;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(0,0,0,0.5);
  display: flex; align-items: center; justify-content: center;
  transition: transform 0.15s;
}
.recenter-btn:active { transform: scale(0.9); }

/* Bottom Sheet */
.nav-bottom-sheet {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  z-index: 10;
  background: var(--bg2);
  border-top-left-radius: 26px;
  border-top-right-radius: 26px;
  border-top: 1px solid var(--border);
  box-shadow: 0 -20px 60px rgba(0,0,0,0.7);
  padding: 10px 0 0;
  /* altura variable: expandible */
  max-height: 75dvh;
  overflow-y: auto;
  /* transición de entrada */
  transform: translateY(100%);
  transition: transform 0.5s cubic-bezier(0.16, 1, 0.3, 1);
  animation: sheetUp 0.6s cubic-bezier(0.16, 1, 0.3, 1) 0.3s forwards;
}
.nav-bottom-sheet.minimized {
  transform: translateY(calc(100% - 45px)) !important;
}
@keyframes sheetUp {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}
.nav-bottom-sheet::-webkit-scrollbar { display: none; }

.sheet-handle {
  width: 40px; height: 5px;
  background: rgba(255,255,255,0.25);
  border-radius: 10px;
  margin: 0 auto 8px;
  cursor: grab;
  touch-action: none;
}
.sheet-handle:active { cursor: grabbing; }

.nav-bottom-sheet.minimized {
  /* La clase se usa para lógica, el transform se maneja en JS o via transición */
}

/* Resumen de ruta */
.route-summary {
  display: flex;
  align-items: center;
  gap: 0;
  padding: 0 20px 16px;
  border-bottom: 1px solid var(--border);
}
.route-stat {
  flex: 1;
  text-align: center;
}
.route-stat-val   { font-size: 20px; font-weight: 900; color: var(--red); }
.route-stat-label { font-size: 10px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; margin-top: 2px; }
.route-divider    { width: 1px; height: 36px; background: var(--border); }

/* Info del cliente */
.client-strip {
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 11px;
  border-bottom: 1px solid var(--border);
}
.client-info-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  font-size: 14px;
}
.client-icon { font-size: 16px; flex-shrink: 0; margin-top: 1px; }
.client-name    { font-weight: 800; font-size: 16px; color: var(--text); }
.client-addr    { color: var(--text); line-height: 1.4; font-weight: 600; }
.client-items   { color: var(--muted); line-height: 1.5; }
.client-payment {
  color: var(--warning); font-weight: 700;
  background: rgba(245,158,11,0.1);
  border: 1px solid rgba(245,158,11,0.25);
  padding: 3px 12px; border-radius: 50px;
  font-size: 13px;
}

/* Acciones en el nav */
.nav-actions {
  display: flex;
  gap: 12px;
  padding: 16px 20px 30px;  /* espacio home indicator */
}
.nav-action-btn {
  flex: 1;
  padding: 14px;
  border-radius: 14px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  transition: transform 0.15s, filter 0.15s;
  text-decoration: none;
}
.nav-action-btn:active { transform: scale(0.96); filter: brightness(0.85); }
.nav-action-btn.call {
  background: rgba(37,211,102,0.12);
  border: 1px solid rgba(37,211,102,0.3);
  color: var(--success);
}
.nav-action-btn.whatsapp {
  background: rgba(37,211,102,0.9);
  color: #000;
}

/* Botón marcar entregado */
.deliver-btn {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; padding: 15px;
  background: linear-gradient(135deg, #166534, var(--success));
  color: white; border: none; border-radius: 14px;
  font-family: inherit; font-size: 15px; font-weight: 800;
  cursor: pointer; transition: transform 0.15s, filter 0.15s;
  letter-spacing: 0.3px;
}
.deliver-btn:active { transform: scale(0.97); filter: brightness(0.85); }

/* Marcadores personalizados Leaflet */
.marker-driver {
  width: 20px; height: 20px;
  background: var(--blue);
  border-radius: 50%;
  border: 3px solid #fff;
  box-shadow: 0 0 0 4px rgba(59,130,246,0.35), 0 2px 10px rgba(0,0,0,0.5);
  animation: driver-pulse 2s ease-in-out infinite;
}
@keyframes driver-pulse {
  0%, 100% { box-shadow: 0 0 0 4px rgba(59,130,246,0.35), 0 2px 10px rgba(0,0,0,0.5); }
  50%       { box-shadow: 0 0 0 8px rgba(59,130,246,0.12), 0 2px 10px rgba(0,0,0,0.5); }
}
.marker-dest {
  width: 20px; height: 20px;
  background: var(--red);
  border-radius: 50%;
  border: 3px solid #fff;
  box-shadow: 0 0 0 4px rgba(233,75,77,0.3), 0 2px 10px rgba(0,0,0,0.5);
}

/* Línea de ruta personalizada */
.leaflet-routing-container { display: none !important; } /* Ocultamos el panel de LRM */

/* Pulse ring (pantalla sin pedidos) */
.pulse-ring {
  position: absolute;
  width: 160px; height: 160px;
  border-radius: 50%;
  border: 2px solid rgba(233,75,77,0.15);
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  animation: pulse-ring 2.5s ease-out infinite;
  pointer-events: none;
}
