/* =====================================================
   CHATBOT WIDGET - Infinity Shop AI Assistant
   Tema: Modern, Professional, E-Commerce
   ===================================================== */

@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@400;500;600;700;800&display=swap');

:root {
    --chat-primary:    #4F46E5;
    --chat-primary-dk: #3730A3;
    --chat-secondary:  #818CF8;
    --chat-accent:     #EEF2FF;
    --chat-bg:         #F8FAFC;
    --chat-surface:    #FFFFFF;
    --chat-border:     #E2E8F0;
    --chat-text:       #1E293B;
    --chat-muted:      #64748B;
    --chat-shadow:     0 8px 32px rgba(79,70,229,0.18), 0 2px 8px rgba(0,0,0,0.08);
    --chat-radius:     20px;
    --chat-font:       'Nunito', sans-serif;
    --chat-width:      380px;
    --chat-height:     560px;
    --chat-z:          9999;
}

/* ── FLOATING BUTTON ─────────────────────────── */
#chatbot-launcher {
    position: fixed;
    bottom: 28px;
    right: 28px;
    z-index: var(--chat-z);
    width: 62px;
    height: 62px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--chat-primary), #6366F1);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(79,70,229,0.45);
    transition: transform .25s cubic-bezier(.34,1.56,.64,1), box-shadow .2s;
    outline: none;
}
#chatbot-launcher:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 28px rgba(79,70,229,0.55);
}
#chatbot-launcher:active { transform: scale(.97); }

#chatbot-launcher .launcher-icon { 
    width: 28px; 
    height: 28px; 
    transition: opacity .2s, transform .2s; 
}
#chatbot-launcher .launcher-close {
    position: absolute;
    opacity: 0;
    transform: rotate(-90deg) scale(.7);
    transition: opacity .2s, transform .2s;
    color: white;
    font-size: 22px;
    line-height: 1;
}
#chatbot-launcher.is-open .launcher-icon { opacity: 0; transform: scale(.7); }
#chatbot-launcher.is-open .launcher-close { opacity: 1; transform: rotate(0) scale(1); }

/* Notifikasi badge */
.chat-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 18px;
    height: 18px;
    background: var(--chat-secondary);
    border-radius: 50%;
    border: 2px solid white;
    font-size: 9px;
    font-weight: 800;
    color: var(--chat-text);
    display: flex;
    align-items: center;
    justify-content: center;
    animation: badge-pulse 1.8s ease-in-out infinite;
}
@keyframes badge-pulse {
    0%,100% { transform: scale(1); }
    50%      { transform: scale(1.15); }
}

/* ── CHAT WINDOW ─────────────────────────────── */
#chatbot-window {
    position: fixed;
    bottom: 104px;
    right: 28px;
    z-index: var(--chat-z);
    width: var(--chat-width);
    height: var(--chat-height);
    background: var(--chat-bg);
    border-radius: var(--chat-radius);
    box-shadow: var(--chat-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    font-family: var(--chat-font);
    border: 1.5px solid var(--chat-border);

    /* Animasi masuk/keluar */
    transform-origin: bottom right;
    transform: scale(.85) translateY(20px);
    opacity: 0;
    pointer-events: none;
    transition: transform .3s cubic-bezier(.34,1.56,.64,1), opacity .25s ease;
}
#chatbot-window.is-visible {
    transform: scale(1) translateY(0);
    opacity: 1;
    pointer-events: all;
}

/* Motif batik subtle di background */
#chatbot-window::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image: 
        radial-gradient(circle at 20% 20%, rgba(79,70,229,.04) 0%, transparent 50%),
        radial-gradient(circle at 80% 80%, rgba(129,140,248,.06) 0%, transparent 50%);
    pointer-events: none;
    z-index: 0;
}

/* ── HEADER ─────────────────────────────────── */
.chat-header {
    position: relative;
    z-index: 1;
    background: linear-gradient(135deg, var(--chat-primary) 0%, #E8590C 100%);
    padding: 16px 18px 14px;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.chat-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: rgba(255,255,255,.2);
    border: 2px solid rgba(255,255,255,.5);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    flex-shrink: 0;
    animation: avatar-float 3s ease-in-out infinite;
}
@keyframes avatar-float {
    0%,100% { transform: translateY(0); }
    50%      { transform: translateY(-2px); }
}

.chat-header-info { flex: 1; }
.chat-header-name {
    color: white;
    font-weight: 800;
    font-size: 15px;
    letter-spacing: .2px;
    line-height: 1.2;
}
.chat-header-status {
    color: rgba(255,255,255,.85);
    font-size: 11.5px;
    display: flex;
    align-items: center;
    gap: 5px;
    margin-top: 2px;
}
.status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #4ADE80;
    animation: status-blink 2s ease-in-out infinite;
}
@keyframes status-blink {
    0%,100% { opacity: 1; }
    50%      { opacity: .5; }
}

.chat-header-actions {
    display: flex;
    gap: 6px;
}
.chat-btn-action {
    background: rgba(255,255,255,.15);
    border: none;
    border-radius: 8px;
    width: 32px;
    height: 32px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 15px;
    transition: background .15s;
}
.mobile-close-btn {
    display: none !important;
}
.chat-btn-action:hover { background: rgba(255,255,255,.25); }

/* ── MESSAGES AREA ──────────────────────────── */
.chat-messages {
    position: relative;
    z-index: 1;
    flex: 1;
    overflow-y: auto;
    padding: 16px 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    scroll-behavior: smooth;
}
.chat-messages::-webkit-scrollbar { width: 4px; }
.chat-messages::-webkit-scrollbar-track { background: transparent; }
.chat-messages::-webkit-scrollbar-thumb { background: var(--chat-border); border-radius: 4px; }

/* ── MESSAGE BUBBLES ─────────────────────────── */
.msg-row {
    display: flex;
    gap: 8px;
    animation: msg-in .3s cubic-bezier(.34,1.56,.64,1) both;
}
@keyframes msg-in {
    from { opacity: 0; transform: translateY(10px) scale(.96); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.msg-row.user { flex-direction: row-reverse; }

.msg-avatar-sm {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    background: var(--chat-accent);
    border: 1.5px solid var(--chat-border);
    align-self: flex-end;
}

.msg-content { max-width: 78%; display: flex; flex-direction: column; gap: 3px; }
.msg-row.user .msg-content { align-items: flex-end; }

.msg-bubble {
    padding: 10px 14px;
    border-radius: 18px;
    font-size: 13.5px;
    line-height: 1.55;
    word-break: break-word;
    position: relative;
}
/* Bot bubble */
.msg-row.bot .msg-bubble {
    background: var(--chat-surface);
    color: var(--chat-text);
    border-radius: 4px 18px 18px 18px;
    border: 1px solid var(--chat-border);
    box-shadow: 0 1px 4px rgba(0,0,0,.06);
}
/* User bubble */
.msg-row.user .msg-bubble {
    background: linear-gradient(135deg, var(--chat-primary), #E8590C);
    color: white;
    border-radius: 18px 18px 4px 18px;
}

.msg-time {
    font-size: 10.5px;
    color: var(--chat-muted);
    padding: 0 4px;
}

/* ── TYPING INDICATOR ─────────────────────────── */
.typing-indicator {
    display: flex;
    gap: 8px;
    align-items: center;
    animation: msg-in .3s ease both;
}
.typing-dots {
    background: var(--chat-surface);
    border: 1px solid var(--chat-border);
    border-radius: 4px 18px 18px 18px;
    padding: 12px 16px;
    display: flex;
    gap: 5px;
    align-items: center;
}
.typing-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--chat-primary);
    animation: dot-bounce .9s ease-in-out infinite;
}
.typing-dot:nth-child(2) { animation-delay: .15s; }
.typing-dot:nth-child(3) { animation-delay: .3s; }
@keyframes dot-bounce {
    0%,100% { transform: translateY(0); opacity: .6; }
    50%      { transform: translateY(-5px); opacity: 1; }
}

/* ── QUICK SUGGESTIONS ─────────────────────────── */
.chat-suggestions {
    position: relative;
    z-index: 1;
    padding: 6px 14px 4px;
    display: flex;
    gap: 6px;
    overflow-x: auto;
    flex-shrink: 0;
}
.chat-suggestions::-webkit-scrollbar { display: none; }

.suggestion-chip {
    flex-shrink: 0;
    background: var(--chat-accent);
    border: 1.5px solid var(--chat-border);
    border-radius: 20px;
    padding: 5px 12px;
    font-size: 11.5px;
    font-weight: 600;
    color: var(--chat-primary-dk);
    cursor: pointer;
    white-space: nowrap;
    transition: background .15s, transform .1s;
    font-family: var(--chat-font);
}
.suggestion-chip:hover {
    background: #DDD6FE;
    transform: translateY(-1px);
}
.suggestion-chip:active { transform: translateY(0) scale(.97); }

/* ── INPUT AREA ─────────────────────────────── */
.chat-input-area {
    position: relative;
    z-index: 1;
    padding: 10px 12px 14px;
    background: var(--chat-surface);
    border-top: 1.5px solid var(--chat-border);
    flex-shrink: 0;
}

.chat-input-row {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

.chat-input {
    flex: 1;
    background: var(--chat-bg);
    border: 1.5px solid var(--chat-border);
    border-radius: 22px;
    padding: 10px 16px;
    font-family: var(--chat-font);
    font-size: 13.5px;
    color: var(--chat-text);
    resize: none;
    min-height: 44px;
    max-height: 120px;
    outline: none;
    transition: border-color .2s;
    line-height: 1.5;
}
.chat-input:focus {
    border-color: var(--chat-primary);
    background: white;
}
.chat-input::placeholder { color: var(--chat-muted); }

.chat-send-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--chat-primary);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background .15s, transform .1s;
    outline: none;
}
.chat-send-btn:hover  { background: var(--chat-primary-dk); transform: scale(1.05); }
.chat-send-btn:active { transform: scale(.95); }
.chat-send-btn:disabled { background: var(--chat-border); cursor: not-allowed; transform: none; }

.chat-send-btn svg { color: white; }

/* ── WATERMARK ─────────────────────────────── */
.chat-footer {
    position: relative;
    z-index: 1;
    text-align: center;
    font-size: 10px;
    color: var(--chat-muted);
    padding: 4px 0 8px;
    background: var(--chat-surface);
}

/* ── WELCOME MESSAGE ─────────────────────────── */
.welcome-card {
    background: linear-gradient(135deg, var(--chat-accent), #FFF7E6);
    border: 1.5px solid var(--chat-border);
    border-radius: 14px;
    padding: 14px 16px;
    text-align: center;
    margin-bottom: 4px;
}
.welcome-emoji { font-size: 32px; display: block; margin-bottom: 6px; }
.welcome-title {
    font-weight: 800;
    font-size: 14px;
    color: var(--chat-primary-dk);
    margin-bottom: 4px;
}
.welcome-desc {
    font-size: 12.5px;
    color: var(--chat-muted);
    line-height: 1.5;
}

/* ── TOAST NOTIF ─────────────────────────────── */
.chat-toast {
    position: absolute;
    top: 70px;
    left: 50%;
    transform: translateX(-50%) translateY(-8px);
    background: rgba(45,26,10,.88);
    color: white;
    padding: 7px 16px;
    border-radius: 20px;
    font-size: 12.5px;
    font-weight: 600;
    white-space: nowrap;
    opacity: 0;
    transition: opacity .2s, transform .2s;
    z-index: 10;
    pointer-events: none;
}
.chat-toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ── RESPONSIVE ─────────────────────────────── */
@media (max-width: 480px) {
    #chatbot-window {
        bottom: 0;
        right: 0;
        width: 100vw;
        height: 100dvh;
        border-radius: 0;
        border: none;
    }
    .mobile-close-btn {
        display: flex !important;
    }
    #chatbot-launcher {
        bottom: 16px;
        right: 16px;
    }
}

