/* ════════════════════════════════════════════════════════════════════
   CBS Live Chat Widget — brandeo WhatsApp + identidad CBS
   Header verde WhatsApp profundo, avatar con borde blanco, burbujas
   con tail característica, fondo doodle natural, check marks ✓✓.
   ════════════════════════════════════════════════════════════════════ */

#cbs-lc {
    /* WhatsApp palette */
    --cbs-lc-wa-dark:   #075E54;   /* header & FAB */
    --cbs-lc-wa-mid:    #128C7E;   /* hover / accent */
    --cbs-lc-wa-light:  #25D366;   /* send button + check entregado */
    --cbs-lc-wa-tick:   #34B7F1;   /* check marks azul (✓✓ leído) */
    --cbs-lc-bubble-me: #DCF8C6;   /* burbuja del visitor (verde WhatsApp) */
    --cbs-lc-bubble-op: #FFFFFF;   /* burbuja del bot/operador */
    --cbs-lc-bg:        #ECE5DD;   /* fondo beige WhatsApp */

    /* CBS palette (uso secundario) */
    --cbs-lc-blue:      #25377B;
    --cbs-lc-blue-dark: #1a2654;

    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
#cbs-lc * { box-sizing: border-box; }

/* ── FAB (botón flotante) ────────────────────────────── */
.cbs-lc__fab {
    position: fixed; right: 16px; bottom: 16px; z-index: 2147483000;
    width: 60px; height: 60px; border-radius: 50%;
    border: 0; padding: 0; cursor: pointer;
    background: var(--cbs-lc-wa-light); color: #fff;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 6px 22px rgba(37, 211, 102, 0.45), 0 2px 8px rgba(0, 0, 0, 0.14);
    transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.cbs-lc__fab:hover {
    transform: scale(1.08) translateY(-2px);
    box-shadow: 0 10px 30px rgba(37, 211, 102, 0.6);
}
.cbs-lc__fab:active { transform: scale(0.97); }
.cbs-lc__fab svg { display: block; }
.cbs-lc__fab-dot {
    position: absolute; top: 4px; right: 4px;
    width: 14px; height: 14px; border-radius: 50%;
    background: #EA0029; border: 2px solid #fff;
    animation: cbsLcPulse 2.4s infinite;
}
#cbs-lc[data-closed="0"] .cbs-lc__fab-dot { display: none; }
@keyframes cbsLcPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(234, 0, 41, 0.6); }
    50%      { box-shadow: 0 0 0 8px rgba(234, 0, 41, 0); }
}

/* ── Panel ───────────────────────────────────────────── */
.cbs-lc__panel {
    position: fixed; right: 16px; bottom: 88px; z-index: 2147483001;
    width: 380px; max-width: calc(100vw - 32px);
    height: 580px; max-height: calc(100vh - 120px);
    display: none; flex-direction: column;
    background: var(--cbs-lc-bg);
    border-radius: 12px; overflow: hidden;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.28), 0 4px 16px rgba(0, 0, 0, 0.12);
}
#cbs-lc[data-closed="0"] .cbs-lc__panel {
    display: flex;
    animation: cbsLcPop 0.22s cubic-bezier(0.34, 1.4, 0.64, 1);
}
@keyframes cbsLcPop {
    from { opacity: 0; transform: scale(0.92) translateY(16px); }
    to   { opacity: 1; transform: scale(1)    translateY(0); }
}

/* ── Header (verde WhatsApp + identidad CBS) ────────── */
.cbs-lc__head {
    display: flex; align-items: center; gap: 11px;
    padding: 11px 14px;
    background: var(--cbs-lc-wa-dark);
    color: #fff;
    flex: 0 0 auto;
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.15);
}
/* Avatar tipo "pill" rectangular para acomodar el logo CBS horizontal
   (432x128, ratio 3.4:1). Ancho fijo, alto similar al header. */
.cbs-lc__avatar {
    position: relative; flex: 0 0 auto;
    width: 96px; height: 32px;
    background: #fff;
    border-radius: 6px;
    display: flex; align-items: center; justify-content: center;
    overflow: hidden;
    padding: 3px 6px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}
.cbs-lc__avatar img {
    width: 100%; height: 100%;
    object-fit: contain;
    display: block;
}
.cbs-lc__head-txt {
    display: flex; flex-direction: column; line-height: 1.25;
    min-width: 0; flex: 1;
}
.cbs-lc__head-txt strong {
    font-size: 15px; font-weight: 600; letter-spacing: 0.01em;
}
.cbs-lc__head-txt span {
    font-size: 12px; opacity: 0.85;
    display: flex; align-items: center; gap: 4px;
}
.cbs-lc__head-txt span::before {
    content: ''; width: 6px; height: 6px; border-radius: 50%;
    background: var(--cbs-lc-wa-light);
    box-shadow: 0 0 4px rgba(37, 211, 102, 0.8);
}
.cbs-lc__close {
    border: 0; background: transparent; color: #fff; cursor: pointer;
    font-size: 22px; line-height: 1; padding: 4px 8px; opacity: 0.85;
    flex: 0 0 auto; border-radius: 8px;
    transition: background 0.15s, opacity 0.15s;
}
.cbs-lc__close:hover { background: rgba(255, 255, 255, 0.14); opacity: 1; }

/* ── Cuerpo de mensajes (fondo doodle WhatsApp) ─────── */
.cbs-lc__body {
    flex: 1 1 auto; overflow-y: auto;
    padding: 14px 12px;
    display: flex; flex-direction: column; gap: 6px;
    background-color: var(--cbs-lc-bg);
    /* Patrón doodle sutil — micropuntos + ligera textura */
    background-image:
        radial-gradient(rgba(0, 0, 0, 0.04) 1px, transparent 1px),
        radial-gradient(rgba(255, 255, 255, 0.5) 1px, transparent 1px);
    background-size: 22px 22px, 33px 33px;
    background-position: 0 0, 11px 11px;
}
.cbs-lc__body::-webkit-scrollbar { width: 5px; }
.cbs-lc__body::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.18); border-radius: 4px;
}

/* ── Burbujas (estilo WhatsApp con tail) ────────────── */
.cbs-lc__msg {
    position: relative;
    max-width: 80%;
    padding: 6px 10px 20px;
    border-radius: 8px;
    font-size: 14px; line-height: 1.4; color: #111827;
    word-wrap: break-word; white-space: pre-wrap;
    box-shadow: 0 1px 1px rgba(0, 0, 0, 0.12);
    animation: cbsLcMsg 0.18s ease;
}
@keyframes cbsLcMsg {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Visitor (me): a la derecha, verde claro WhatsApp + tail */
.cbs-lc__msg--me {
    align-self: flex-end;
    background: var(--cbs-lc-bubble-me);
    border-top-right-radius: 0;
    margin-right: 6px;
}
.cbs-lc__msg--me::after {
    content: '';
    position: absolute; top: 0; right: -8px;
    width: 0; height: 0;
    border-top: 10px solid var(--cbs-lc-bubble-me);
    border-right: 8px solid transparent;
}

/* Operador (bot pre-conexión): a la izquierda, blanco + tail */
.cbs-lc__msg--op {
    align-self: flex-start;
    background: var(--cbs-lc-bubble-op);
    border-top-left-radius: 0;
    margin-left: 6px;
}
.cbs-lc__msg--op::after {
    content: '';
    position: absolute; top: 0; left: -8px;
    width: 0; height: 0;
    border-top: 10px solid var(--cbs-lc-bubble-op);
    border-left: 8px solid transparent;
}

/* Agente humano del CRM (Mirian): blanco con acento CBS azul */
.cbs-lc__msg--agent {
    align-self: flex-start;
    background: var(--cbs-lc-bubble-op);
    border-top-left-radius: 0;
    border-left: 3px solid var(--cbs-lc-blue);
    padding-left: 9px;
    margin-left: 6px;
}
.cbs-lc__msg--agent::after {
    content: '';
    position: absolute; top: 0; left: -8px;
    width: 0; height: 0;
    border-top: 10px solid var(--cbs-lc-bubble-op);
    border-left: 8px solid transparent;
}

/* Bot del CRM (off-hours): lavanda con acento indigo */
.cbs-lc__msg--bot {
    align-self: flex-start;
    background: #F3F4FF;
    border-top-left-radius: 0;
    border-left: 3px solid #6366f1;
    padding-left: 9px;
    margin-left: 6px;
}
.cbs-lc__msg--bot::after {
    content: '';
    position: absolute; top: 0; left: -8px;
    width: 0; height: 0;
    border-top: 10px solid #F3F4FF;
    border-left: 8px solid transparent;
}

/* System messages (ej. "conversación cerrada") */
.cbs-lc__msg--system {
    align-self: center;
    background: rgba(255, 255, 255, 0.85);
    font-size: 11.5px; color: #5b6470;
    padding: 5px 12px; border-radius: 12px;
    font-style: italic;
    box-shadow: 0 1px 1px rgba(0, 0, 0, 0.08);
    max-width: 90%;
    text-align: center;
}

/* Etiqueta del sender (agente/bot) arriba del mensaje */
.cbs-lc__msg-sender {
    display: block;
    font-size: 11px; font-weight: 600;
    color: #6366f1;
    margin-bottom: 2px;
    letter-spacing: 0.02em;
}
.cbs-lc__msg--agent .cbs-lc__msg-sender { color: var(--cbs-lc-blue); }

/* Footer del mensaje — hora + check marks */
.cbs-lc__msg-meta {
    position: absolute; right: 8px; bottom: 4px;
    display: flex; align-items: center; gap: 3px;
    font-size: 10.5px; color: rgba(0, 0, 0, 0.45);
}
.cbs-lc__msg-time { line-height: 1; }
.cbs-lc__msg-check {
    display: inline-flex; align-items: center;
    font-size: 12px; line-height: 1;
    color: rgba(0, 0, 0, 0.45);
    margin-left: 1px;
}
/* Check entregado (visto por el agente) → azul WhatsApp */
.cbs-lc__msg--me.cbs-lc__msg--delivered .cbs-lc__msg-check {
    color: var(--cbs-lc-wa-tick);
}

/* ── Botones de elección (Camino A — WhatsApp vs chat) ──── */
.cbs-lc__choices {
    align-self: flex-start;
    display: flex; flex-direction: column; gap: 6px;
    max-width: 85%;
    margin: 2px 0 4px 6px;
    animation: cbsLcMsg 0.22s ease;
}
.cbs-lc__choice {
    display: inline-flex; align-items: center; gap: 8px;
    border: 0; cursor: pointer;
    padding: 10px 16px;
    border-radius: 22px;
    font-size: 13.5px; font-weight: 600;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
    transition: transform 0.12s, box-shadow 0.15s, background 0.15s;
    font-family: inherit;
}
.cbs-lc__choice svg { flex: 0 0 auto; }
.cbs-lc__choice:hover  { transform: translateY(-1px); box-shadow: 0 3px 10px rgba(0, 0, 0, 0.16); }
.cbs-lc__choice:active { transform: scale(0.97); }

.cbs-lc__choice--wa {
    background: var(--cbs-lc-wa-light); color: #fff;
}
.cbs-lc__choice--wa:hover { background: var(--cbs-lc-wa-mid); }

.cbs-lc__choice--here {
    background: #fff; color: var(--cbs-lc-blue);
    border: 1.5px solid var(--cbs-lc-blue);
}
.cbs-lc__choice--here:hover { background: #f0f4ff; }

/* ── Error inline ────────────────────────────────────── */
.cbs-lc__err {
    align-self: center;
    background: #fef2f2; color: #b91c1c;
    font-size: 12px; padding: 6px 12px; border-radius: 10px;
    max-width: 90%; text-align: center;
    border: 1px solid #fecaca;
}

/* ── Typing indicator ────────────────────────────────── */
.cbs-lc__typing {
    align-self: flex-start;
    background: var(--cbs-lc-bubble-op);
    border-radius: 8px; border-top-left-radius: 0;
    padding: 11px 16px;
    display: flex; gap: 4px;
    box-shadow: 0 1px 1px rgba(0, 0, 0, 0.12);
    margin-left: 6px;
    position: relative;
}
.cbs-lc__typing::after {
    content: '';
    position: absolute; top: 0; left: -8px;
    width: 0; height: 0;
    border-top: 10px solid var(--cbs-lc-bubble-op);
    border-left: 8px solid transparent;
}
.cbs-lc__typing span {
    width: 7px; height: 7px; border-radius: 50%; background: #9ca3af;
    animation: cbsLcTyping 1.2s infinite ease-in-out;
}
.cbs-lc__typing span:nth-child(2) { animation-delay: 0.18s; }
.cbs-lc__typing span:nth-child(3) { animation-delay: 0.36s; }
@keyframes cbsLcTyping {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
    30%           { transform: translateY(-5px); opacity: 1; }
}

/* ── Barra de entrada ────────────────────────────────── */
.cbs-lc__input {
    flex: 0 0 auto;
    display: flex; align-items: center; gap: 8px;
    padding: 9px 11px;
    background: #f0f2f5;
    border-top: 1px solid rgba(0, 0, 0, 0.05);
}
.cbs-lc__input input {
    flex: 1; min-width: 0;
    border: 0 !important; outline: 0 !important; box-shadow: none !important;
    background: #fff !important;
    border-radius: 22px !important;
    padding: 11px 18px !important; margin: 0 !important;
    font-size: 14px; color: #0f172a; height: auto !important;
    -webkit-appearance: none; appearance: none;
}
.cbs-lc__input input::placeholder { color: #9ca3af; }
.cbs-lc__input input:disabled { background: #e9edef !important; cursor: wait; }
.cbs-lc__input button {
    flex: 0 0 auto;
    width: 44px; height: 44px; border-radius: 50%;
    border: 0; cursor: pointer;
    background: var(--cbs-lc-wa-light); color: #fff;
    display: flex; align-items: center; justify-content: center;
    transition: background 0.15s, transform 0.12s, box-shadow 0.15s;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}
.cbs-lc__input button:hover  { background: var(--cbs-lc-wa-mid); box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2); }
.cbs-lc__input button:active { transform: scale(0.93); }
.cbs-lc__input button:disabled { background: #9ca3af; cursor: default; box-shadow: none; }

/* ── Móvil — panel casi pantalla completa ────────────── */
@media (max-width: 480px) {
    .cbs-lc__panel {
        right: 8px; left: 8px; bottom: 84px;
        width: auto; max-width: none;
        height: calc(var(--cbs-lc-h, 100vh) - 100px);
        max-height: calc(var(--cbs-lc-h, 100vh) - 100px);
        border-radius: 10px;
    }
}

/* ── Zoho SalesIQ no debe superponer el FAB del chat ── */
body.cbs-lc-open .zsiq-float,
body.cbs-lc-open .zsiq_floatmain,
body.cbs-lc-open #zsiq_float,
body.cbs-lc-open #zsiqwidget,
body.cbs-lc-open [class*="zsiq_"] {
    display: none !important;
}
