/* ==============================================
   TRI AI Chatbot — Premium Widget Styles v2
   ============================================== */

/* ── Trigger Button ─────────────────────────── */
.chatbot-trigger {
    position: fixed;
    bottom: 100px;
    right: 28px;
    z-index: 9998;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.chatbot-trigger-btn {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #a855f7 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 24px rgba(99, 102, 241, .45);
    transition: all .3s cubic-bezier(.4,0,.2,1);
    position: relative;
    border: none;
    outline: none;
}

.chatbot-trigger-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 8px 36px rgba(99, 102, 241, .55);
}

/* Pulse ring */
.chatbot-trigger-btn::before {
    content: '';
    position: absolute;
    inset: -6px;
    border-radius: 50%;
    border: 2px solid rgba(99, 102, 241, .35);
    animation: triPulse 2s ease-in-out infinite;
    pointer-events: none;
}

@keyframes triPulse {
    0%, 100% { transform: scale(1); opacity: .6; }
    50%        { transform: scale(1.25); opacity: 0; }
}

.chatbot-trigger-label {
    position: absolute;
    top: calc(100% + 6px);
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: #fff;
    font-family: 'Inter', sans-serif;
    font-size: .7rem;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 999px;
    letter-spacing: .03em;
    white-space: nowrap;
    opacity: 0;
    transform: translateY(4px);
    transition: all .3s ease;
    pointer-events: none;
}

.chatbot-trigger:not(.active):hover .chatbot-trigger-label {
    opacity: 1;
    transform: translateY(0);
}

/* Icons toggle */
.chatbot-icon-close { display: none; }
.chatbot-trigger.active .chatbot-icon-open  { display: none; }
.chatbot-trigger.active .chatbot-icon-close { display: block; }

/* Notification badge */
.chatbot-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    width: 20px;
    height: 20px;
    background: #ef4444;
    border-radius: 50%;
    color: #fff;
    font-size: .68rem;
    font-weight: 700;
    display: none;
    align-items: center;
    justify-content: center;
    border: 2px solid #fff;
    animation: badgePop .4s cubic-bezier(.34,1.56,.64,1);
    z-index: 1;
}

@keyframes badgePop {
    from { transform: scale(0); }
    to   { transform: scale(1); }
}

.chatbot-trigger.active .chatbot-badge { display: none !important; }

/* ── Chat Window ────────────────────────────── */
.chatbot-window {
    position: fixed;
    bottom: 178px;
    right: 28px;
    width: 390px;
    max-height: 580px;
    background: #fff;
    border-radius: 24px;
    box-shadow:
        0 24px 64px rgba(0, 0, 0, .14),
        0 0 0 1px rgba(0,0,0,.05),
        inset 0 1px 0 rgba(255,255,255,.8);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transform: translateY(24px) scale(.94);
    transition: all .38s cubic-bezier(.34,1.56,.64,1);
    will-change: transform, opacity;
}

.chatbot-window.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

/* ── Header ─────────────────────────────────── */
.chatbot-header {
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 60%, #9333ea 100%);
    padding: 16px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: #fff;
    flex-shrink: 0;
    position: relative;
    overflow: hidden;
}

/* Header background pattern */
.chatbot-header::after {
    content: '';
    position: absolute;
    right: -20px;
    top: -20px;
    width: 100px;
    height: 100px;
    background: radial-gradient(circle, rgba(255,255,255,.15) 0%, transparent 70%);
    border-radius: 50%;
    pointer-events: none;
}

.chatbot-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
    z-index: 1;
}

/* TRI Avatar */
.tri-avatar-wrap {
    position: relative;
    width: 42px;
    height: 42px;
    flex-shrink: 0;
}

.tri-avatar-ring {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: rgba(255,255,255,.2);
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid rgba(255,255,255,.35);
    backdrop-filter: blur(4px);
}

.tri-avatar-pulse {
    position: absolute;
    inset: -3px;
    border-radius: 50%;
    border: 2px solid rgba(255,255,255,.3);
    animation: avatarPulse 2.5s ease-in-out infinite;
}

@keyframes avatarPulse {
    0%, 100% { transform: scale(1); opacity: .6; }
    50%        { transform: scale(1.15); opacity: 0; }
}

.chatbot-header h4 {
    font-family: 'Outfit', sans-serif;
    font-size: .95rem;
    font-weight: 700;
    margin: 0 0 2px;
    letter-spacing: -.01em;
}

.chatbot-header-sub {
    font-size: .7rem;
    opacity: .75;
    font-family: 'Inter', sans-serif;
}

.chatbot-status {
    font-size: .7rem;
    opacity: .9;
    display: flex;
    align-items: center;
    gap: 5px;
    font-family: 'Inter', sans-serif;
}

.status-dot {
    width: 7px;
    height: 7px;
    background: #22c55e;
    border-radius: 50%;
    display: inline-block;
    animation: statusPulse 2s ease-in-out infinite;
    box-shadow: 0 0 6px rgba(34,197,94,.6);
}

@keyframes statusPulse {
    0%, 100% { opacity: 1; box-shadow: 0 0 6px rgba(34,197,94,.6); }
    50%        { opacity: .5; box-shadow: 0 0 2px rgba(34,197,94,.2); }
}

/* Header action buttons */
.chatbot-header-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    z-index: 1;
}

.chatbot-header-btn {
    background: rgba(255,255,255,.15);
    border: none;
    color: #fff;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background .2s;
    font-size: 1rem;
}

.chatbot-header-btn:hover {
    background: rgba(255,255,255,.25);
}

.chatbot-header-btn.active {
    background: rgba(255,255,255,.3);
    color: #fde047;
}

.chatbot-close {
    background: rgba(255,255,255,.15);
    border: none;
    color: #fff;
    font-size: 1.4rem;
    cursor: pointer;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .2s;
    line-height: 1;
    z-index: 1;
}

.chatbot-close:hover {
    background: rgba(255,255,255,.25);
}

/* ── Body ───────────────────────────────────── */
.chatbot-body {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    max-height: 340px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    scrollbar-width: thin;
    scrollbar-color: #e2e8f0 transparent;
    background: #f8fafc;
}

.chatbot-body::-webkit-scrollbar { width: 4px; }
.chatbot-body::-webkit-scrollbar-thumb {
    background: #e2e8f0;
    border-radius: 999px;
}

/* ── Messages ───────────────────────────────── */
.chat-msg {
    display: flex;
    gap: 8px;
    animation: msgIn .3s cubic-bezier(.34,1.56,.64,1);
    align-items: flex-end;
}

@keyframes msgIn {
    from { opacity: 0; transform: translateY(12px) scale(.96); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.chat-msg.bot  { align-items: flex-start; }
.chat-msg.user { flex-direction: row-reverse; }

/* Avatars */
.chat-msg-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .65rem;
    font-weight: 700;
}

.tri-avatar {
    background: linear-gradient(135deg, #4f46e5, #9333ea);
    color: #fff;
    box-shadow: 0 2px 8px rgba(99,102,241,.3);
}

.user-avatar {
    background: linear-gradient(135deg, #e0e7ff, #f0f9ff);
    color: #4f46e5;
    border: 1px solid #c7d2fe;
}

/* Chat bubbles */
.chat-bubble {
    max-width: 82%;
    padding: 11px 15px;
    border-radius: 18px;
    font-size: .875rem;
    line-height: 1.6;
    font-family: 'Inter', sans-serif;
}

.chat-msg.bot .chat-bubble {
    background: #fff;
    color: #1e293b;
    border-bottom-left-radius: 5px;
    box-shadow: 0 1px 4px rgba(0,0,0,.07);
}

.chat-msg.user .chat-bubble {
    background: linear-gradient(135deg, #4f46e5, #7c3aed);
    color: #fff;
    border-bottom-right-radius: 5px;
    box-shadow: 0 2px 10px rgba(79,70,229,.3);
}

/* Bullet points inside bot messages */
.chat-bullet {
    display: block;
    padding-left: 4px;
}

/* ── Typing Indicator ───────────────────────── */
.typing-indicator {
    display: flex;
    gap: 5px;
    padding: 4px 2px;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background: #c7d2fe;
    border-radius: 50%;
    animation: triTyping 1.4s ease-in-out infinite;
}

.typing-indicator span:nth-child(2) { animation-delay: .2s; }
.typing-indicator span:nth-child(3) { animation-delay: .4s; }

@keyframes triTyping {
    0%, 100% { transform: translateY(0); opacity: .4; }
    50%        { transform: translateY(-5px); opacity: 1; }
}

/* ── Quick Replies ──────────────────────────── */
.chatbot-quick-replies {
    padding: 4px 16px 10px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    flex-shrink: 0;
    background: #f8fafc;
}

.quick-reply-btn {
    padding: 7px 14px;
    background: #fff;
    border: 1.5px solid #e0e7ff;
    border-radius: 999px;
    font-size: .78rem;
    font-weight: 500;
    color: #4f46e5;
    cursor: pointer;
    transition: all .2s cubic-bezier(.4,0,.2,1);
    font-family: 'Inter', sans-serif;
    white-space: nowrap;
    box-shadow: 0 1px 3px rgba(0,0,0,.05);
}

.quick-reply-btn:hover {
    background: linear-gradient(135deg, #4f46e5, #7c3aed);
    color: #fff;
    border-color: transparent;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(79,70,229,.3);
}

/* ── Input Area ─────────────────────────────── */
.chatbot-input-area {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 14px;
    border-top: 1px solid #f1f5f9;
    background: #fff;
    flex-shrink: 0;
}

#chatbot-input {
    flex: 1;
    padding: 10px 15px;
    background: #f8fafc;
    border: 1.5px solid #e2e8f0;
    border-radius: 999px;
    font-family: 'Inter', sans-serif;
    font-size: .875rem;
    color: #0f172a;
    outline: none;
    transition: all .2s;
}

#chatbot-input:focus {
    border-color: #6366f1;
    background: #fff;
    box-shadow: 0 0 0 3px rgba(99,102,241,.1);
}

#chatbot-input::placeholder { color: #94a3b8; }

/* Voice button */
#chatbot-voice-btn {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: #f1f5f9;
    border: 1.5px solid #e2e8f0;
    color: #64748b;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all .2s;
    flex-shrink: 0;
}

#chatbot-voice-btn:hover {
    background: #e0e7ff;
    border-color: #c7d2fe;
    color: #4f46e5;
}

#chatbot-voice-btn.listening {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    border-color: transparent;
    color: #fff;
    box-shadow: 0 0 0 4px rgba(239,68,68,.2);
    animation: voicePulse 1s ease-in-out infinite;
}

@keyframes voicePulse {
    0%, 100% { box-shadow: 0 0 0 4px rgba(239,68,68,.2); }
    50%        { box-shadow: 0 0 0 8px rgba(239,68,68,.05); }
}

/* Send button */
#chatbot-send {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #4f46e5, #7c3aed);
    border: none;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all .2s;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(79,70,229,.3);
}

#chatbot-send:hover {
    transform: scale(1.08);
    box-shadow: 0 4px 16px rgba(79,70,229,.45);
}

/* Speaker toggle button (in header) */
#chatbot-speaker-btn {
    position: relative;
}

/* ── Powered by footer ──────────────────────── */
.chatbot-powered {
    text-align: center;
    padding: 5px 0 8px;
    font-size: .65rem;
    color: #94a3b8;
    font-family: 'Inter', sans-serif;
    background: #fff;
    flex-shrink: 0;
}

.chatbot-powered a {
    color: #6366f1;
    text-decoration: none;
    font-weight: 500;
}

/* ── Responsive ─────────────────────────────── */
@media (max-width: 480px) {
    .chatbot-window {
        right: 0;
        left: 0;
        bottom: 0;
        width: 100%;
        max-height: 85dvh;
        border-radius: 24px 24px 0 0;
        transform: translateY(100%) scale(1);
    }

    .chatbot-window.active {
        transform: translateY(0) scale(1);
    }

    .chatbot-trigger {
        bottom: 84px;
        right: 16px;
    }

    .chatbot-body {
        max-height: 50dvh;
    }
}

@media (max-width: 768px) and (min-width: 481px) {
    .chatbot-window {
        right: 12px;
        bottom: 150px;
        width: calc(100vw - 24px);
        max-height: 75vh;
    }
}
