/* chat-ui.css — la interfaz del chat de Atención del Socio (atencion.js + chat-ui.js): burbujas con hora, separador por día, «escribiendo», barra para escribir
   (clip · cuadro que crece · micrófono/enviar), grabación y reproductor de audio, aviso, y el panel que sigue al teclado del celular. Solo tokens (sin hex ni z-index sueltos).
   Se carga DESPUÉS de styles.css y chat-imagenes.css: acá solo se pisa y se agrega lo del chat; el resto (cabecera, sugerencias, tarjetas, beneficios) queda como estaba. */

/* ── Panel: en el celular mide el área REALMENTE visible (--atc-vh y --atc-top los pone atencion.js con visualViewport) para que el teclado no tape la barra ── */
.atc-panel { overflow: hidden; }
.atc-head, .atc-fr, .atc-sug, .atc-persona, .atc-adj, .atc-aviso, .atc-form { flex: none; }   /* solo la conversación se encoge: la barra y lo de arriba nunca se aplastan */
@media (max-width: 599px), (pointer: coarse) {
  .atc-panel { top: var(--atc-top, 0px); bottom: auto; height: var(--atc-vh, 100dvh); max-height: 100dvh; }
  html.atc-abierto, html.atc-abierto body { overflow: hidden; overscroll-behavior: none; }
}
.atc-head { padding-top: max(14px, env(safe-area-inset-top)); padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); }

/* ── Conversación ── */
.atc-cuerpo { position: relative; flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
.atc-lista { flex: 1 1 auto; min-height: 0; gap: var(--sp-2); padding: var(--sp-4) max(16px, env(safe-area-inset-right)) var(--sp-4) max(16px, env(safe-area-inset-left)); -webkit-overflow-scrolling: touch; }
.atc-msg { max-width: 84%; gap: var(--sp-1); }
.atc-msg.yo + .atc-msg:not(.yo), .atc-msg:not(.yo) + .atc-msg.yo, .atc-typing { margin-top: var(--sp-2); }   /* más aire cuando cambia quien habla */
.atc-msg.yo .atc-b { background: var(--action-primary-bg); color: var(--action-primary-text); border: 0; border-radius: var(--r-22) var(--r-22) var(--r-8) var(--r-22); }
.atc-msg.ia .atc-b { background: var(--surface-campo); color: var(--text-primary); border: 0; border-radius: var(--r-22) var(--r-22) var(--r-22) var(--r-8); }
.atc-msg.hu .atc-b { border-radius: var(--r-22) var(--r-22) var(--r-22) var(--r-8); }
.atc-b { padding: var(--sp-3) var(--sp-4); }
.atc-hora { display: block; padding: 0 var(--sp-2); font-size: var(--t-11); line-height: 1.2; color: var(--text-secondary); font-variant-numeric: tabular-nums; }
.atc-dia { align-self: center; margin: var(--sp-3) 0 var(--sp-1); }
.atc-dia span { display: inline-block; padding: var(--sp-1) var(--sp-3); border-radius: var(--r-pill); background: var(--overlay-medium); color: var(--text-secondary); font-size: var(--t-12); font-weight: 600; }

/* ── «Escribiendo»: tres puntitos en una burbuja del lado del chat ── */
.atc-typing { gap: 5px; align-items: center; padding: var(--sp-3) var(--sp-4); border: 0; background: var(--surface-campo); }
.atc-typing i { width: 7px; height: 7px; }
.atc-typing-t { margin-left: var(--sp-2); color: var(--text-secondary); font-size: .8125rem; line-height: 1.3; }   /* <chat-letal> qué pasa cuando la respuesta tarda */
.atc-typing-t:empty { display: none; }
@media (prefers-reduced-motion: reduce) { .atc-typing i { animation: none; opacity: .6; transform: none; } .atc-rec-punto { animation: none; } }

/* ── «↓ Nuevos mensajes» ── */
.atc-nuevos { position: absolute; left: 50%; bottom: var(--sp-3); transform: translateX(-50%); z-index: var(--z-pop); min-height: 44px; padding: 0 var(--sp-4); border: 0; border-radius: var(--r-pill);
  background: var(--action-primary-bg); color: var(--action-primary-text); font-family: inherit; font-size: var(--t-13); font-weight: 700; line-height: 1; box-shadow: var(--sombra); cursor: pointer; }
.atc-nuevos[hidden] { display: none; }

/* ── Aviso (permiso del micrófono, audio muy corto…) ── */
.atc-aviso { display: flex; align-items: flex-start; gap: var(--sp-2); margin: 0 var(--sp-4) var(--sp-2); padding: var(--sp-3) var(--sp-3) var(--sp-3) var(--sp-4); border-radius: var(--r-14);
  background: color-mix(in srgb, var(--error-fg) 12%, var(--surface-card)); border: 1px solid color-mix(in srgb, var(--error-fg) 40%, transparent); color: var(--text-primary); font-size: var(--t-13); line-height: 1.4; }
.atc-aviso[hidden] { display: none; }
.atc-aviso > span { flex: 1; min-width: 0; }
.atc-aviso-x { flex: none; width: 44px; height: 44px; margin: calc(var(--sp-3) * -1) calc(var(--sp-3) * -1) calc(var(--sp-3) * -1) 0; border: 0; background: transparent; color: var(--text-primary); font-size: var(--t-20); line-height: 1; cursor: pointer; border-radius: 50%; }

/* ── Barra para escribir ── */
.atc-form { --atc-b: var(--touch); align-items: flex-end; gap: var(--sp-2); padding: var(--sp-3) max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left)); }
.atc-panel.atc-teclado .atc-form { padding-bottom: var(--sp-3); }   /* con el teclado abierto la barra de inicio del teléfono no está: sin hueco de más */
.atc-caja { flex: 1 1 auto; min-width: 0; display: flex; }
.atc-caja[hidden], .atc-rec[hidden] { display: none; }
.atc-campo { display: block; width: 100%; box-sizing: border-box; min-height: var(--atc-b); max-height: calc(22px * 5 + 28px); margin: 0; padding: 13px var(--sp-4); border: 1px solid var(--border-default); border-radius: var(--r-22); background: var(--surface-input);
  color: var(--text-primary); font-family: inherit; font-size: 16px; line-height: 22px; resize: none; overflow-y: hidden; overscroll-behavior: contain; }
.atc-campo::placeholder { color: var(--text-secondary); opacity: 1; }
.atc-form .atc-clip { width: var(--atc-b); height: var(--atc-b); border: 0; background: transparent; color: var(--text-secondary); }
.atc-form .atc-clip:hover { color: var(--text-primary); }
.atc-send { width: var(--atc-b); height: var(--atc-b); flex: none; position: relative; touch-action: manipulation; }
.atc-send[data-modo="mic"], .atc-send[data-modo="grabando"] { touch-action: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.atc-send[data-modo="mic"] .ic, .atc-send[data-modo="enviar"] .ic-mic, .atc-send[data-modo="grabando"] .ic-mic { display: none; }
.atc-send[aria-disabled="true"] { opacity: .45; cursor: default; }
.atc-form .atc-rec-x, .atc-play { display: grid; place-items: center; width: 44px; height: 44px; flex: none; padding: 0; border: 0; border-radius: 50%; cursor: pointer; }
.atc-campo:focus-visible, .atc-send:focus-visible, .atc-nuevos:focus-visible, .atc-aviso-x:focus-visible, .atc-rec-x:focus-visible, .atc-play:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }

/* Vista previa de la imagen antes de enviar (la lógica es la de siempre: chat-imagenes.js): pequeña, con ✕ de tamaño táctil */
.atc-adj { padding: var(--sp-3) max(16px, env(safe-area-inset-left)) var(--sp-1); }
.atc-adj-i { width: 76px; min-height: 76px; border-radius: var(--r-14); }
.atc-adj-i img { height: 76px; }
.atc-adj-x { top: 2px; right: 2px; width: 28px; height: 28px; }
.atc-adj-x::after { content: ""; position: absolute; inset: -8px; }   /* zona táctil de 44 px sin agrandar el ícono */

/* ── Grabando ── */
.atc-rec { flex: 1 1 auto; min-width: 0; min-height: var(--atc-b); display: flex; align-items: center; gap: var(--sp-2); padding: 0 var(--sp-4) 0 var(--sp-1); border-radius: var(--r-pill); background: var(--surface-campo); color: var(--text-primary); }
.atc-rec-x { background: transparent; color: var(--text-secondary); }
.atc-rec-punto { flex: none; width: 10px; height: 10px; border-radius: 50%; background: var(--error-fg); animation: atcRec var(--t-pulso) infinite ease-in-out; }
.atc-rec-t { flex: none; font-size: var(--t-15); font-weight: 700; font-variant-numeric: tabular-nums; }
.atc-rec.cerca .atc-rec-t { color: var(--error-fg); }
.atc-rec-ay { flex: 1; min-width: 0; font-size: var(--t-12); line-height: 1.25; color: var(--text-secondary); text-align: right; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.atc-rec.va-cancelar .atc-rec-ay { color: var(--error-fg); font-weight: 700; }
@keyframes atcRec { 0%, 100% { opacity: 1; } 50% { opacity: .3; } }

/* ── Reproductor del audio en la conversación ── */
.atc-audio { display: flex; align-items: center; gap: var(--sp-2); width: min(260px, 100%); padding: var(--sp-1) var(--sp-4) var(--sp-1) var(--sp-1); border-radius: var(--r-pill); background: var(--action-primary-bg); color: var(--action-primary-text); }
.atc-play { background: var(--action-primary-text); color: var(--action-primary-bg); }
.atc-play .ic, .atc-play svg { display: block; }
.atc-onda { position: relative; flex: 1; height: 4px; border-radius: var(--r-pill); background: color-mix(in srgb, currentColor 30%, transparent); overflow: hidden; }
.atc-onda i { position: absolute; inset: 0 auto 0 0; width: var(--avance, 0%); background: currentColor; }
.atc-audio-t { flex: none; font-size: var(--t-13); font-weight: 600; font-variant-numeric: tabular-nums; }
.atc-audio + .atc-b { margin-top: 0; }
.atc-b.atc-trans { opacity: .75; font-style: italic; }
.atc-msg.yo .atc-audio { align-self: flex-end; }

/* Sugerencias: una sola fila que se desliza hacia el costado (en el celular no se comen media pantalla) */
.atc-sug { flex-wrap: nowrap; overflow-x: auto; gap: var(--sp-2); padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); scrollbar-width: none; overscroll-behavior-x: contain; }
.atc-sug::-webkit-scrollbar { display: none; }
.atc-sug .atc-pill { flex: none; white-space: nowrap; min-height: 44px; }
