/* ═══════════════════════════════════════
   Living Alarm – Chat Widget Styles
   ═══════════════════════════════════════ */

:root {
    --la-blue:      #2563eb;
    --la-blue-dark: #1d4ed8;
    --la-bot-bg:    #f1f5f9;
    --la-user-bg:   #2563eb;
    --la-radius:    18px;
    --la-font:      'Inter', 'Segoe UI', system-ui, sans-serif;
    --la-shadow:    0 20px 60px rgba(0,0,0,0.18);
}

/* ── Container ── */
#la-chat {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 99999;
    font-family: var(--la-font);
    font-size: 14px;
    line-height: 1.5;
}

/* ── Chat Window ── */
#la-window {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 370px;
    height: 580px;
    background: #fff;
    border-radius: 20px;
    box-shadow: var(--la-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    transform: translateY(20px) scale(0.96);
    pointer-events: none;
    transition: opacity 0.25s ease, transform 0.25s ease;
}

#la-window.la-open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: all;
}

/* ── Header ── */
#la-header {
    background: linear-gradient(135deg, var(--la-blue) 0%, #1e40af 100%);
    padding: 16px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

#la-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

#la-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255,255,255,0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 13px;
    color: #fff;
    flex-shrink: 0;
    border: 2px solid rgba(255,255,255,0.4);
}

#la-title {
    color: #fff;
    font-weight: 700;
    font-size: 15px;
    letter-spacing: -0.2px;
}

#la-status {
    color: rgba(255,255,255,0.8);
    font-size: 11.5px;
    display: flex;
    align-items: center;
    gap: 5px;
    margin-top: 2px;
}

.la-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #4ade80;
    display: inline-block;
    animation: la-pulse 2s infinite;
}

@keyframes la-pulse {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.4; }
}

#la-close {
    background: rgba(255,255,255,0.15);
    border: none;
    color: #fff;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 13px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
}

#la-close:hover { background: rgba(255,255,255,0.3); }

/* ── Messages Area ── */
#la-messages {
    flex: 1;
    padding: 16px 14px 8px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: #f8fafc;
    scroll-behavior: smooth;
}

#la-messages::-webkit-scrollbar { width: 4px; }
#la-messages::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }

/* ── Message Wrappers ── */
.la-msg-wrap {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    max-width: 100%;
    animation: la-fadein 0.2s ease;
}

@keyframes la-fadein {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.la-bot, .la-ai, .la-admin { flex-direction: row; }
.la-user { flex-direction: row-reverse; }
.la-error { flex-direction: row; }

/* Small avatar for bot/admin */
.la-avatar-sm {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--la-blue);
    color: #fff;
    font-size: 9px;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-bottom: 4px;
}

.la-admin .la-avatar-sm { background: #7c3aed; }

/* ── Bubbles ── */
.la-bubble {
    max-width: 78%;
    padding: 10px 14px;
    border-radius: var(--la-radius);
    word-break: break-word;
    font-size: 13.5px;
    line-height: 1.55;
}

.la-bot .la-bubble,
.la-ai .la-bubble {
    background: #fff;
    color: #1e293b;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.07);
}

.la-admin .la-bubble {
    background: #ede9fe;
    color: #4c1d95;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.07);
}

.la-user .la-bubble {
    background: var(--la-user-bg);
    color: #fff;
    border-bottom-right-radius: 4px;
    box-shadow: 0 2px 8px rgba(37,99,235,0.3);
}

.la-error .la-bubble {
    background: #fee2e2;
    color: #991b1b;
    border-bottom-left-radius: 4px;
    font-size: 12.5px;
}

/* Timestamp */
.la-ts {
    font-size: 10.5px;
    color: #94a3b8;
    align-self: flex-end;
    margin-bottom: 4px;
    white-space: nowrap;
}
.la-user .la-ts { order: -1; }

/* ── Typing Indicator ── */
#la-typing {
    display: none;
    align-items: center;
    gap: 8px;
    padding: 4px 14px 8px;
    background: #f8fafc;
}

#la-typing-inner {
    display: flex;
    align-items: center;
    gap: 8px;
}

.la-typing-dots {
    display: flex;
    align-items: center;
    gap: 4px;
    background: #fff;
    padding: 10px 14px;
    border-radius: 18px;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.07);
}

.la-typing-dots span {
    width: 7px;
    height: 7px;
    background: #94a3b8;
    border-radius: 50%;
    display: inline-block;
    animation: la-bounce 1.3s infinite;
}

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

@keyframes la-bounce {
    0%, 80%, 100% { transform: scale(0.7); opacity: 0.5; }
    40%            { transform: scale(1);   opacity: 1; }
}

/* ── Quick Replies ── */
#la-quick {
    padding: 6px 14px 8px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    background: #f8fafc;
    flex-shrink: 0;
}

.la-qr-btn {
    background: #fff;
    border: 1.5px solid #e2e8f0;
    color: var(--la-blue);
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    font-family: var(--la-font);
    white-space: nowrap;
}

.la-qr-btn:hover {
    background: var(--la-blue);
    border-color: var(--la-blue);
    color: #fff;
    box-shadow: 0 2px 8px rgba(37,99,235,0.25);
}

/* ── Input Footer ── */
#la-footer {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 14px;
    border-top: 1px solid #e2e8f0;
    background: #fff;
    flex-shrink: 0;
}

#la-input {
    flex: 1;
    padding: 10px 16px;
    border: 1.5px solid #e2e8f0;
    border-radius: 25px;
    outline: none;
    font-size: 13.5px;
    color: #1e293b;
    font-family: var(--la-font);
    transition: border-color 0.15s, box-shadow 0.15s;
    background: #f8fafc;
}

#la-input:focus {
    border-color: var(--la-blue);
    background: #fff;
    box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}

#la-input::placeholder { color: #94a3b8; }
#la-input:disabled { opacity: 0.6; }

#la-send {
    width: 40px;
    height: 40px;
    background: var(--la-blue);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.15s, transform 0.1s, box-shadow 0.15s;
    box-shadow: 0 2px 8px rgba(37,99,235,0.3);
}

#la-send svg {
    width: 18px;
    height: 18px;
    fill: #fff;
}

#la-send:hover {
    background: var(--la-blue-dark);
    transform: scale(1.05);
}

#la-send:disabled {
    background: #94a3b8;
    box-shadow: none;
    transform: none;
    cursor: not-allowed;
}

/* ── Launcher Button ── */
#la-btn {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--la-blue) 0%, #1e40af 100%);
    box-shadow: 0 4px 20px rgba(37,99,235,0.45);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

#la-btn:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 28px rgba(37,99,235,0.55);
}

#la-btn-icon {
    position: relative;
    width: 28px;
    height: 28px;
}

#la-btn-icon svg {
    position: absolute;
    top: 0;
    left: 0;
    width: 28px;
    height: 28px;
    fill: #fff;
    transition: opacity 0.2s, transform 0.2s;
}

.la-icon-chat  { opacity: 1;  transform: rotate(0deg) scale(1); }
.la-icon-close { opacity: 0;  transform: rotate(-90deg) scale(0.7); }

#la-btn.la-open .la-icon-chat  { opacity: 0;  transform: rotate(90deg) scale(0.7); }
#la-btn.la-open .la-icon-close { opacity: 1;  transform: rotate(0deg) scale(1); }

/* Notification badge */
#la-notif {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 20px;
    height: 20px;
    background: #ef4444;
    color: #fff;
    border-radius: 50%;
    font-size: 11px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #fff;
    animation: la-pop 0.3s ease;
}

@keyframes la-pop {
    from { transform: scale(0); }
    to   { transform: scale(1); }
}

/* ── Responsive ── */
@media (max-width: 420px) {
    #la-window {
        width: calc(100vw - 32px);
        right: 0;
        bottom: 76px;
        border-radius: 16px;
        height: 72vh;
    }
    #la-chat { right: 16px; bottom: 16px; }
}
