/* ═══════════════════════════════════════════════════════
   SUNILIES CHATBOX — Floating chat widget
   Path: src/main/resources/static/css/chatbox.css
   Palette: #3d2e1c (nâu đậm) / #c8986a (vàng đồng) / #faf2e6 (kem)
   ═══════════════════════════════════════════════════════ */

:root {
    --sun-chat-primary:   #3d2e1c;
    --sun-chat-accent:    #c8986a;
    --sun-chat-cream:     #faf2e6;
    --sun-chat-bg:        #fffdf9;
    --sun-chat-text:      #3d2e1c;
    --sun-chat-muted:     #7a6a57;
    --sun-chat-border:    #ede4d3;
    --sun-chat-user-bg:   #3d2e1c;
    --sun-chat-bot-bg:    #faf2e6;
    --sun-chat-shadow:    0 12px 32px rgba(61, 46, 28, 0.18);
}

/* ──── Bubble toggle ──────────────────────────────────── */
.sun-chat-toggle {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, #3d2e1c 0%, #5c4530 100%);
    color: var(--sun-chat-cream);
    cursor: pointer;
    box-shadow: 0 8px 24px rgba(61, 46, 28, 0.35);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9998;
    transition: transform .25s ease, box-shadow .25s ease;
}
.sun-chat-toggle:hover {
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 12px 32px rgba(61, 46, 28, 0.45);
}
.sun-chat-toggle__icon-close { display: none; }
.sun-chat-toggle.is-open .sun-chat-toggle__icon-open  { display: none; }
.sun-chat-toggle.is-open .sun-chat-toggle__icon-close { display: block; }

/* Pulse animation khi chưa mở */
.sun-chat-toggle__pulse {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 2px solid var(--sun-chat-accent);
    opacity: 0;
    animation: sunChatPulse 2s ease-out infinite;
}
.sun-chat-toggle.is-open .sun-chat-toggle__pulse { display: none; }
@keyframes sunChatPulse {
    0%   { transform: scale(1);   opacity: 0.7; }
    100% { transform: scale(1.6); opacity: 0;   }
}

/* Badge số tin nhắn mới */
.sun-chat-toggle__badge {
    position: absolute;
    top: -2px;
    right: -2px;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 10px;
    background: #e74c3c;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    display: none;
    align-items: center;
    justify-content: center;
    border: 2px solid #fff;
}
.sun-chat-toggle__badge.is-show { display: inline-flex; }

/* ──── Panel ──────────────────────────────────────────── */
.sun-chat-panel {
    position: fixed;
    bottom: 96px;
    right: 24px;
    width: 380px;
    max-width: calc(100vw - 32px);
    height: 580px;
    max-height: calc(100vh - 120px);
    background: var(--sun-chat-bg);
    border-radius: 20px;
    box-shadow: var(--sun-chat-shadow);
    display: none;
    flex-direction: column;
    overflow: hidden;
    z-index: 9999;
    border: 1px solid var(--sun-chat-border);
    transform: translateY(20px) scale(0.95);
    opacity: 0;
    transition: transform .3s cubic-bezier(.4, 0, .2, 1), opacity .3s ease;
}
.sun-chat-panel.is-open {
    display: flex;
    transform: translateY(0) scale(1);
    opacity: 1;
}

/* Header */
.sun-chat-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 18px;
    background: linear-gradient(135deg, #3d2e1c 0%, #4a3826 100%);
    color: var(--sun-chat-cream);
}
.sun-chat-header__avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--sun-chat-accent);
    color: var(--sun-chat-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 18px;
    letter-spacing: 1px;
}
.sun-chat-header__info { flex: 1; min-width: 0; }
.sun-chat-header__name {
    font-size: 15px;
    font-weight: 600;
    letter-spacing: .5px;
}
.sun-chat-header__status {
    font-size: 11px;
    color: var(--sun-chat-accent);
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 2px;
}
.sun-chat-header__dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #4ade80;
    box-shadow: 0 0 6px #4ade80;
}
.sun-chat-header__close {
    background: rgba(255, 255, 255, .1);
    border: none;
    color: var(--sun-chat-cream);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background .2s ease;
}
.sun-chat-header__close:hover { background: rgba(255, 255, 255, .2); }

/* Body — khu vực tin nhắn */
.sun-chat-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px 18px;
    background: #fffdf9;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scroll-behavior: smooth;
}
.sun-chat-body::-webkit-scrollbar { width: 6px; }
.sun-chat-body::-webkit-scrollbar-thumb {
    background: var(--sun-chat-border);
    border-radius: 3px;
}

/* Bubble tin nhắn */
.sun-chat-msg {
    max-width: 80%;
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.55;
    word-wrap: break-word;
    white-space: pre-wrap;
    animation: sunMsgIn .3s ease;
}
@keyframes sunMsgIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0);   }
}
.sun-chat-msg--bot {
    background: var(--sun-chat-bot-bg);
    color: var(--sun-chat-text);
    border-bottom-left-radius: 4px;
    align-self: flex-start;
    border: 1px solid var(--sun-chat-border);
}
.sun-chat-msg--user {
    background: var(--sun-chat-user-bg);
    color: var(--sun-chat-cream);
    border-bottom-right-radius: 4px;
    align-self: flex-end;
}
.sun-chat-msg a {
    color: var(--sun-chat-accent);
    text-decoration: underline;
}
.sun-chat-msg--user a { color: #ffd9a3; }

/* Time stamp */
.sun-chat-msg__time {
    font-size: 10px;
    color: var(--sun-chat-muted);
    margin-top: 4px;
    padding: 0 6px;
}
.sun-chat-msg--user + .sun-chat-msg__time {
    align-self: flex-end;
}
.sun-chat-msg--bot + .sun-chat-msg__time {
    align-self: flex-start;
}

/* Typing indicator */
.sun-chat-typing {
    align-self: flex-start;
    background: var(--sun-chat-bot-bg);
    border: 1px solid var(--sun-chat-border);
    border-radius: 16px;
    border-bottom-left-radius: 4px;
    padding: 12px 16px;
    display: inline-flex;
    gap: 4px;
}
.sun-chat-typing span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--sun-chat-accent);
    animation: sunTyping 1.4s infinite ease-in-out;
}
.sun-chat-typing span:nth-child(2) { animation-delay: .2s; }
.sun-chat-typing span:nth-child(3) { animation-delay: .4s; }
@keyframes sunTyping {
    0%, 60%, 100% { transform: translateY(0);    opacity: .5; }
    30%           { transform: translateY(-6px); opacity: 1;  }
}

/* Source badge (FAQ / AI) — nhỏ, mờ */
.sun-chat-msg__source {
    display: inline-block;
    font-size: 9px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--sun-chat-accent);
    margin-top: 4px;
    opacity: 0.7;
}

/* Gợi ý câu hỏi nhanh */
.sun-chat-suggestions {
    padding: 0 18px 8px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    background: #fffdf9;
}
.sun-chat-suggestion {
    padding: 7px 14px;
    border-radius: 16px;
    background: #fff;
    border: 1px solid var(--sun-chat-accent);
    color: var(--sun-chat-primary);
    font-size: 12px;
    cursor: pointer;
    transition: all .2s ease;
}
.sun-chat-suggestion:hover {
    background: var(--sun-chat-accent);
    color: #fff;
}

/* Input */
.sun-chat-input-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 14px;
    border-top: 1px solid var(--sun-chat-border);
    background: #fff;
}
.sun-chat-input {
    flex: 1;
    border: 1px solid var(--sun-chat-border);
    border-radius: 22px;
    padding: 10px 16px;
    font-size: 14px;
    color: var(--sun-chat-text);
    outline: none;
    background: #fffdf9;
    font-family: inherit;
    transition: border-color .2s ease;
}
.sun-chat-input:focus {
    border-color: var(--sun-chat-accent);
}
.sun-chat-input::placeholder {
    color: #b8a888;
}
.sun-chat-send {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, #3d2e1c 0%, #5c4530 100%);
    color: var(--sun-chat-cream);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: transform .15s ease, opacity .2s ease;
}
.sun-chat-send:hover { transform: scale(1.08); }
.sun-chat-send:disabled {
    opacity: .5;
    cursor: not-allowed;
    transform: none;
}

/* Footer */
.sun-chat-footer {
    padding: 8px 18px 12px;
    text-align: center;
    font-size: 10px;
    color: #b8a888;
    background: #fff;
    letter-spacing: .5px;
}

/* ──── Responsive — mobile ───────────────────────────── */
@media (max-width: 480px) {
    .sun-chat-panel {
        right: 8px;
        left: 8px;
        bottom: 84px;
        width: auto;
        max-width: none;
        height: calc(100vh - 100px);
        max-height: none;
    }
    .sun-chat-toggle {
        bottom: 16px;
        right: 16px;
        width: 54px;
        height: 54px;
    }
}
