/* ============================================
   Asistente LiAds — Widget Light (spec UI)
   #14122B · #A33BDA · #F5F7FA · Plus Jakarta Sans
   Solo tema claro — sin variante dark.
   ============================================ */

:root {
    --liads-ai-navy: #14122B;
    --liads-ai-orange: #A33BDA;
    --liads-ai-bg: #F5F7FA;
    --liads-ai-white: #FFFFFF;
    --liads-ai-green: #22C55E;
    --liads-ai-text: #1E293B;
    --liads-ai-muted: #64748B;
    --liads-ai-border: rgba(13, 44, 77, 0.1);
}

/* ── FAB (LiAds + punto online) ── */
.liads-ai-toggle {
    position: fixed;
    bottom: calc(28px + env(safe-area-inset-bottom, 0px));
    right: calc(28px + env(safe-area-inset-right, 0px));
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: var(--liads-ai-navy);
    border: 3px solid rgba(255, 255, 255, 0.95);
    cursor: pointer;
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 28px rgba(13, 44, 77, 0.32);
    transition: transform 0.22s ease, box-shadow 0.22s ease, opacity 0.22s ease;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

.liads-ai-toggle:hover {
    transform: scale(1.05);
    box-shadow: 0 10px 32px rgba(13, 44, 77, 0.38);
}

.liads-ai-toggle-img,
.liads-ai-brand-img {
    display: block;
    object-fit: contain;
    pointer-events: none;
}

.liads-ai-toggle-img {
    width: 32px;
    height: 32px;
    filter: drop-shadow(0 0 8px rgba(62, 226, 254, 0.55)) drop-shadow(0 0 4px rgba(255, 255, 255, 0.35));
}

.liads-ai-brand-img {
    width: 28px;
    height: 28px;
}
.liads-ai-toggle {
    background: linear-gradient(135deg, #14122B 0%, #A33BDA 100%);
}
.liads-ai-header {
    background: linear-gradient(135deg, #14122B 0%, #2A1140 100%);
}
.liads-ai-header h4 { color: #fff; }
.liads-ai-send { background: #A33BDA; }
.liads-ai-send:hover { background: #8E2FC4; }
.liads-ai-user .liads-ai-bubble { background: #A33BDA; }

.liads-ai-toggle .liads-ai-close-icon { display: none; }

.liads-ai-toggle::after {
    content: '';
    position: absolute;
    inset: -4px;
    border-radius: 50%;
    border: 2px solid rgba(247, 147, 30, 0.28);
    animation: laiaPing 2.6s ease-out infinite;
    z-index: -1;
    pointer-events: none;
}

@keyframes laiaPing {
    0% { transform: scale(1); opacity: 0.5; }
    100% { transform: scale(1.32); opacity: 0; }
}

.liads-ai-badge {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 14px;
    height: 14px;
    background: var(--liads-ai-green);
    border-radius: 50%;
    border: 2px solid var(--liads-ai-white);
    pointer-events: none;
}

/* Ocultar FAB mientras el chat está abierto (minimizar desde header) */
body.liads-ai-chat-open .liads-ai-toggle {
    opacity: 0;
    pointer-events: none;
    transform: scale(0.85);
}

/* ── Ventana chat (light) ── */
.liads-ai-chat {
    position: fixed;
    bottom: calc(105px + env(safe-area-inset-bottom, 0px));
    right: calc(28px + env(safe-area-inset-right, 0px));
    width: 400px;
    max-width: calc(100vw - 32px);
    height: min(580px, calc(100vh - 140px));
    max-height: calc(100dvh - 140px);
    background: var(--liads-ai-bg);
    border: 1px solid var(--liads-ai-border);
    border-radius: 16px;
    z-index: 99998;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    transform: translateY(16px) scale(0.97);
    pointer-events: none;
    transition: opacity 0.28s ease, transform 0.28s ease;
    box-shadow: 0 20px 56px rgba(13, 44, 77, 0.16);
    font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

.liads-ai-chat.open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: all;
}

/* ── Header navy ── */
.liads-ai-header {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.85rem 1rem;
    background: var(--liads-ai-navy);
    flex-shrink: 0;
}

.liads-ai-header-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--liads-ai-white);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.liads-ai-header-avatar .liads-ai-brand-img {
    width: 26px;
    height: 26px;
}

.liads-ai-header-info {
    flex: 1;
    min-width: 0;
}

.liads-ai-header-info h4 {
    font-size: 0.92rem;
    font-weight: 700;
    color: #fff;
    margin: 0;
    line-height: 1.2;
}

.liads-ai-header-info span {
    font-size: 0.7rem;
    color: #bbf7d0;
    display: flex;
    align-items: center;
    gap: 5px;
    font-weight: 500;
    margin-top: 2px;
}

.liads-ai-header-info span::before {
    content: '';
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--liads-ai-green);
    flex-shrink: 0;
}

.liads-ai-header-minimize {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.18s ease;
    -webkit-tap-highlight-color: transparent;
}

.liads-ai-header-minimize:hover {
    background: rgba(255, 255, 255, 0.22);
}

.liads-ai-header-minimize svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

/* ── Cuerpo scrollable (mensajes + quick actions) ── */
.liads-ai-body {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    background: var(--liads-ai-bg);
}

.liads-ai-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 1rem 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
}

.liads-ai-messages::-webkit-scrollbar { width: 4px; }
.liads-ai-messages::-webkit-scrollbar-thumb {
    background: rgba(13, 44, 77, 0.14);
    border-radius: 2px;
}

.liads-ai-msg {
    display: flex;
    gap: 0.5rem;
    align-items: flex-end;
    animation: laiaMsgSlide 0.26s ease-out;
}

@keyframes laiaMsgSlide {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

.liads-ai-msg .liads-ai-msg-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--liads-ai-white);
    border: 1px solid var(--liads-ai-border);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.liads-ai-msg .liads-ai-msg-avatar .liads-ai-brand-img {
    width: 18px;
    height: 18px;
}

.liads-ai-msg.user { flex-direction: row-reverse; }

.liads-ai-bubble {
    max-width: 85%;
    padding: 0.72rem 0.95rem;
    border-radius: 14px;
    font-size: 0.84rem;
    line-height: 1.55;
    color: var(--liads-ai-text);
    word-wrap: break-word;
}

.liads-ai-msg.bot .liads-ai-bubble {
    background: var(--liads-ai-white);
    border: 1px solid var(--liads-ai-border);
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 6px rgba(13, 44, 77, 0.04);
}

.liads-ai-msg.user .liads-ai-bubble {
    background: var(--liads-ai-white);
    border: 1px solid rgba(247, 147, 30, 0.35);
    border-bottom-right-radius: 4px;
}

.liads-ai-time {
    font-size: 0.62rem;
    color: var(--liads-ai-muted);
    margin-top: 0.22rem;
}

.liads-ai-msg.user .liads-ai-time { text-align: right; }

/* Typing */
.liads-ai-typing {
    display: none;
    align-items: center;
    gap: 0.5rem;
    padding: 0 1rem 0.35rem;
}

.liads-ai-typing.show { display: flex; }

.liads-ai-typing-dots {
    display: flex;
    gap: 4px;
    padding: 0.6rem 0.85rem;
    background: var(--liads-ai-white);
    border: 1px solid var(--liads-ai-border);
    border-radius: 14px;
    border-bottom-left-radius: 4px;
}

.liads-ai-typing-dots span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--liads-ai-muted);
    animation: laiaTyping 1.4s infinite;
}

.liads-ai-typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.liads-ai-typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes laiaTyping {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.35; }
    30% { transform: translateY(-4px); opacity: 1; }
}

/* Quick actions (pills spec) */
.liads-ai-quick {
    display: flex;
    flex-direction: column;
    gap: 0.42rem;
    padding: 0.35rem 1rem 0.75rem;
    flex-shrink: 0;
}

.liads-ai-quick-btn {
    width: 100%;
    text-align: left;
    padding: 0.65rem 0.95rem;
    font-size: 0.82rem;
    font-weight: 500;
    border: 1px solid var(--liads-ai-border);
    border-radius: 12px;
    background: var(--liads-ai-white);
    color: var(--liads-ai-navy);
    cursor: pointer;
    transition: border-color 0.16s ease, background 0.16s ease;
    font-family: inherit;
    line-height: 1.35;
    min-height: 44px;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.liads-ai-quick-btn:hover,
.liads-ai-quick-btn:active {
    border-color: rgba(247, 147, 30, 0.45);
    background: #fffaf5;
}

/* Input + footer */
.liads-ai-input-area {
    display: flex;
    align-items: flex-end;
    gap: 0.5rem;
    padding: 0.65rem 1rem;
    border-top: 1px solid var(--liads-ai-border);
    background: var(--liads-ai-white);
    flex-shrink: 0;
}

.liads-ai-input {
    flex: 1;
    background: var(--liads-ai-white);
    border: 1px solid var(--liads-ai-border);
    border-radius: 12px;
    padding: 0.65rem 0.95rem;
    color: var(--liads-ai-text);
    font-size: 16px; /* evita zoom iOS */
    font-family: inherit;
    outline: none;
    transition: border-color 0.18s;
    resize: none;
    max-height: 96px;
    min-height: 44px;
    line-height: 1.4;
}

.liads-ai-input::placeholder { color: #94a3b8; }
.liads-ai-input:focus { border-color: rgba(13, 44, 77, 0.35); }

.liads-ai-send {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--liads-ai-navy);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.18s ease, transform 0.18s ease;
    flex-shrink: 0;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.liads-ai-send:hover { background: #123a61; }
.liads-ai-send:active { transform: scale(0.96); }
.liads-ai-send svg { width: 18px; height: 18px; fill: #fff; }

.liads-ai-chat-footer {
    padding: 0.3rem 1rem calc(0.55rem + env(safe-area-inset-bottom, 0px));
    text-align: center;
    font-size: 0.62rem;
    color: var(--liads-ai-muted);
    background: var(--liads-ai-white);
    letter-spacing: 0.03em;
    flex-shrink: 0;
}

.liads-ai-chat-footer a {
    color: var(--liads-ai-muted);
    text-decoration: none;
    font-weight: 600;
    transition: color 0.18s ease;
}

.liads-ai-chat-footer a:hover {
    color: var(--liads-ai-orange);
}

.liads-ai-chat-footer strong {
    color: var(--liads-ai-navy);
    font-weight: 700;
}

body.liads-ai-chat-open {
    overflow: hidden;
    touch-action: none;
}

/* ── Mobile ── */
@media (max-width: 480px) {
    .liads-ai-chat {
        bottom: 0;
        right: 0;
        left: 0;
        width: 100%;
        max-width: 100%;
        height: 100dvh;
        max-height: 100dvh;
        border-radius: 0;
        border-left: none;
        border-right: none;
        border-bottom: none;
    }

    .liads-ai-chat.liads-ai-keyboard-open {
        height: var(--liads-ai-vv-height, 100dvh);
        max-height: var(--liads-ai-vv-height, 100dvh);
    }

    .liads-ai-toggle {
        bottom: calc(18px + env(safe-area-inset-bottom, 0px));
        right: calc(18px + env(safe-area-inset-right, 0px));
        width: 58px;
        height: 58px;
    }

    .liads-ai-bubble { max-width: 90%; }

    .liads-ai-header {
        padding-top: calc(0.85rem + env(safe-area-inset-top, 0px));
    }

    .liads-ai-quick-btn {
        font-size: 0.85rem;
        padding: 0.72rem 1rem;
    }
}
