/* ============================================================
   WEBAPP DE CHOFER — ShuttleCRM · Estilos de las 11 pantallas
   ============================================================
   Base 390px (diseños de Fany), mobile-first, español México.

   TOKENS DE COLOR FIJOS (nota B3 de Memo): estos hex están verificados
   AA por muestreo de píxeles (badge verde 4.55:1 y ámbar 4.54:1 pasan
   JUSTO el umbral 4.5) — NO retocarlos sin re-verificar contraste.
   ============================================================ */
:root {
    /* Tokens AA verificados (B3) — NO MODIFICAR sin re-verificar */
    --verde:  #15803D;   /* TURNO ACTIVO / EN CURSO / Ya llegué */
    --rojo:   #B91C1C;   /* Finalizar servicio / Terminar turno / GPS off */
    --ambar:  #B45309;   /* banners de precaución / notas de operaciones */
    --azul:   #1D4ED8;   /* acción primaria / Voy en camino */

    /* Paleta de soporte (del diseño de Fany) */
    --navy:        #0F172A;  /* texto principal / horas grandes (17.85:1) */
    --azul-badge:  #1E40AF;  /* badge ASIGNADO (7.9:1 sobre azul claro) */
    --muted:       #475569;  /* texto secundario (6.93:1) */
    --fondo:       #F1F5F9;  /* fondo general */
    --blanco:      #FFFFFF;
    --borde:       #E2E8F0;
    --verde-suave: #EAF7EF;  /* fondo del badge TURNO ACTIVO */
    --azul-suave:  #DBEAFE;  /* fondo del badge ASIGNADO */
    --ambar-suave: #FEF3C7;  /* fondo de banners ámbar */
    --rojo-suave:  #FDECEC;  /* fondo del icono GPS denegado */
    --radius:      14px;
    --radius-sm:   10px;
    --sombra:      0 1px 4px rgba(15, 23, 42, .08);
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --mono: "SF Mono", "Roboto Mono", Consolas, monospace;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { font-size: 16px; }
body {
    font-family: var(--font);
    background: var(--fondo);
    color: var(--navy);
    line-height: 1.45;
    -webkit-font-smoothing: antialiased;
    /* Safe areas de iPhone (notch / home indicator) */
    padding-bottom: env(safe-area-inset-bottom);
}
button { font-family: inherit; cursor: pointer; }
a { color: var(--azul); }

/* Foco visible SIEMPRE (WCAG 2.4.7) */
:focus-visible { outline: 3px solid var(--azul); outline-offset: 2px; }
[hidden] { display: none !important; }
svg { flex-shrink: 0; vertical-align: middle; }

/* ---------- Carga inicial ---------- */
.cargando-inicial { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; color: var(--muted); }
.spinner { width: 34px; height: 34px; border: 3.5px solid var(--borde); border-top-color: var(--azul); border-radius: 50%; animation: girar .8s linear infinite; }
@keyframes girar { to { transform: rotate(360deg); } }

/* ---------- Banner offline global ---------- */
.banner-offline { position: fixed; bottom: 0; left: 0; right: 0; z-index: 100;
    background: var(--navy); color: #fff; text-align: center; font-size: .88rem; font-weight: 600;
    padding: 11px 16px calc(11px + env(safe-area-inset-bottom)); }

/* ---------- Header de la app ---------- */
.ch-header { background: var(--blanco); border-bottom: 1px solid var(--borde);
    display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; }
.ch-logo { font-weight: 800; font-size: 1.05rem; color: var(--navy); }
.ch-logo b { color: var(--azul); }
.ch-logo small { color: var(--muted); font-weight: 600; font-size: .85rem; }
.badge-turno { display: inline-flex; align-items: center; gap: 6px;
    background: var(--verde-suave); color: var(--verde); border: 1px solid #BBE5C9;
    border-radius: 999px; padding: 5px 12px; font-size: .72rem; font-weight: 800; letter-spacing: .5px; }
.badge-turno::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--verde); }

/* ---------- Status bar de GPS ---------- */
.gps-bar { background: #EEF2FB; color: var(--azul-badge); font-size: .82rem; font-weight: 600;
    display: flex; align-items: center; gap: 8px; padding: 8px 16px; }
.gps-bar .punto { width: 8px; height: 8px; border-radius: 50%; background: var(--azul); }
.gps-bar.gps-error { background: var(--rojo-suave); color: var(--rojo); }
.gps-bar.gps-error .punto { background: var(--rojo); }

/* ---------- Contenido ---------- */
.ch-main { padding: 18px 16px calc(84px + env(safe-area-inset-bottom)); max-width: 480px; margin: 0 auto; }
.sin-tabs { padding-bottom: 24px; }

.titulo-vista { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 16px; }
.titulo-vista h1 { font-size: 1.5rem; font-weight: 800; }
.titulo-vista .fecha { color: var(--muted); font-size: .88rem; font-weight: 600; }

/* ---------- Login (01) ---------- */
.login-wrap { min-height: 100vh; display: flex; flex-direction: column; justify-content: center; padding: 24px; max-width: 440px; margin: 0 auto; }
.login-logo { text-align: center; margin-bottom: 34px; }
.login-icono { width: 74px; height: 74px; border-radius: 20px; background: var(--azul); color: #fff;
    display: inline-flex; align-items: center; justify-content: center; margin-bottom: 16px; }
.login-logo h1 { font-size: 1.5rem; font-weight: 800; }
.login-logo h1 b { color: var(--azul); }
.login-logo p { color: var(--muted); font-size: .95rem; }
.campo { margin-bottom: 16px; }
.campo label { display: block; font-size: .74rem; font-weight: 800; letter-spacing: .8px; color: var(--muted); text-transform: uppercase; margin-bottom: 7px; }
.campo-wrap { position: relative; display: flex; align-items: center; }
.campo-ico { position: absolute; left: 13px; color: var(--muted); display: inline-flex; pointer-events: none; }
.campo input { width: 100%; border: 1.5px solid var(--borde); border-radius: var(--radius-sm);
    padding: 14px 14px 14px 42px; font-size: 1rem; color: var(--navy); background: var(--blanco); }
.campo input:focus { outline: none; border-color: var(--azul); }
.campo input[aria-invalid="true"] { border-color: var(--rojo); }
.check-row { display: flex; align-items: center; gap: 10px; margin: 4px 0 20px; font-size: .95rem; }
.check-row input { width: 20px; height: 20px; accent-color: var(--azul); }
.login-ayuda { text-align: center; color: var(--muted); font-size: .88rem; margin-top: 18px; }

/* Hint de instalación de la PWA (login): Android botón, iOS instrucciones */
.hint-instalar { margin-top: 20px; padding: 12px 14px; border-radius: var(--radius-sm);
    background: var(--azul-suave, #EFF6FF); border: 1px solid #BFDBFE; color: #1E3A8A;
    font-size: .9rem; text-align: center; line-height: 1.5; }
.btn-hint-instalar { display: inline-block; margin-left: 8px; min-height: 40px; padding: 0 18px;
    font-size: .9rem; font-weight: 700; color: var(--blanco); background: var(--azul);
    border: 0; border-radius: 10px; cursor: pointer; }
.error-form { background: var(--rojo-suave); color: var(--rojo); border-radius: var(--radius-sm);
    padding: 12px 14px; font-size: .9rem; font-weight: 600; margin-bottom: 14px; }

/* ---------- Botones ---------- */
/* Táctil: TODOS los botones de acción ≥48px de alto (validación de Memo) */
.btn { display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%;
    min-height: 52px; border: none; border-radius: var(--radius); font-size: 1.02rem; font-weight: 700;
    transition: filter .12s; }
.btn:active { filter: brightness(.92); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-azul   { background: var(--azul); color: #fff; }
.btn-verde  { background: var(--verde); color: #fff; }
/* Finalizar/Terminar: rojo OUTLINE (decisión documentada del diseño) */
.btn-rojo-outline { background: var(--blanco); color: var(--rojo); border: 1.5px solid var(--rojo); }
.btn-neutro { background: var(--blanco); color: var(--navy); border: 1.5px solid var(--borde); }
.btn-grande { min-height: 58px; }

/* ---------- Cards genéricas ---------- */
.card { background: var(--blanco); border: 1px solid var(--borde); border-radius: var(--radius);
    box-shadow: var(--sombra); }

/* ---------- Unidad (02) ---------- */
.saludo { font-size: 1.5rem; font-weight: 800; margin-bottom: 6px; }
.saludo-sub { color: var(--muted); margin-bottom: 18px; }
.unidad-lista { display: flex; flex-direction: column; gap: 12px; margin-bottom: 16px; }
.unidad-card { display: flex; align-items: center; gap: 14px; padding: 16px; cursor: pointer;
    background: var(--blanco); border: 2px solid var(--borde); border-radius: var(--radius); text-align: left; width: 100%; }
.unidad-card.sel { border-color: var(--azul); background: #EEF2FB; }
.unidad-ico { color: var(--azul); }
.unidad-info { flex: 1; min-width: 0; }
.unidad-cod { font-family: var(--mono); font-weight: 800; font-size: 1.05rem; }
.unidad-desc { color: var(--muted); font-size: .88rem; }
.unidad-radio { width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--borde);
    display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
/* Semántica de radio (fix Clemente): NO seleccionada = círculo vacío, sin icono */
.unidad-radio svg { visibility: hidden; }
.unidad-card.sel .unidad-radio { background: var(--azul); border-color: var(--azul); color: #fff; }
.unidad-card.sel .unidad-radio svg { visibility: visible; }
.nota-sistema { background: #EEF2FB; border: 1px solid #C7D6F5; border-radius: var(--radius-sm);
    color: var(--azul-badge); font-size: .88rem; padding: 13px 14px; }
/* Barra fija inferior con el CTA (02) */
.cta-fija { position: fixed; bottom: 0; left: 0; right: 0; background: var(--blanco);
    border-top: 1px solid var(--borde); padding: 14px 16px calc(14px + env(safe-area-inset-bottom)); }
.con-cta-fija { padding-bottom: 110px; }

/* ---------- Cards de servicio (03/03b) ---------- */
.srv-lista { display: flex; flex-direction: column; gap: 14px; }
.srv-card { display: block; width: 100%; text-align: left; padding: 16px; position: relative;
    background: var(--blanco); border: 2px solid var(--borde); border-radius: var(--radius); box-shadow: var(--sombra); }
.srv-card.en-curso { border-color: var(--verde); }
.srv-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.srv-id { font-family: var(--mono); color: var(--azul-badge); font-weight: 800; font-size: .88rem; }
.badge { border-radius: 999px; padding: 4px 12px; font-size: .7rem; font-weight: 800; letter-spacing: .6px; }
.badge-asignado { background: var(--azul-suave); color: var(--azul-badge); }
.badge-encurso  { background: var(--verde); color: #fff; }
/* Hora ENORME — lo primero que se lee (regla de 2 segundos de Memo) */
.srv-hora { font-size: 2rem; font-weight: 900; letter-spacing: -0.5px; line-height: 1.1; }
.srv-hora small { font-size: .85rem; font-weight: 600; color: var(--muted); margin-left: 6px; }
.srv-ruta { display: flex; align-items: flex-start; gap: 8px; margin: 8px 0; font-weight: 700; font-size: .95rem; }
.srv-ruta svg { color: var(--azul); margin-top: 2px; }
.srv-meta { display: flex; gap: 16px; color: var(--muted); font-size: .85rem; font-weight: 600; flex-wrap: wrap; }
.srv-meta span { display: inline-flex; align-items: center; gap: 5px; }

/* Bloqueo (03b): cards atenuadas + tooltip candado + banner ámbar */
.srv-card.bloqueada { opacity: .55; pointer-events: none; }
.lock-pill { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -60%);
    background: var(--navy); color: #fff; border-radius: 999px; padding: 8px 14px;
    font-size: .8rem; font-weight: 700; display: inline-flex; align-items: center; gap: 7px;
    white-space: nowrap; opacity: 1; }
.banner-ambar { background: var(--ambar-suave); border: 1px solid #F1D48A; border-radius: var(--radius-sm);
    color: var(--ambar); font-size: .9rem; padding: 13px 14px; margin-top: 16px; display: flex; gap: 8px; }
.banner-ambar b { font-weight: 800; }

/* ---------- Detalle (04) ---------- */
.volver-row { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.btn-volver { width: 42px; height: 42px; min-height: 42px; border-radius: 50%; background: var(--blanco);
    border: 1px solid var(--borde); display: inline-flex; align-items: center; justify-content: center;
    color: var(--navy); flex-shrink: 0; }
.volver-info .srv-id { display: block; }
.volver-info .badge { margin-top: 3px; display: inline-block; }
.detalle-tabla { padding: 4px 16px; }
.det-row { display: flex; justify-content: space-between; align-items: baseline; gap: 14px;
    padding: 13px 0; border-bottom: 1px solid var(--fondo); }
.det-row:last-child { border-bottom: none; }
.det-label { color: var(--muted); font-size: .88rem; flex-shrink: 0; }
.det-valor { font-weight: 700; text-align: right; font-size: .95rem; }
.det-valor.mono { font-family: var(--mono); }
.det-valor.destacado { color: var(--azul-badge); font-weight: 800; letter-spacing: .5px; }
.det-hora { font-size: 1.2rem; font-weight: 900; }
.nota-privacidad { background: #EEF2FB; border: 1px solid #C7D6F5; border-radius: var(--radius-sm);
    color: var(--azul-badge); font-size: .86rem; padding: 13px 14px; margin-top: 14px; display: flex; gap: 8px; }

/* ---------- Servicio activo (05/05b) ---------- */
.activo-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; }
/* Fix Clemente: mismo spacing del volver de la 04, sin encimarse al código */
.activo-volver { margin-bottom: 0; min-width: 0; }
.activo-volver .srv-id { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.activo-resumen { padding: 16px; margin-bottom: 12px; }
.ar-top { display: flex; justify-content: space-between; gap: 14px; margin-bottom: 10px; }
.ar-col small { display: block; color: var(--muted); font-size: .68rem; font-weight: 800; letter-spacing: .8px; }
.ar-hora { font-size: 1.7rem; font-weight: 900; line-height: 1.15; }
.ar-letrero { color: var(--azul-badge); font-weight: 800; font-size: 1rem; text-align: right; }
.ar-bottom { display: flex; justify-content: space-between; gap: 10px; color: var(--muted);
    font-size: .86rem; font-weight: 600; border-top: 1px solid var(--fondo); padding-top: 10px; flex-wrap: wrap; }
.ar-bottom span { display: inline-flex; align-items: center; gap: 6px; }
/* Link "Ver ruta en Google Maps" — abre la app nativa, sin API key */
.btn-maps { background: var(--blanco); color: var(--azul); border: 1.5px solid #C7D6F5;
    font-weight: 800; margin-bottom: 12px; text-decoration: none; }
/* Notas del pasajero (azul) y de operaciones (ámbar) — actualización de Fany */
.nota-tarjeta { border-radius: var(--radius-sm); padding: 12px 14px 12px 16px; margin-bottom: 12px;
    font-size: .92rem; position: relative; }
.nota-tarjeta small { display: flex; align-items: center; gap: 6px; font-size: .68rem;
    font-weight: 800; letter-spacing: .8px; margin-bottom: 4px; }
.nota-pasajero { background: var(--blanco); border: 1px solid var(--borde); border-left: 4px solid var(--azul); }
.nota-pasajero small { color: var(--azul-badge); }
.nota-operaciones { background: var(--ambar-suave); border: 1px solid #F1D48A; border-left: 4px solid var(--ambar); color: var(--ambar); font-weight: 600; }
.nota-operaciones small { color: var(--ambar); }
/* Avisos al pasajero */
.avisos-label { color: var(--muted); font-size: .72rem; font-weight: 800; letter-spacing: .8px; margin: 16px 0 10px; }
.avisos { display: flex; flex-direction: column; gap: 10px; }
.avisos .btn { min-height: 58px; }
/* Estado "enviado" (05b): botón se vuelve pill neutra + confirmación verde */
.aviso-enviado { background: var(--fondo); color: var(--muted); border: 1px solid var(--borde);
    border-radius: var(--radius); min-height: 52px; display: flex; align-items: center;
    justify-content: center; gap: 8px; font-weight: 700; font-size: .95rem; }
.aviso-enviado svg { color: var(--verde); }
.pill-confirmacion { background: var(--verde-suave); border: 1px solid #BBE5C9; color: var(--verde);
    border-radius: var(--radius-sm); padding: 9px 14px; font-size: .84rem; font-weight: 700; text-align: center; }
/* Finalizar: SEPARADO de los avisos (divisor punteado + espacio — validación táctil de Memo) */
.divisor-finalizar { border: none; border-top: 2px dashed var(--borde); margin: 26px 0 16px; }

/* ---------- Historial (06) ---------- */
.tabs-hist { display: flex; gap: 10px; margin-bottom: 16px; }
.tab-hist { display: inline-flex; align-items: center; gap: 7px; border-radius: 999px; padding: 10px 18px;
    font-weight: 700; font-size: .9rem; background: var(--blanco); border: 1.5px solid var(--borde); color: var(--muted); }
.tab-hist.activa { background: var(--navy); border-color: var(--navy); color: #fff; }
.turno-actual { background: #EEF2FB; border: 1px solid #C7D6F5; border-radius: var(--radius);
    padding: 14px 16px; margin-bottom: 16px; }
.turno-actual small { display: block; color: var(--azul-badge); font-size: .68rem; font-weight: 800; letter-spacing: .8px; margin-bottom: 4px; }
.turno-actual .rango { font-weight: 900; font-size: 1.05rem; }
.turno-actual .sub { color: var(--azul-badge); font-size: .86rem; font-weight: 700; margin-top: 2px; }
.hist-lista { display: flex; flex-direction: column; gap: 10px; }
.hist-item { display: flex; align-items: center; gap: 12px; padding: 13px 14px; }
.hist-check { width: 38px; height: 38px; border-radius: var(--radius-sm); background: var(--verde-suave);
    color: var(--verde); display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.hist-info { flex: 1; min-width: 0; }
.hist-info .srv-id { font-size: .8rem; }
.hist-info .cuando { color: var(--muted); font-size: .8rem; font-weight: 600; margin-left: 6px; }
.hist-ruta { font-weight: 700; font-size: .92rem; }
.hist-pax { color: var(--muted); font-weight: 700; font-size: .88rem; flex-shrink: 0; }
/* Agrupador por día (tab "Por día") */
.dia-grupo { color: var(--muted); font-size: .74rem; font-weight: 800; letter-spacing: .8px; margin: 14px 0 8px; }

/* ---------- Perfil (07) ---------- */
.perfil-head { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; }
.avatar { width: 56px; height: 56px; border-radius: var(--radius); background: var(--azul); color: #fff;
    font-weight: 800; font-size: 1.2rem; display: inline-flex; align-items: center; justify-content: center; }
.perfil-head h1 { font-size: 1.3rem; font-weight: 800; }
.perfil-head p { color: var(--muted); font-size: .9rem; }
.perfil-datos { padding: 4px 16px; margin-bottom: 14px; }
.perfil-datos .det-valor.verde { color: var(--verde); }
.perfil-acciones { display: flex; flex-direction: column; gap: 12px; }

/* ---------- Sin servicios (08) ---------- */
.vacio { text-align: center; padding: 60px 20px 30px; }
.vacio-icono { width: 88px; height: 88px; border-radius: 22px; border: 2.5px dashed var(--borde);
    color: var(--muted); display: inline-flex; align-items: center; justify-content: center; margin-bottom: 22px; }
.vacio h2 { font-size: 1.25rem; font-weight: 800; margin-bottom: 8px; }
.vacio p { color: var(--muted); max-width: 300px; margin: 0 auto 22px; }

/* ---------- GPS denegado (09) ---------- */
.gps-den { text-align: center; padding: 40px 20px; max-width: 420px; margin: 0 auto; }
.gps-den-icono { width: 92px; height: 92px; border-radius: 24px; background: var(--rojo-suave);
    border: 1.5px solid #F3C6C6; color: var(--rojo); display: inline-flex; align-items: center;
    justify-content: center; margin-bottom: 22px; }
.gps-den h2 { font-size: 1.35rem; font-weight: 800; margin-bottom: 10px; }
.gps-den .explica { color: var(--muted); margin-bottom: 22px; }
.gps-den .explica b { color: var(--navy); }
.pasos { text-align: left; padding: 16px 18px; margin-bottom: 18px; }
.pasos small { display: block; color: var(--muted); font-size: .7rem; font-weight: 800; letter-spacing: .8px; margin-bottom: 10px; }
.pasos ol { list-style: none; }
.pasos li { padding: 6px 0; font-weight: 600; font-size: .95rem; }
.pasos li b { font-weight: 800; }
.pasos li .num { color: var(--azul); font-weight: 900; margin-right: 8px; }
.gps-den .coordinador { color: var(--muted); font-size: .9rem; margin-top: 16px; }

/* ---------- Tab bar inferior ---------- */
.tabbar { position: fixed; bottom: 0; left: 0; right: 0; z-index: 50; background: var(--blanco);
    border-top: 1px solid var(--borde); display: flex;
    padding-bottom: env(safe-area-inset-bottom); }
.tab { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
    padding: 10px 0 8px; border: none; background: none; color: var(--muted); font-size: .74rem; font-weight: 700; }
.tab.activa { color: var(--azul); }

/* ---------- Modal de confirmación (B1 de Memo) ---------- */
.modal-fondo { position: fixed; inset: 0; z-index: 90; background: rgba(15,23,42,.55);
    display: flex; align-items: flex-end; justify-content: center; }
.modal { background: var(--blanco); border-radius: var(--radius) var(--radius) 0 0; width: 100%;
    max-width: 480px; padding: 22px 20px calc(22px + env(safe-area-inset-bottom)); }
.modal h3 { font-size: 1.15rem; font-weight: 800; margin-bottom: 8px; }
.modal p { color: var(--muted); margin-bottom: 18px; }
.modal .btn { margin-bottom: 10px; }
/* En la confirmación, la acción destructiva es SÓLIDA roja (intencional:
   dentro del modal el usuario ya está decidiendo — el outline vive en la vista) */
.btn-rojo-solido { background: var(--rojo); color: #fff; }

/* ---------- Toast de error de acción ---------- */
.toast { position: fixed; bottom: calc(76px + env(safe-area-inset-bottom)); left: 16px; right: 16px; z-index: 95;
    background: var(--navy); color: #fff; border-radius: var(--radius-sm); padding: 13px 16px;
    font-size: .9rem; font-weight: 600; text-align: center; }

/* ---------- Pantallas más anchas (tablet en cabina) ---------- */
@media (min-width: 560px) {
    .ch-main { max-width: 520px; }
}
