/* ===========================
   CHATBOT STYLES (Trợ lý AI)
   =========================== */

/* Chatbot Toggle Button */
#chatbot-toggle-btn {
    position: fixed;
    bottom: 25px;
    right: 25px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    /* Nền tròn xanh teal nhạt mờ + hiệu ứng tráng gương (Glassmorphism) */
    background: rgba(0, 121, 107, 0.25);
    -webkit-backdrop-filter: blur(10px) saturate(180%);
    backdrop-filter: blur(10px) saturate(180%);
    border: 1.5px solid rgba(255, 255, 255, 0.65);
    cursor: pointer;
    z-index: 9998;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 3px;
    overflow: hidden;
    /* Nhấp nháy sáng nhẹ (pulse animation) */
    animation: chatbotTealPulse 2.8s infinite ease-in-out;
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.3s ease;
}

#chatbot-toggle-btn:hover {
    transform: scale(1.08);
    background: rgba(0, 121, 107, 0.35);
    border-color: rgba(255, 255, 255, 0.85);
}

#chatbot-toggle-btn:active {
    transform: scale(0.95);
}

/* Avatar hình ảnh inside toggle button */
.chatbot-btn-avatar {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: top center;
    border-radius: 50%;
    display: block;
}

/* Hiệu ứng nhấp nháy sáng nhẹ (Light Teal Glow Pulse) */
@keyframes chatbotTealPulse {
    0% {
        box-shadow: 0 4px 15px rgba(0, 121, 107, 0.3), 0 0 0 0 rgba(77, 182, 172, 0.45), inset 0 0 10px rgba(255, 255, 255, 0.4);
    }
    50% {
        box-shadow: 0 6px 22px rgba(0, 121, 107, 0.5), 0 0 0 10px rgba(77, 182, 172, 0), inset 0 0 15px rgba(255, 255, 255, 0.7);
    }
    100% {
        box-shadow: 0 4px 15px rgba(0, 121, 107, 0.3), 0 0 0 0 rgba(77, 182, 172, 0), inset 0 0 10px rgba(255, 255, 255, 0.4);
    }
}

/* Chatbot Window */
.chatbot-window {
    position: fixed;
    bottom: 95px;
    right: 25px;
    width: 370px;
    max-width: calc(100vw - 40px);
    height: 520px;
    max-height: calc(100vh - 110px); /* Đảm bảo không quá to che thanh header */
    background: white;
    border-radius: 20px;
    box-shadow: 0 10px 32px rgba(0, 0, 0, 0.18);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 9995; /* Header có z-index: 9999 nên header luôn nằm trên */
    transition: opacity 0.3s ease, transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.chatbot-window.hidden {
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    pointer-events: none;
}

/* Chatbot Header */
.chatbot-header {
    background: linear-gradient(135deg, #00796b 0%, #004d40 100%);
    color: white;
    padding: 14px 18px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.chatbot-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    font-size: 15px;
}

.chatbot-header-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
    object-position: top center;
    border: 1px solid rgba(255, 255, 255, 0.6);
}

.chatbot-close-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease;
}

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

/* Chatbot Messages Area */
.chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: #f8f9fa;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.chatbot-messages::-webkit-scrollbar {
    width: 5px;
}

.chatbot-messages::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.chatbot-messages::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.chatbot-messages::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* Chat Message */
.chatbot-message {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    animation: messageSlideIn 0.3s ease;
}

@keyframes messageSlideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    overflow: hidden;
}

.chatbot-avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: top center;
    border-radius: 50%;
}

.bot-message .message-avatar {
    background: #00796b;
}

.user-message .message-avatar {
    background: linear-gradient(135deg, #00796b 0%, #004d40 100%);
    color: white;
    font-size: 14px;
}

.message-content {
    max-width: 78%;
    padding: 11px 15px;
    border-radius: 16px;
    line-height: 1.5;
    font-size: 14px;
}

.bot-message .message-content {
    background: white;
    color: #333;
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.06);
}

.user-message {
    flex-direction: row-reverse;
}

.user-message .message-content {
    background: linear-gradient(135deg, #00796b 0%, #004d40 100%);
    color: white;
    border-bottom-right-radius: 4px;
}

.message-content p {
    margin: 0 0 6px 0;
}

.message-content p:last-child {
    margin-bottom: 0;
}

.message-content ul {
    margin: 6px 0;
    padding-left: 18px;
}

.message-content li {
    margin: 3px 0;
}

/* Typing Indicator */
.typing-indicator .message-content {
    padding: 12px 16px;
}

.typing-dots {
    display: flex;
    gap: 5px;
    align-items: center;
}

.typing-dots span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #00796b;
    animation: typingDot 1.4s infinite;
}

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

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

@keyframes typingDot {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.7;
    }
    30% {
        transform: translateY(-8px);
        opacity: 1;
    }
}

/* Disclaimer */
.chatbot-disclaimer {
    background: #fff8e1;
    border-top: 1px solid #ffe082;
    border-bottom: 1px solid #ffe082;
    padding: 8px 14px;
    font-size: 11.5px;
    color: #856404;
    display: flex;
    align-items: center;
    gap: 8px;
}

.chatbot-disclaimer i {
    font-size: 13px;
    color: #f57f17;
    flex-shrink: 0;
}

/* Input Area */
.chatbot-input-area {
    padding: 12px 14px;
    background: white;
    border-top: 1px solid #e0e0e0;
    display: flex;
    gap: 10px;
    align-items: center;
}

.chatbot-input {
    flex: 1;
    padding: 10px 16px;
    border: 1.5px solid #d0d0d0;
    border-radius: 22px;
    outline: none;
    font-size: 16px; /* 16px để chống iOS tự động phóng to (zoom) khi focus */
    font-family: 'Quicksand', sans-serif;
    transition: border-color 0.2s ease;
}

.chatbot-input:focus {
    border-color: #00796b;
}

.chatbot-send-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #00796b 0%, #004d40 100%);
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.chatbot-send-btn:hover {
    transform: scale(1.06);
    box-shadow: 0 3px 8px rgba(0, 121, 107, 0.4);
}

.chatbot-send-btn:active {
    transform: scale(0.94);
}

/* Responsive Design cho Điện thoại (Matches Hình 2 & Hình 3) */
@media (max-width: 768px) {
    #chatbot-toggle-btn {
        right: 15px;
        bottom: 18px;
        width: 54px;
        height: 54px;
    }

    .chatbot-window {
        right: 15px;
        bottom: 80px;
        width: calc(100vw - 30px);
        max-width: 360px;
        height: 480px;
        max-height: calc(100vh - 140px); /* Khung chat vừa vặn, không che thanh header */
        border-radius: 16px;
    }

    .message-content {
        max-width: 82%;
        font-size: 13.5px;
    }

    .chatbot-header {
        padding: 12px 14px;
    }

    .chatbot-messages {
        padding: 12px;
    }

    .chatbot-input {
        font-size: 16px; /* Đảm bảo 16px trên điện thoại ngăn iOS tự phóng to trang */
    }
}
