/* ============================================
   Asistente DR360 — Widget Light (spec UI)
   #0D2C4D · #F7931E · #F5F7FA · Poppins
   Solo tema claro — sin variante dark.
   ============================================ */

:root {
    --laia-navy: #0D2C4D;
    --laia-orange: #F7931E;
    --laia-bg: #F5F7FA;
    --laia-white: #FFFFFF;
    --laia-green: #22C55E;
    --laia-text: #1E293B;
    --laia-muted: #64748B;
    --laia-border: rgba(13, 44, 77, 0.1);
}

/* ── FAB (DR360 + punto online) ── */
.laia-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(--laia-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;
}

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

.laia-toggle-logo {
    font-family: 'Poppins', sans-serif;
    font-weight: 800;
    font-size: 15px;
    letter-spacing: -0.5px;
    line-height: 1;
    pointer-events: none;
}

.laia-toggle-logo .dr { color: #fff; }
.laia-toggle-logo .num { color: var(--laia-orange); }

.laia-toggle .laia-close-icon { display: none; }

.laia-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; }
}

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

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

/* ── Ventana chat (light) ── */
.laia-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(--laia-bg);
    border: 1px solid var(--laia-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: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

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

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

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

.laia-header-avatar .laia-brand-mark {
    font-weight: 800;
    font-size: 11px;
    letter-spacing: -0.3px;
}

.laia-header-avatar .laia-brand-mark .dr { color: var(--laia-navy); }
.laia-header-avatar .laia-brand-mark .num { color: var(--laia-orange); }

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

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

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

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

.laia-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;
}

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

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

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

.laia-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;
}

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

.laia-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); }
}

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

.laia-msg .laia-msg-avatar .laia-brand-mark {
    font-size: 7px;
    font-weight: 800;
}

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

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

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

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

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

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

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

.laia-typing.show { display: flex; }

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

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

.laia-typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.laia-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) */
.laia-quick {
    display: flex;
    flex-direction: column;
    gap: 0.42rem;
    padding: 0.35rem 1rem 0.75rem;
    flex-shrink: 0;
}

.laia-quick-btn {
    width: 100%;
    text-align: left;
    padding: 0.65rem 0.95rem;
    font-size: 0.82rem;
    font-weight: 500;
    border: 1px solid var(--laia-border);
    border-radius: 12px;
    background: var(--laia-white);
    color: var(--laia-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;
}

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

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

.laia-input {
    flex: 1;
    background: var(--laia-white);
    border: 1px solid var(--laia-border);
    border-radius: 12px;
    padding: 0.65rem 0.95rem;
    color: var(--laia-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;
}

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

.laia-send {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--laia-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;
}

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

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

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

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

/* ── Mobile ── */
@media (max-width: 480px) {
    .laia-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;
    }

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

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

    .laia-bubble { max-width: 90%; }

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

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