/* ===== Botón flotante (burbuja tipo WhatsApp) ===== */
.chat-fab {
  position:fixed; right:20px; bottom:calc(20px + env(safe-area-inset-bottom)); z-index:9990;
  width:60px; height:60px; border-radius:50%; border:0; cursor:pointer; color:#fff;
  background:linear-gradient(135deg,#0ea5e9,#0369a1);
  box-shadow:0 8px 24px rgba(2,132,199,.45), 0 2px 6px rgba(0,0,0,.2);
  display:flex; align-items:center; justify-content:center;
  transition:transform .15s ease, box-shadow .15s ease;
}
.chat-fab:hover { transform:translateY(-2px) scale(1.05); box-shadow:0 14px 32px rgba(2,132,199,.5); }
.chat-fab:active { transform:scale(.95); }
.chat-fab svg { width:29px; height:29px; position:relative; z-index:1; }
/* anillo pulsante para llamar la atención, como las burbujas de soporte web */
.chat-fab::before { content:""; position:absolute; inset:0; border-radius:50%; background:linear-gradient(135deg,#0ea5e9,#0369a1); z-index:0; animation:fab-pulse 2.6s ease-out infinite; }
@keyframes fab-pulse { 0% { transform:scale(1); opacity:.45; } 70% { transform:scale(1.6); opacity:0; } 100% { opacity:0; } }
.chat-fab-badge { position:absolute; top:-3px; right:-3px; min-width:22px; height:22px; padding:0 6px; border-radius:11px; background:#ef4444; color:#fff; font-size:12px; font-weight:700; display:flex; align-items:center; justify-content:center; border:2.5px solid #fff; box-shadow:0 1px 4px rgba(0,0,0,.3); z-index:2; }
@media (max-width:560px) { .chat-fab { width:56px; height:56px; right:16px; bottom:calc(16px + env(safe-area-inset-bottom)); } .chat-fab svg { width:27px; height:27px; } }
@media (prefers-reduced-motion:reduce) { .chat-fab::before { animation:none; } }

/* ===== Chat interno — ventana flotante (chofer y supervisor) — 2026-08-11 ===== */
.chat-overlay { position:fixed; inset:0; z-index:99999; display:none; }
.chat-overlay.abierto { display:flex; align-items:flex-end; justify-content:flex-end; }

/* Ventana flotante (escritorio) */
.chat-win {
  width:390px; height:min(640px, 84vh); margin:0 22px 22px 0;
  background:#eef2f6; border-radius:18px; overflow:hidden;
  display:flex; flex-direction:column; position:relative;
  box-shadow:0 24px 60px -12px rgba(15,23,42,.45), 0 0 0 1px rgba(15,23,42,.06);
  animation:chat-in .18s cubic-bezier(.2,.8,.2,1);
}
@keyframes chat-in { from { opacity:0; transform:translateY(14px) scale(.98); } to { opacity:1; transform:none; } }

.chat-vista { position:absolute; inset:0; display:flex; flex-direction:column; }

/* Barra superior */
.chat-top { display:flex; align-items:center; gap:11px; padding:13px 14px;
  background:linear-gradient(135deg,#0369a1,#0284c7); color:#fff; flex:0 0 auto; }
.chat-back, .chat-x { background:none; border:0; color:#fff; padding:4px; cursor:pointer; display:flex; opacity:.92; border-radius:8px; }
.chat-back:hover, .chat-x:hover { opacity:1; background:rgba(255,255,255,.14); }
.chat-back svg, .chat-x svg { width:22px; height:22px; }
.chat-x { margin-left:auto; }
.chat-top-txt { min-width:0; }
.chat-top-title { font-weight:700; font-size:16px; line-height:1.2; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.chat-top-sub { font-size:12px; opacity:.9; margin-top:1px; }

/* Buscador */
.chat-buscar-wrap { position:relative; flex:0 0 auto; padding:10px 12px 6px; background:#eef2f6; }
.chat-buscar-ic { position:absolute; left:24px; top:50%; transform:translateY(-25%); width:16px; height:16px; color:#94a3b8; pointer-events:none; }
.chat-buscar { width:100%; padding:9px 14px 9px 36px; border:1px solid rgba(0,0,0,.10); border-radius:22px; font-size:14px; font-family:inherit; outline:none; background:#fff; }
.chat-buscar:focus { border-color:#0284c7; box-shadow:0 0 0 3px rgba(2,132,199,.12); }

/* Lista de conversaciones */
.chat-lista { flex:1 1 auto; overflow-y:auto; padding:4px 0 16px; background:#eef2f6; }
.chat-item { display:flex; align-items:center; gap:12px; width:100%; padding:11px 15px; background:none; border:0; text-align:left; cursor:pointer; transition:background .12s; }
.chat-item:hover { background:rgba(2,132,199,.06); }
.chat-item:active { background:rgba(2,132,199,.11); }
.chat-ava { position:relative; width:46px; height:46px; border-radius:50%; background:linear-gradient(135deg,#0ea5e9,#0369a1); color:#fff; font-weight:700; font-size:18px; display:flex; align-items:center; justify-content:center; flex:0 0 auto; box-shadow:0 1px 3px rgba(0,0,0,.15); }
.chat-ava.ava-ia { background:linear-gradient(135deg,#8b5cf6,#6d28d9); }
.chat-ava.ava-grupo { background:linear-gradient(135deg,#06b6d4,#0e7490); }
.chat-ava-sm { width:38px; height:38px; font-size:15px; }
.chat-dot { position:absolute; right:-1px; bottom:-1px; width:13px; height:13px; border-radius:50%; background:#94a3b8; border:2.5px solid #eef2f6; }
.chat-ava-sm .chat-dot { width:11px; height:11px; border-color:#0369a1; }
.chat-dot.st-verde { background:#22c55e; }
.chat-dot.st-amarillo { background:#f59e0b; }
.chat-dot.st-rojo { background:#ef4444; }
.chat-item-txt { flex:1 1 auto; min-width:0; }
.chat-item-row { display:flex; align-items:baseline; justify-content:space-between; gap:8px; }
.chat-item-nom { font-weight:600; color:#0f172a; font-size:15px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.chat-item-hora { flex:0 0 auto; font-size:11px; color:#94a3b8; }
.chat-item-sub { color:#64748b; font-size:12.5px; margin-top:2px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.chat-item-sub.sub-st-verde { color:#16a34a; font-weight:600; }
.chat-item-sub.sub-st-amarillo { color:#d97706; font-weight:600; }
.chat-item-sub.sub-st-rojo { color:#94a3b8; }
.chat-badge { flex:0 0 auto; min-width:20px; height:20px; padding:0 6px; border-radius:10px; background:#22c55e; color:#fff; font-size:12px; font-weight:700; display:inline-flex; align-items:center; justify-content:center; box-shadow:0 1px 2px rgba(0,0,0,.15); }
.chat-sep { padding:12px 16px 5px; font-size:11px; font-weight:700; letter-spacing:.05em; text-transform:uppercase; color:#94a3b8; }
.chat-vacio, .conv-vacio { text-align:center; color:#94a3b8; padding:26px 18px; font-size:13.5px; line-height:1.6; }

/* Estado en el encabezado de la conversación */
.conv-estado { display:inline-flex; align-items:center; gap:5px; font-weight:600; }
.conv-estado-dot { width:8px; height:8px; border-radius:50%; background:currentColor; }
.conv-estado.st-verde { color:#bbf7d0; }
.conv-estado.st-amarillo { color:#fde68a; }
.conv-estado.st-rojo { color:#e2e8f0; }

/* Mensajes */
.conv-mensajes { flex:1 1 auto; overflow-y:auto; padding:12px 12px 4px; display:flex; flex-direction:column; gap:5px;
  background:#dbe4ec; background-image:radial-gradient(rgba(15,23,42,.035) 1px, transparent 1px); background-size:22px 22px; }
.msg { max-width:80%; padding:7px 10px 5px; border-radius:14px; word-wrap:break-word; overflow-wrap:anywhere; box-shadow:0 1px 1px rgba(0,0,0,.06); }
.msg-otro { align-self:flex-start; background:#fff; border-bottom-left-radius:4px; }
.msg-mio { align-self:flex-end; background:#d1f5d3; border-bottom-right-radius:4px; }
.msg-de { font-size:12px; font-weight:700; color:#0891b2; margin-bottom:2px; }
.msg-txt { font-size:14.5px; color:#0f172a; white-space:pre-wrap; line-height:1.35; }
.msg-img { max-width:220px; max-height:280px; border-radius:10px; display:block; }
.msg-video { max-width:240px; border-radius:10px; display:block; }
.msg-audio { width:220px; height:40px; }

/* Reproductor de nota de voz (play/pausa + barra + tiempo) */
.voz { display:flex; align-items:center; gap:10px; min-width:190px; padding:2px 2px 2px 0; }
.voz-btn { flex:0 0 auto; width:40px; height:40px; border-radius:50%; border:0; cursor:pointer; background:linear-gradient(135deg,#0ea5e9,#0369a1); color:#fff; display:flex; align-items:center; justify-content:center; box-shadow:0 2px 5px rgba(2,132,199,.3); }
.msg-mio .voz-btn { background:linear-gradient(135deg,#22c55e,#15803d); box-shadow:0 2px 5px rgba(22,163,74,.3); }
.voz-btn svg { width:22px; height:22px; }
.voz-btn .ic-pause { display:none; }
.voz-btn.playing .ic-play { display:none; }
.voz-btn.playing .ic-pause { display:inline; }
.voz-bar { position:relative; flex:1 1 auto; height:5px; background:rgba(15,23,42,.16); border-radius:3px; cursor:pointer; }
.voz-prog { position:absolute; left:0; top:0; height:100%; width:0; background:#0369a1; border-radius:3px; }
.msg-mio .voz-prog { background:#15803d; }
.voz-cursor { display:none; }
.voz-time { flex:0 0 auto; font-size:11.5px; color:#64748b; font-variant-numeric:tabular-nums; min-width:30px; text-align:right; }
.voz-error .voz-btn { background:#94a3b8; box-shadow:none; }
.msg-meta { font-size:10.5px; color:#94a3b8; text-align:right; margin-top:2px; }
.msg-check { font-weight:700; }
.msg-mio .msg-check { color:#22c55e; }

.conv-typing { min-height:18px; padding:3px 16px; font-size:12.5px; color:#0891b2; font-style:italic; background:#dbe4ec; flex:0 0 auto; display:flex; align-items:center; gap:6px; }
.typing-dots { display:inline-flex; gap:3px; }
.typing-dots i { width:5px; height:5px; border-radius:50%; background:#0891b2; display:inline-block; animation:typing 1.2s infinite ease-in-out; }
.typing-dots i:nth-child(2) { animation-delay:.15s; }
.typing-dots i:nth-child(3) { animation-delay:.3s; }
@keyframes typing { 0%,60%,100% { opacity:.3; transform:translateY(0); } 30% { opacity:1; transform:translateY(-3px); } }
.conv-cargando { text-align:center; color:#94a3b8; padding:20px; }

/* Respuestas rápidas del asistente IA (elegir patente) */
.ia-quick { display:flex; flex-wrap:wrap; gap:6px; margin-top:7px; }
.ia-chip { background:#fff; border:1.5px solid #0284c7; color:#0369a1; font-weight:600; font-size:13px; padding:6px 12px; border-radius:16px; cursor:pointer; transition:background .12s; }
.ia-chip:hover { background:#e0f2fe; }
.ia-chip:active { background:#bae6fd; }

/* Barra de escritura */
.conv-inputbar { display:flex; align-items:flex-end; gap:8px; padding:8px 10px calc(8px + env(safe-area-inset-bottom)); background:#eef2f6; border-top:1px solid rgba(0,0,0,.07); flex:0 0 auto; }
.conv-adj, .conv-send { background:none; border:0; cursor:pointer; padding:8px; border-radius:50%; display:flex; flex:0 0 auto; color:#0369a1; transition:background .12s; }
.conv-adj:hover { background:rgba(2,132,199,.1); }
.conv-send { background:linear-gradient(135deg,#0ea5e9,#0369a1); color:#fff; box-shadow:0 2px 6px rgba(2,132,199,.35); }
.conv-adj svg, .conv-send svg { width:22px; height:22px; }
.conv-input { flex:1 1 auto; resize:none; border:1px solid rgba(0,0,0,.12); border-radius:20px; padding:9px 14px; font-size:15px; font-family:inherit; max-height:120px; outline:none; background:#fff; }
.conv-input:focus { border-color:#0284c7; }

/* En móvil ocupa toda la pantalla (una ventanita en un teléfono se ve mal) */
@media (max-width:560px) {
  .chat-overlay.abierto { align-items:stretch; justify-content:stretch; }
  .chat-win { width:100%; height:100%; margin:0; border-radius:0; box-shadow:none; animation:chat-in-m .18s ease; }
  @keyframes chat-in-m { from { opacity:.4; transform:translateX(16px); } to { opacity:1; transform:none; } }
}

/* ===== Notas de voz (grabación) ===== */
.conv-normalbar { display:flex; align-items:flex-end; gap:8px; flex:1 1 auto; }
.conv-mic { background:none; border:0; cursor:pointer; padding:8px; border-radius:50%; display:flex; flex:0 0 auto; color:#0369a1; transition:background .12s; }
.conv-mic:hover { background:rgba(2,132,199,.1); }
.conv-mic svg { width:22px; height:22px; }
.conv-rec { display:flex; align-items:center; gap:10px; flex:1 1 auto; padding:2px 4px; }
.rec-cancel, .rec-send { background:none; border:0; cursor:pointer; padding:8px; border-radius:50%; display:flex; flex:0 0 auto; }
.rec-cancel { color:#ef4444; }
.rec-cancel:hover { background:rgba(239,68,68,.12); }
.rec-send { background:linear-gradient(135deg,#0ea5e9,#0369a1); color:#fff; box-shadow:0 2px 6px rgba(2,132,199,.35); }
.rec-cancel svg, .rec-send svg { width:20px; height:20px; }
.rec-ind { width:11px; height:11px; border-radius:50%; background:#ef4444; flex:0 0 auto; animation:rec-blink 1s infinite; }
@keyframes rec-blink { 0%,100% { opacity:1; } 50% { opacity:.25; } }
.rec-time { font-variant-numeric:tabular-nums; font-weight:700; color:#0f172a; font-size:15px; }
.rec-hint { color:#64748b; font-size:12.5px; flex:1 1 auto; }

/* ===== Botón de vehículo (IA) ===== */
.chat-veh { background:rgba(255,255,255,.16); border:0; color:#fff; padding:7px; border-radius:10px; cursor:pointer; display:flex; align-items:center; justify-content:center; flex:0 0 auto; }
.chat-veh:hover { background:rgba(255,255,255,.28); }
.chat-veh svg { width:20px; height:20px; }
.ia-chip-off { border-color:#94a3b8 !important; color:#64748b !important; }

/* ===== Botón "Nuevo grupo" en el hub ===== */
.chat-nuevo { display:flex; align-items:center; gap:12px; width:100%; padding:11px 16px; background:none; border:0; text-align:left; cursor:pointer; color:#0369a1; font-weight:600; font-size:14.5px; }
.chat-nuevo:hover { background:rgba(2,132,199,.06); }
.chat-nuevo-ic { width:38px; height:38px; border-radius:50%; background:#e0f2fe; color:#0369a1; display:flex; align-items:center; justify-content:center; font-size:24px; font-weight:400; flex:0 0 auto; line-height:1; }

/* ===== Vista crear grupo ===== */
.grupo-form { flex:0 0 auto; padding:12px 14px 8px; background:#eef2f6; }
.grupo-nombre { width:100%; padding:11px 14px; border:1px solid rgba(0,0,0,.12); border-radius:12px; font-size:15px; font-family:inherit; outline:none; background:#fff; }
.grupo-nombre:focus { border-color:#0284c7; box-shadow:0 0 0 3px rgba(2,132,199,.12); }
.grupo-count { margin-top:7px; font-size:12.5px; color:#64748b; font-weight:600; }
.grupo-miembros { flex:1 1 auto; overflow-y:auto; background:#eef2f6; padding-bottom:12px; }
.gm-row { display:flex; align-items:center; gap:12px; padding:9px 16px; cursor:pointer; border-bottom:1px solid rgba(0,0,0,.05); }
.gm-row:hover { background:rgba(2,132,199,.05); }
.gm-row.sel { background:rgba(34,197,94,.10); }
.gm-txt { flex:1 1 auto; min-width:0; }
.gm-nom { font-weight:600; color:#0f172a; font-size:14.5px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.gm-rol { font-size:12px; color:#64748b; text-transform:capitalize; }
.gm-check { width:22px; height:22px; border-radius:50%; border:2px solid #cbd5e1; flex:0 0 auto; position:relative; transition:all .12s; }
.gm-row.sel .gm-check { background:#22c55e; border-color:#22c55e; }
.gm-row.sel .gm-check::after { content:""; position:absolute; left:7px; top:3px; width:5px; height:10px; border:solid #fff; border-width:0 2.5px 2.5px 0; transform:rotate(45deg); }
.grupo-crear-bar { flex:0 0 auto; padding:10px 14px calc(12px + env(safe-area-inset-bottom)); background:#fff; border-top:1px solid rgba(0,0,0,.08); }
.grupo-crear-btn { width:100%; padding:13px; border:0; border-radius:12px; background:linear-gradient(135deg,#0ea5e9,#0369a1); color:#fff; font-size:15px; font-weight:700; cursor:pointer; box-shadow:0 3px 10px rgba(2,132,199,.3); }
.grupo-crear-btn:disabled { background:#cbd5e1; box-shadow:none; cursor:not-allowed; }

/* Fotos que devuelve la IA (prueba de entrega) */
.ia-foto { margin-top:6px; border-radius:10px; cursor:pointer; }
