/* Google Fonts - Inter */
@import url('https://fonts.googleapis.com/css2?family=Inter:opsz,wght@14..32,100..900&display=swap');

/* Chatbot Styles */
#chatbot-toggler {
    position: fixed;
    bottom: 24px; /* Đặt thấp hơn contact button (24px = 1.5rem) */
    right: 24px; /* Căn chỉnh với contact button (24px = 1.5rem) */
    border: none;
    height: 56px; /* Đồng kích thước với contact button (w-14 h-14) */
    width: 56px;
    display: flex;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: #62000d; /* Mon Amour wine-red color */
    box-shadow: 0 0 20px rgba(98, 0, 13, 0.3);
    transition: all 0.2s ease;
    z-index: 9999;
}

#chatbot-toggler:hover {
    background: #4a0009;
    transform: scale(1.05);
}

body.show-chatbot #chatbot-toggler {
    transform: rotate(90deg);
}

#chatbot-toggler span {
    color: #fbf1e6; /* Mon Amour beige color */
    position: absolute;
    font-size: 28px; /* Tăng kích thước icon */
    font-weight: 400;
    display: flex;
    align-items: center;
    justify-content: center;
}

#chatbot-toggler span:last-child,
body.show-chatbot #chatbot-toggler span:first-child {
    opacity: 0;
}

body.show-chatbot #chatbot-toggler span:last-child {
    opacity: 1;
}

.chatbot-popup {
    position: fixed;
    right: 24px; /* Căn chỉnh với chatbot button */
    bottom: 84px; /* Điều chỉnh để phù hợp với vị trí mới của nút chatbot (24px + 56px + 4px) */
    width: 380px; /* Giảm từ 420px xuống 380px */
    overflow: hidden;
    background: #fff;
    border-radius: 15px;
    opacity: 0;
    pointer-events: none;
    transform: scale(0.2);
    transform-origin: bottom right;
    box-shadow: 0 0 128px 0 rgba(98, 0, 13, 0.2),
        0 32px 64px -48px rgba(98, 0, 13, 0.4);
    transition: all 0.1s ease;
    z-index: 9998;
}

body.show-chatbot .chatbot-popup {
    opacity: 1;
    pointer-events: auto;
    transform: scale(1);
}

.chat-header {
    display: flex;
    align-items: center;
    padding: 15px 22px;
    background: #62000d; /* Mon Amour wine-red */
    justify-content: space-between;
}

.chat-header .header-info {
    display: flex;
    gap: 10px;
    align-items: center;
}

.header-info .chatbot-logo {
    width: 35px;
    height: 35px;
    padding: 6px;
    fill: #62000d;
    flex-shrink: 0;
    background: #fbf1e6; /* Mon Amour beige */
    border-radius: 50%;
}

.header-info .logo-text {
    color: #fbf1e6; /* Mon Amour beige */
    font-weight: 600;
    font-size: 1.1rem; /* Giảm từ 1.31rem xuống 1.1rem */
    letter-spacing: 0.02rem;
    font-family: 'Prata', serif;
}

.chat-header #close-chatbot {
    border: none;
    color: #fbf1e6;
    height: 40px;
    width: 40px;
    font-size: 1.9rem;
    margin-right: -10px;
    padding-top: 2px;
    cursor: pointer;
    border-radius: 50%;
    background: none;
    transition: 0.2s ease;
}

.chat-header #close-chatbot:hover {
    background: rgba(251, 241, 230, 0.2);
}

.chat-body {
    padding: 20px 18px; /* Giảm padding từ 25px 22px xuống 20px 18px */
    gap: 16px; /* Giảm gap từ 20px xuống 16px */
    display: flex;
    height: 420px; /* Giảm từ 460px xuống 420px */
    overflow-y: auto;
    margin-bottom: 78px; /* Giảm từ 82px xuống 78px */
    flex-direction: column;
    scrollbar-width: thin;
    scrollbar-color: #62000d transparent;
}

.chat-body,
.chat-form .message-input:hover {
    scrollbar-color: #62000d transparent;
}

.chat-body .message {
    display: flex;
    gap: 11px;
    align-items: center;
}

.chat-body .message .bot-avatar {
    width: 35px;
    height: 35px;
    padding: 6px;
    fill: #fbf1e6;
    flex-shrink: 0;
    margin-bottom: 2px;
    align-self: flex-end;
    border-radius: 50%;
    background: #62000d;
}

.chat-body .message .message-text {
    padding: 10px 14px; /* Giảm padding từ 12px 16px xuống 10px 14px */
    max-width: 75%;
    font-size: 0.875rem; /* Giảm từ 0.95rem xuống 0.875rem */
    font-family: 'Noto Serif', serif;
    line-height: 1.4; /* Thêm line-height để dễ đọc */
}

.chat-body .bot-message.thinking .message-text {
    padding: 2px 16px;
}

.chat-body .bot-message .message-text {
    background: #fbf1e6; /* Mon Amour beige */
    border: 1px solid rgba(98, 0, 13, 0.1);
    border-radius: 13px 13px 13px 3px;
    color: #62000d;
}

.chat-body .user-message {
    flex-direction: column;
    align-items: flex-end;
}

.chat-body .user-message .message-text {
    color: #fbf1e6;
    background: #62000d;
    border-radius: 13px 13px 3px 13px;
}

.chat-body .user-message .attachment {
    width: 50%;
    margin-top: -7px;
    border-radius: 13px 3px 13px 13px;
}

.chat-body .bot-message .thinking-indicator {
    display: flex;
    gap: 4px;
    padding-block: 15px;
}

.chat-body .bot-message .thinking-indicator .dot {
    height: 7px;
    width: 7px;
    opacity: 0.7;
    border-radius: 50%;
    background: #62000d;
    animation: dotPulse 1.8s ease-in-out infinite;
}

.chat-body .bot-message .thinking-indicator .dot:nth-child(1) {
    animation-delay: 0.2s;
}

.chat-body .bot-message .thinking-indicator .dot:nth-child(2) {
    animation-delay: 0.3s;
}

.chat-body .bot-message .thinking-indicator .dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes dotPulse {
    0%, 44% { transform: translateY(0); }
    28% { opacity: 0.4; transform: translateY(-4px); }
    44% { opacity: 0.2; }
}

.chat-footer {
    position: absolute;
    bottom: 0;
    width: 100%;
    background: #fff;
    padding: 15px 22px 20px;
}

.chat-footer .chat-form {
    display: flex;
    align-items: center;
    position: relative;
    background: #fff;
    border-radius: 32px;
    outline: 1px solid rgba(98, 0, 13, 0.2);
    box-shadow: 0 0 8px rgba(98, 0, 13, 0.1);
    transition: 0s ease, border-radius 0s;
}

.chat-form:focus-within {
    outline: 2px solid #62000d;
}

.chat-form .message-input {
    width: 100%;
    height: 44px; /* Giảm từ 47px xuống 44px */
    outline: none;
    resize: none;
    border: none;
    max-height: 160px; /* Giảm từ 180px xuống 160px */
    scrollbar-width: thin;
    border-radius: inherit;
    font-size: 0.875rem; /* Giảm từ 0.95rem xuống 0.875rem */
    padding: 12px 0 10px 16px; /* Giảm padding từ 14px 0 12px 18px */
    scrollbar-color: transparent transparent;
    font-family: 'Noto Serif', serif;
}

.chat-form .message-input::placeholder {
    color: #999;
}

.chat-form .chat-controls {
    gap: 3px;
    height: 44px; /* Giảm từ 47px xuống 44px để phù hợp với input */
    display: flex;
    padding-right: 6px;
    align-items: center;
    align-self: flex-end;
}

.chat-form .chat-controls button {
    height: 35px;
    width: 35px;
    border: none;
    cursor: pointer;
    color: #62000d;
    border-radius: 50%;
    font-size: 1.15rem;
    background: none;
    transition: 0.2s ease;
}

.chat-form .chat-controls button:hover,
body.show-emoji-picker .chat-controls #emoji-picker {
    color: #4a0009;
    background: rgba(251, 241, 230, 0.5);
}

.chat-form .chat-controls #send-message {
    color: #fbf1e6;
    display: none;
    background: #62000d;
}

.chat-form .chat-controls #send-message:hover {
    background: #4a0009;
}

.chat-form .message-input:valid~.chat-controls #send-message {
    display: block;
}

.chat-form .file-upload-wrapper {
    position: relative;
    height: 35px;
    width: 35px;
}

.chat-form .file-upload-wrapper :where(button, img) {
    position: absolute;
}

.chat-form .file-upload-wrapper img {
    height: 100%;
    width: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.chat-form .file-upload-wrapper #file-cancel {
    color: #ff0000;
    background: #fff;
}

.chat-form .file-upload-wrapper :where(img, #file-cancel),
.chat-form .file-upload-wrapper.file-uploaded #file-upload {
    display: none;
}

.chat-form .file-upload-wrapper.file-uploaded img,
.chat-form .file-upload-wrapper.file-uploaded:hover #file-cancel {
    display: block;
}

em-emoji-picker {
    position: absolute;
    left: 50%;
    top: -337px;
    width: 100%;
    max-width: 350px;
    visibility: hidden;
    max-height: 330px;
    transform: translateX(-50%);
}

body.show-emoji-picker em-emoji-picker {
    visibility: visible;
}

/* Responsive media query for mobile screens */
@media (max-width: 640px) {
    #chatbot-toggler {
        right: 16px; /* Căn chỉnh với contact button trên mobile (1rem = 16px) */
        bottom: 16px; /* Đặt thấp hơn contact button trên mobile */
        height: 48px; /* Kích thước phù hợp cho mobile */
        width: 48px;
    }
    
    #chatbot-toggler span {
        font-size: 22px; /* Icon phù hợp cho mobile */
    }
    
    .chatbot-popup {
        right: 8px; /* Căn lề phải */
        bottom: 70px; /* Đặt trên nút chatbot */
        height: 500px; /* Chiều cao cố định thay vì full screen */
        border-radius: 15px; /* Giữ border radius */
        width: calc(100vw - 16px); /* Chiều rộng gần full nhưng có margin */
        max-width: 350px; /* Giới hạn chiều rộng tối đa */
        display: flex;
        flex-direction: column;
        box-shadow: 0 0 128px 0 rgba(98, 0, 13, 0.3),
            0 32px 64px -48px rgba(98, 0, 13, 0.5); /* Tăng shadow để nổi bật */
    }
    
    .chatbot-popup .chat-header {
        padding: 12px 15px;
        flex-shrink: 0; /* Không cho header co lại */
        border-radius: 15px 15px 0 0; /* Bo góc trên */
    }
    
    .chat-body {
        flex: 1; /* Chiếm toàn bộ không gian còn lại */
        padding: 15px 12px; /* Giảm padding để tiết kiệm không gian */
        margin-bottom: 0; /* Bỏ margin-bottom */
        overflow-y: auto;
        max-height: 350px; /* Giới hạn chiều cao tối đa */
    }
    
    .chat-footer {
        padding: 12px 12px 15px; /* Giảm padding để tiết kiệm không gian */
        flex-shrink: 0; /* Không cho footer co lại */
        background: #fff;
        border-top: 1px solid rgba(98, 0, 13, 0.1); /* Thêm border để phân biệt */
        border-radius: 0 0 15px 15px; /* Bo góc dưới */
    }
    
    .chat-form {
        position: relative;
        z-index: 10;
    }
    
    .chat-form .chat-controls {
        height: 40px; /* Giảm chiều cao controls trên mobile */
        position: relative;
        z-index: 15;
    }
    
    .chat-form .chat-controls button {
        height: 32px; /* Giảm kích thước button trên mobile */
        width: 32px;
        font-size: 1rem; /* Giảm kích thước icon */
        position: relative;
        z-index: 20;
    }
    
    .chat-form .chat-controls #send-message {
        background: #62000d !important;
        color: #fbf1e6 !important;
        z-index: 25; /* Z-index cao nhất cho nút gửi */
    }
    
    .chat-form .message-input {
        height: 40px; /* Giảm chiều cao input trên mobile */
        font-size: 0.8rem; /* Font nhỏ hơn trên mobile */
        padding: 10px 0 8px 14px;
    }
    
    .chat-header #close-chatbot {
        z-index: 5; /* Z-index thấp hơn nút gửi */
        position: relative;
    }
    
    .chat-form .file-upload-wrapper.file-uploaded #file-cancel {
        opacity: 0;
    }
}
