/* ══════════════════════════════════════════════
   CHAT WIDGET — asistente virtual en el hero
   Ocupa la columna derecha del hero__grid (390px),
   con la misma estética "glass" que las hv-card.
══════════════════════════════════════════════ */

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.chat-widget {
    display: flex;
    flex-direction: column;
    /* Deja hueco para el header fijo del sitio (68px) al saltar aquí desde
       el enlace "Agente IA" del menú, para que se vea la cabecera del
       widget (avatar + "Agente IA CERO microchip") y no quede tapada. */
    scroll-margin-top: 92px;
    background: linear-gradient(165deg, rgba(0,116,170,0.55), rgba(3,44,89,0.75));
    border: 1px solid rgba(0,120,212,0.4);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-radius: var(--radius-lg);
    overflow: hidden;
    color: #fff;
    box-shadow: 0 12px 48px rgba(0,50,90,0.45);
}

/* ── Cabecera ── */
.chat-widget__header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 18px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    background: linear-gradient(135deg, rgba(0,120,212,0.18), rgba(43,136,216,0.05));
}
.chat-widget__avatar {
    width: 42px;
    height: 42px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    background: rgba(255,255,255,0.92);
    box-shadow: 0 4px 16px rgba(0,120,212,0.4);
}
.chat-widget__avatar img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 2px;
}
.chat-widget__header h2 {
    font-size: 0.95rem;
    font-weight: 700;
    color: #fff;
    line-height: 1.2;
}
.chat-widget__header p {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.72rem;
    color: rgba(255,255,255,0.55);
    margin: 2px 0 0;
}
.chat-widget__dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #2b88d8;
    animation: pulse 2s infinite;
}

/* ── Mensajes ── */
.chat-widget__messages {
    height: 300px;
    overflow-y: auto;
    padding: 16px 14px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.25) transparent;
}
.chat-widget__messages::-webkit-scrollbar { width: 6px; }
.chat-widget__messages::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.25); border-radius: 3px; }

.message-row {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    max-width: 100%;
}
.message-row.user { justify-content: flex-end; }

/* La imagen de la mascota del agente hace de avatar en cada burbuja */
.mini-avatar {
    width: 26px;
    height: 26px;
    flex-shrink: 0;
    display: block;
    object-fit: contain;
    border-radius: 8px;
    background: rgba(255,255,255,0.92);
    padding: 2px;
}

.bubble {
    max-width: 85%;
    padding: 10px 13px;
    border-radius: 14px;
    font-size: 0.85rem;
    line-height: 1.5;
    word-wrap: break-word;
}
.message-row.bot .bubble {
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.12);
    border-bottom-left-radius: 4px;
}
.message-row.user .bubble {
    background: linear-gradient(135deg, var(--red), #005a9e);
    border-bottom-right-radius: 4px;
    color: #fff;
}
.bubble small {
    display: block;
    margin-top: 5px;
    font-size: 0.62rem;
    color: rgba(255,255,255,0.4);
}
.bubble a {
    color: #6cb4ee;
    font-weight: 600;
    text-decoration: underline;
    text-underline-offset: 2px;
}
.bubble a:hover { color: #2b88d8; }

/* Indicador de escritura */
.bubble.typing { display: flex; gap: 4px; padding: 13px 15px; }
.bubble.typing i {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: rgba(255,255,255,0.55);
    animation: typingBlink 1.2s infinite;
}
.bubble.typing i:nth-child(2) { animation-delay: 0.18s; }
.bubble.typing i:nth-child(3) { animation-delay: 0.36s; }
@keyframes typingBlink {
    0%, 60%, 100% { opacity: 0.25; transform: translateY(0); }
    30%           { opacity: 1;    transform: translateY(-3px); }
}

/* ── Sugerencias ── */
.chat-widget__suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 0 14px 10px;
}
.chat-widget__suggestions[hidden] { display: none; }
.chat-widget__suggestions button {
    background: rgba(0,120,212,0.14);
    border: 1px solid rgba(0,120,212,0.35);
    color: #6cb4ee;
    font-size: 0.72rem;
    font-weight: 500;
    padding: 6px 11px;
    border-radius: 50px;
    cursor: pointer;
    transition: all var(--transition);
}
.chat-widget__suggestions button:hover {
    background: rgba(0,120,212,0.3);
    color: #fff;
}

/* ── Medidor de tokens (simulado) ── */
.chat-widget__tokens {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 12px;
    padding: 7px 14px;
    border-top: 1px solid rgba(255,255,255,0.08);
    background: rgba(0,0,0,0.12);
    font-size: 0.62rem;
    color: rgba(255,255,255,0.38);
    letter-spacing: 0.02em;
}
.chat-widget__tokens b {
    color: #6cb4ee;
    font-weight: 600;
}

/* ── Redactor ── */
.chat-widget__composer {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 10px 12px;
    border-top: 1px solid rgba(255,255,255,0.1);
    background: rgba(0,0,0,0.15);
}
.chat-widget__composer textarea {
    flex: 1;
    resize: none;
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 12px;
    color: #fff;
    font-size: 0.85rem;
    line-height: 1.4;
    padding: 9px 12px;
    outline: none;
    max-height: 90px;
    transition: border-color var(--transition);
}
.chat-widget__composer textarea::placeholder { color: rgba(255,255,255,0.35); }
.chat-widget__composer textarea:focus { border-color: rgba(0,120,212,0.6); }
.chat-widget__composer button {
    width: 38px;
    height: 38px;
    flex-shrink: 0;
    border: none;
    border-radius: 12px;
    font-size: 1rem;
    color: #fff;
    background: linear-gradient(135deg, var(--red), #2b88d8);
    cursor: pointer;
    transition: opacity var(--transition), transform var(--transition);
}
.chat-widget__composer button:hover:not(:disabled) { transform: translateY(-1px); }
.chat-widget__composer button:disabled { opacity: 0.35; cursor: default; }

.chat-widget__disclaimer {
    padding: 8px 14px 12px;
    font-size: 0.62rem;
    color: rgba(255,255,255,0.35);
    text-align: center;
    background: rgba(0,0,0,0.15);
}

/* ── Insignia de valoración: ahora es un <a> a Google Maps.
   .hero__left es flex-column y por defecto la estira a todo su ancho;
   align-self la ciñe de nuevo al ancho de su texto. ── */
.hero__badge {
    align-self: flex-start;
}

/* ── Columna del chat: widget + reclamo comercial debajo ── */
.hero__chat-col {
    display: flex;
    flex-direction: column;
    gap: 14px;
}
.chat-promo {
    display: block;
    text-align: center;
    font-size: 0.9rem;
    font-weight: 600;
    line-height: 1.5;
    color: #6cb4ee;
    text-decoration: none;
    transition: color var(--transition);
}
.chat-promo strong { color: #2b88d8; font-weight: 800; }
.chat-promo:hover { color: #2b88d8; }

/* ── Responsive ──
   A diferencia de las hv-card originales (que se ocultaban en móvil),
   el chat se mantiene visible en todos los tamaños. */
@media (max-width: 1024px) {
    .hero__chat-col {
        width: 100%;
        max-width: 480px;
        margin: 0 auto;
        /* Centrado explícito de la celda del grid, como refuerzo del
           margin:auto de arriba (por si el navegador del móvil resuelve
           el ancho "stretch" de forma distinta y deja la caja descentrada). */
        justify-self: center;
    }
}
@media (max-width: 768px) {
    /* Evita el zoom automático de iOS al tocar el textarea del chat
       (letra por debajo de 16px lo dispara). Solo en móvil. */
    .chat-widget__composer textarea { font-size: 16px; }
}
@media (max-width: 480px) {
    /* Menos margen interno en los paneles de "asistencia" en pantallas muy
       estrechas: con el padding de escritorio dejaban muy poco ancho útil
       para los campos del formulario. */
    .assist-info,
    .contact-form {
        padding: 22px 18px;
    }
}
@media (max-width: 480px) {
    .chat-widget__messages { height: 260px; }
}

/* ══════════════════════════════════════════════
   SECCIÓN DE ASISTENCIA Y FOOTER — azul oscuro, mismo lenguaje que el hero.
   #asistencia lleva en index.html las clases section--dark / *--light,
   así que hereda directamente el estilo "texto claro sobre fondo oscuro"
   ya construido en style.css para esas secciones (assist-*, form-input,
   radio-card, link--light): aquí solo se sobrescribe el fondo (degradado
   + textura) y se definen como cajas los dos paneles del formulario.
══════════════════════════════════════════════ */
#asistencia {
    background:
        linear-gradient(160deg, rgba(10,26,56,0.82) 0%, rgba(13,33,68,0.9) 100%),
        url('images/texture-blue.jpg') center/cover no-repeat;
}
.footer {
    background:
        linear-gradient(160deg, rgba(13,33,68,0.95) 0%, rgba(3,13,28,0.98) 100%),
        url('images/texture-blue.jpg') center/cover no-repeat;
}

/* Paneles definidos del formulario: "llámanos directamente" y el formulario en sí */
.assist-info,
.contact-form {
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.14);
    border-radius: var(--radius-lg);
    padding: 30px 28px;
    box-shadow: 0 10px 34px rgba(0,10,25,0.3);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}
