/* =========================================================
   CHAT CON IA - burbuja y ventana
   Va encima del botón de WhatsApp (abajo a la derecha)
   ========================================================= */
.mcc { font-family: 'Inter', 'Segoe UI', sans-serif; }
.mcc-panel, .mcc-panel * { box-sizing: border-box; }
.mcc-panel { margin: 0; padding: 0; }

.mcc-burbuja {
    position: fixed;
    right: 2rem;
    bottom: calc(2rem + 60px + 16px);   /* encima de WhatsApp */
    z-index: 1000;
    width: 60px;
    height: 60px;
    border: 0;
    border-radius: 50%;
    color: #fff;
    font-size: 1.55rem;
    cursor: pointer;
    background: linear-gradient(135deg, #2563eb, #0ea5e9);
    box-shadow: 0 8px 22px rgba(37, 99, 235, .4);
    display: grid;
    place-items: center;
    transition: transform .2s ease, box-shadow .2s ease;
}
.mcc-burbuja:hover { transform: scale(1.08); box-shadow: 0 10px 28px rgba(37, 99, 235, .55); }
.mcc-burbuja > span { grid-area: 1 / 1; transition: transform .25s ease, opacity .25s ease; }
.mcc-ico-cerrar { opacity: 0; transform: rotate(-90deg) scale(.6); }
.mcc-abierto .mcc-ico-abrir { opacity: 0; transform: rotate(90deg) scale(.6); }
.mcc-abierto .mcc-ico-cerrar { opacity: 1; transform: none; }
.mcc-punto {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 13px;
    height: 13px;
    border-radius: 50%;
    background: #22c55e;
    border: 2px solid #fff;
}
.mcc-abierto .mcc-punto { display: none; }

/* Globo de saludo */
.mcc-saludo {
    position: fixed;
    right: calc(2rem + 72px);
    bottom: calc(2rem + 60px + 28px);
    z-index: 1000;
    background: #fff;
    color: #0f172a;
    font-weight: 600;
    font-size: .9rem;
    padding: 10px 14px;
    border-radius: 14px 14px 4px 14px;
    box-shadow: 0 8px 24px rgba(15, 23, 42, .15);
    cursor: pointer;
    white-space: nowrap;
    opacity: 0;
    transform: translateX(10px);
    pointer-events: none;
    transition: opacity .3s ease, transform .3s ease;
}
.mcc-saludo.mcc-ver { opacity: 1; transform: none; pointer-events: auto; }

/* Ventana */
.mcc-panel {
    position: fixed;
    right: 2rem;
    bottom: calc(2rem + 60px + 16px + 60px + 14px);
    z-index: 1001;
    width: 370px;
    height: min(560px, calc(100vh - 220px));
    display: flex;
    flex-direction: column;
    background: #fff;
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 24px 60px rgba(15, 23, 42, .25);
    animation: mcc-entra .25s cubic-bezier(.2, .8, .2, 1);
}
.mcc-panel[hidden] { display: none; }
@keyframes mcc-entra { from { opacity: 0; transform: translateY(16px) scale(.97); } to { opacity: 1; transform: none; } }

.mcc-cab {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 14px 14px 16px;
    color: #fff;
    background: linear-gradient(135deg, #1e3a8a, #2563eb 60%, #0ea5e9);
}
.mcc-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: rgba(255, 255, 255, .18);
    font-size: 1.1rem;
    flex-shrink: 0;
}
.mcc-tit { flex: 1; display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.mcc-tit strong { font-size: .98rem; }
.mcc-tit small { opacity: .85; font-size: .78rem; }
.mcc-tit small::before { content: "● "; color: #4ade80; }
.mcc-cab button {
    width: 34px;
    height: 34px;
    border: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, .15);
    color: #fff;
    cursor: pointer;
}
.mcc-cab button:hover { background: rgba(255, 255, 255, .28); }

.mcc-mensajes {
    flex: 1;
    overflow-y: auto;
    padding: 16px 14px 8px;
    background: #f5f8fd;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.mcc-msg { display: flex; animation: mcc-msg .25s ease; }
.mcc-msg.mcc-sin-anim { animation: none; }
@keyframes mcc-msg { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.mcc-usuario { justify-content: flex-end; }
.mcc-globo {
    max-width: 85%;
    padding: 10px 13px;
    border-radius: 16px;
    font-size: .92rem;
    line-height: 1.5;
    word-wrap: break-word;
    overflow-wrap: anywhere;
}
.mcc-ia .mcc-globo { background: #fff; color: #1e293b; border: 1px solid #e2e8f0; border-bottom-left-radius: 4px; }
.mcc-usuario .mcc-globo { background: #2563eb; color: #fff; border-bottom-right-radius: 4px; }
.mcc-globo a { color: inherit; text-decoration: underline; font-weight: 600; }
.mcc-ia .mcc-globo a { color: #2563eb; }

/* Puntos de "escribiendo" */
.mcc-escribiendo .mcc-globo { display: flex; gap: 4px; padding: 13px 14px; }
.mcc-escribiendo span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #94a3b8;
    animation: mcc-pun 1.1s infinite ease-in-out;
}
.mcc-escribiendo span:nth-child(2) { animation-delay: .15s; }
.mcc-escribiendo span:nth-child(3) { animation-delay: .3s; }
@keyframes mcc-pun { 0%, 80%, 100% { transform: translateY(0); opacity: .5; } 40% { transform: translateY(-5px); opacity: 1; } }

.mcc-sugerencias {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 8px 14px 4px;
    background: #f5f8fd;
}
.mcc-sugerencias[hidden] { display: none; }
.mcc-chip {
    border: 1px solid #bfdbfe;
    background: #fff;
    color: #1d4ed8;
    font: inherit;
    font-size: .8rem;
    font-weight: 600;
    padding: 6px 11px;
    border-radius: 999px;
    cursor: pointer;
}
.mcc-chip:hover { background: #eff6ff; border-color: #2563eb; }

.mcc-form {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 10px 12px;
    border-top: 1px solid #e2e8f0;
    background: #fff;
}
.mcc-input {
    flex: 1;
    resize: none;
    border: 1px solid #cbd5e1;
    border-radius: 14px;
    padding: 10px 12px;
    font: inherit;
    font-size: .92rem;
    line-height: 1.4;
    max-height: 110px;
    outline: none;
}
.mcc-input:focus { border-color: #2563eb; box-shadow: 0 0 0 3px rgba(37, 99, 235, .15); }
.mcc-enviar {
    width: 42px;
    height: 42px;
    flex-shrink: 0;
    border: 0;
    border-radius: 50%;
    background: #2563eb;
    color: #fff;
    cursor: pointer;
}
.mcc-enviar:disabled { opacity: .5; cursor: wait; }
.mcc-pie {
    margin: 0;
    padding: 0 14px 10px;
    background: #fff;
    font-size: .72rem;
    color: #94a3b8;
    text-align: center;
}
.mcc-pie a { color: #16a34a; font-weight: 700; }

/* Tablet / celular: alineado con el botón de WhatsApp (56 px) */
@media (max-width: 768px) {
    .mcc-burbuja { right: 1.5rem; bottom: calc(1.5rem + 56px + 12px); width: 56px; height: 56px; font-size: 1.4rem; }
    .mcc-saludo { right: calc(1.5rem + 68px); bottom: calc(1.5rem + 56px + 24px); }
    .mcc-panel { right: 1.5rem; bottom: calc(1.5rem + 56px + 12px + 56px + 12px); }
}
/* Celular: la ventana ocupa casi toda la pantalla */
@media (max-width: 600px) {
    .mcc-panel {
        right: 8px;
        left: 8px;
        bottom: 8px;
        width: auto;
        height: calc(100dvh - 16px);
        border-radius: 18px;
        z-index: 1002;
    }
    .mcc-abierto .mcc-burbuja { display: none; }
    .mcc-input { font-size: 16px; } /* evita el zoom automático en iPhone */
}
@media (prefers-reduced-motion: reduce) {
    .mcc-panel, .mcc-msg, .mcc-escribiendo span { animation: none; }
}
