/* chatbot/static/chatbot/css/chat.css */
/* Phase C5.4: Floating bubble chat widget layout */

.chatbot-widget {
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 9999;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.chatbot-toggle {
    width: 56px;
    height: 56px;
    border-radius: 9999px;
    border: none;
    cursor: pointer;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.25);
    font-size: 24px;
    background: linear-gradient(135deg, #4338ca, #2563eb);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.chatbot-toggle:hover {
    transform: scale(1.08);
    box-shadow: 0 14px 30px rgba(37, 99, 235, 0.35);
}

.chatbot-panel {
    position: fixed;
    right: 24px;
    bottom: 92px;
    width: min(380px, calc(100vw - 32px));
    height: min(560px, calc(100vh - 120px));
    background: #ffffff;
    border-radius: 18px;
    box-shadow: 0 18px 45px rgba(15, 23, 42, 0.28);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid rgba(148, 163, 184, 0.35);
}

.chatbot-hidden {
    display: none !important;
}

.chatbot-header {
    flex: 0 0 auto;
    padding: 14px 16px;
    background: linear-gradient(135deg, #4338ca, #2563eb);
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chatbot-header strong {
    display: block;
    font-size: 15px;
}

.chatbot-header-sub {
    display: block;
    font-size: 12px;
    opacity: 0.85;
    margin-top: 1px;
}

.chatbot-close {
    background: rgba(255, 255, 255, 0.18);
    border: none;
    color: white;
    cursor: pointer;
    font-size: 20px;
    width: 32px;
    height: 32px;
    border-radius: 9999px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
    line-height: 1;
}

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

.chatbot-messages {
    flex: 1 1 auto;
    padding: 14px;
    overflow-y: auto;
    background: #f8fafc;
}

/* ── Individual message layout ── */

.chat-message {
    display: flex;
    margin-bottom: 10px;
}

.bot-message,
.assistant-message {
    justify-content: flex-start;
}

.user-message {
    justify-content: flex-end;
}

.staff-message,
.admin-message,
.agent-message {
    justify-content: flex-start;
}

.system-message {
    justify-content: center;
}

/* ── Chat bubble ── */

.chat-bubble {
    max-width: 78%;
    padding: 10px 12px;
    border-radius: 16px;
    line-height: 1.45;
    font-size: 14px;
    white-space: pre-wrap;
    word-break: break-word;
}

.bot-message .chat-bubble,
.assistant-message .chat-bubble {
    background: #ffffff;
    color: #0f172a;
    border: 1px solid #e2e8f0;
    border-bottom-left-radius: 6px;
}

.user-message .chat-bubble {
    background: #2563eb;
    color: #ffffff;
    border-bottom-right-radius: 6px;
}

.staff-message .chat-bubble,
.admin-message .chat-bubble,
.agent-message .chat-bubble {
    background: #ecfdf5;
    color: #064e3b;
    border: 1px solid #a7f3d0;
    border-bottom-left-radius: 6px;
}

/* Staff/admin label prefix */
.staff-message .chat-bubble::before,
.admin-message .chat-bubble::before,
.agent-message .chat-bubble::before {
    display: block;
    font-size: 11px;
    font-weight: 600;
    margin-bottom: 4px;
}

.staff-message .chat-bubble::before {
    content: "🧑‍💼 Nhân viên CSKH";
    color: #065f46;
}

.admin-message .chat-bubble::before {
    content: "🛡️ Admin";
    color: #065f46;
}

.agent-message .chat-bubble::before {
    content: "🤖 Agent";
    color: #065f46;
}

.system-message .chat-bubble {
    background: #fef3c7;
    color: #92400e;
    font-size: 13px;
    text-align: center;
    max-width: 95%;
}

/* ── Input form ── */

.chatbot-form {
    flex: 0 0 auto;
    padding: 12px;
    display: flex;
    gap: 8px;
    border-top: 1px solid #e2e8f0;
    background: #ffffff;
}

.chatbot-input {
    flex: 1;
    min-width: 0;
    border: 1px solid #cbd5e1;
    border-radius: 9999px;
    padding: 10px 12px;
    outline: none;
    font-size: 14px;
}

.chatbot-input:focus {
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.chatbot-send {
    border: none;
    border-radius: 9999px;
    padding: 0 18px;
    background: #2563eb;
    color: white;
    font-weight: 600;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.15s;
}

.chatbot-send:hover {
    background: #1d4ed8;
}

/* ── Typing indicator ── */

.typing-indicator {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 8px 12px;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background: #94a3b8;
    border-radius: 50%;
    animation: typing 1s infinite;
}

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

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

@keyframes typing {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 1; }
}

/* ── Responsive ── */

@media (max-width: 480px) {
    .chatbot-widget {
        right: 16px;
        bottom: 16px;
    }

    .chatbot-panel {
        right: 12px;
        left: 12px;
        bottom: 82px;
        width: auto;
        height: min(560px, calc(100vh - 100px));
    }
}
