/* ═══════════════════════════════════════════════════════════════════
   Asistente IA — burbuja de chat en la web de cada marca
   El color sale de la marca (--chat-color), no está fijo aquí.
   ═══════════════════════════════════════════════════════════════════ */

.ia-burbuja {
    position: fixed; right: 20px; bottom: 20px; z-index: 400;
    width: 62px; height: 62px; padding: 0;
    background: none; border: 0; cursor: pointer;
    border-radius: 50%;
    box-shadow: 0 6px 22px rgba(15,23,42,.28);
    transition: transform .18s;
}
.ia-burbuja:hover { transform: scale(1.06); }
.ia-burbuja img { width: 100%; height: 100%; display: block; border-radius: 50%; }

/* Punto que llama la atención la primera vez, y solo la primera */
.ia-burbuja .ia-punto {
    position: absolute; top: 2px; right: 2px;
    width: 14px; height: 14px; border-radius: 50%;
    background: #ef4444; border: 2px solid #fff;
    animation: iaLatido 2s ease-in-out 4;
}
@keyframes iaLatido {
    0%, 100% { transform: scale(1); }
    50%      { transform: scale(1.25); }
}

/* Globo de invitación: sale una vez y se va solo */
.ia-invita {
    position: fixed; right: 92px; bottom: 34px; z-index: 400;
    max-width: 220px; padding: 11px 14px;
    background: #fff; border-radius: 14px 14px 2px 14px;
    box-shadow: 0 6px 22px rgba(15,23,42,.18);
    font-size: 13.5px; line-height: 1.5; color: #334155;
    opacity: 0; transform: translateY(8px); pointer-events: none;
    transition: opacity .3s, transform .3s;
}
.ia-invita.visible { opacity: 1; transform: none; }

/* ── Ventana ────────────────────────────────────────────────────── */
.ia-chat {
    position: fixed; right: 20px; bottom: 20px; z-index: 401;
    width: 370px; max-width: calc(100vw - 32px);
    height: 540px; max-height: calc(100vh - 40px);
    background: #fff; border-radius: 16px;
    box-shadow: 0 18px 60px rgba(15,23,42,.3);
    display: none; flex-direction: column; overflow: hidden;
}
.ia-chat.abierto { display: flex; }

.ia-cab {
    display: flex; align-items: center; gap: 11px;
    padding: 13px 15px;
    background: var(--chat-color, #1e40af); color: #fff;
    flex-shrink: 0;
}
.ia-cab img { width: 38px; height: 38px; border-radius: 50%; background: #fff; flex-shrink: 0; }
.ia-cab-txt { flex: 1; min-width: 0; }
.ia-cab-tit { font-size: 14.5px; font-weight: 800; line-height: 1.2; }
.ia-cab-sub {
    font-size: 11.5px; opacity: .82; display: flex; align-items: center; gap: 6px;
}
.ia-cab-sub::before {
    content: ''; width: 7px; height: 7px; border-radius: 50%;
    background: #4ade80; flex-shrink: 0;
}
.ia-cerrar {
    background: none; border: 0; color: #fff; cursor: pointer;
    font-size: 25px; line-height: 1; padding: 0 4px; opacity: .85;
}
.ia-cerrar:hover { opacity: 1; }

.ia-cuerpo {
    flex: 1; overflow-y: auto; padding: 16px 14px;
    background: #f8fafc;
    display: flex; flex-direction: column; gap: 10px;
}
.ia-msg {
    max-width: 84%; padding: 10px 13px;
    font-size: 13.5px; line-height: 1.6; white-space: pre-wrap;
    word-break: break-word;
}
.ia-msg-bot {
    align-self: flex-start; background: #fff; color: #1e293b;
    border-radius: 14px 14px 14px 3px;
    box-shadow: 0 1px 3px rgba(15,23,42,.08);
}
.ia-msg-yo {
    align-self: flex-end; background: var(--chat-color, #1e40af); color: #fff;
    border-radius: 14px 14px 3px 14px;
}
.ia-msg-error {
    align-self: center; background: #fef2f2; color: #b91c1c;
    border: 1px solid #fecaca; border-radius: 10px;
    font-size: 12.5px; max-width: 95%; text-align: center;
}

/* Los tres puntos mientras piensa */
.ia-escribiendo {
    align-self: flex-start; display: flex; gap: 4px;
    padding: 13px; background: #fff; border-radius: 14px 14px 14px 3px;
    box-shadow: 0 1px 3px rgba(15,23,42,.08);
}
.ia-escribiendo span {
    width: 7px; height: 7px; border-radius: 50%; background: #cbd5e1;
    animation: iaPunto 1.2s infinite;
}
.ia-escribiendo span:nth-child(2) { animation-delay: .2s; }
.ia-escribiendo span:nth-child(3) { animation-delay: .4s; }
@keyframes iaPunto {
    0%, 60%, 100% { opacity: .35; transform: translateY(0); }
    30%           { opacity: 1;   transform: translateY(-4px); }
}

/* Sugerencias del primer momento: el papel en blanco es el enemigo */
.ia-sugerencias { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 2px; }
.ia-sug {
    padding: 7px 12px; border-radius: 20px; cursor: pointer;
    background: #fff; border: 1px solid #e2e8f0;
    color: var(--chat-color, #1e40af);
    font: inherit; font-size: 12.5px; font-weight: 600;
}
.ia-sug:hover { background: #f1f5f9; }

.ia-pie {
    padding: 11px 12px; border-top: 1px solid #e2e8f0; background: #fff;
    flex-shrink: 0;
}
.ia-fila { display: flex; gap: 8px; align-items: flex-end; }
.ia-fila textarea {
    flex: 1; min-height: 42px; max-height: 110px;
    padding: 11px 13px; resize: none;
    border: 1px solid #e2e8f0; border-radius: 12px;
    font-family: inherit; font-size: 14px; line-height: 1.45; color: #1e293b;
}
.ia-fila textarea:focus {
    outline: none; border-color: var(--chat-color, #1e40af);
}
.ia-enviar {
    flex-shrink: 0; width: 42px; height: 42px; padding: 0;
    display: grid; place-items: center;
    background: var(--chat-color, #1e40af); color: #fff;
    border: 0; border-radius: 12px; cursor: pointer;
}
.ia-enviar:disabled { opacity: .45; cursor: default; }
.ia-enviar svg { width: 19px; height: 19px; }
.ia-aviso {
    margin-top: 7px; font-size: 10.5px; color: #94a3b8; text-align: center; line-height: 1.4;
}
.ia-aviso a { color: #64748b; text-decoration: underline; }

@media (max-width: 460px) {
    .ia-chat {
        right: 0; bottom: 0; width: 100%; max-width: none;
        height: 100%; max-height: none; border-radius: 0;
    }
    .ia-invita { display: none; }
}
@media print { .ia-burbuja, .ia-chat, .ia-invita { display: none !important; } }
@media (prefers-reduced-motion: reduce) {
    .ia-burbuja:hover { transform: none; }
    .ia-burbuja .ia-punto, .ia-escribiendo span { animation: none; }
}
