/* Cấu trúc Layout của Chatbot Widget */
#doshi-chatbot-wrapper {
    position: fixed;
    bottom: 25px;
    right: 25px;
    z-index: 999999;
    font-family: 'Roboto', sans-serif;
    font-size: 14px;
    line-height: 1.5;
    box-sizing: border-box;
}

#doshi-chatbot-wrapper * {
    box-sizing: border-box;
}

/* Nút bong bóng chat nổi */
#doshi-chat-toggle-btn {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background-color: var(--doshi-primary-color, #f44336);
    color: #ffffff;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(244, 67, 54, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    position: relative;
}

#doshi-chat-toggle-btn:hover {
    transform: scale(1.08) rotate(5deg);
    box-shadow: 0 6px 20px rgba(244, 67, 54, 0.5);
}

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

/* Badge tin nhắn chưa đọc */
.doshi-chat-badge {
    position: absolute;
    top: -3px;
    right: -3px;
    background-color: #ffeb3b;
    color: #282828;
    font-size: 11px;
    font-weight: 700;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    animation: pulseBadge 2s infinite;
}

@keyframes pulseBadge {
    0% { transform: scale(1); }
    50% { transform: scale(1.15); }
    100% { transform: scale(1); }
}

/* Cửa sổ chat chính */
#doshi-chat-window {
    position: absolute;
    bottom: 75px;
    right: 0;
    width: 380px;
    height: 520px;
    max-height: calc(85vh - 100px);
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 16px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: all 0.35s cubic-bezier(0.19, 1, 0.22, 1);
    transform-origin: bottom right;
}

/* Trạng thái ẩn */
.doshi-chat-window-hidden {
    opacity: 0;
    transform: translateY(30px) scale(0.85);
    pointer-events: none;
}

/* Header cửa sổ chat */
.doshi-chat-header {
    background-color: var(--doshi-primary-color, #f44336);
    color: #ffffff;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 2px 10px rgba(0,0,0,0.08);
}

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

.doshi-chat-avatar-wrapper {
    position: relative;
    width: 36px;
    height: 36px;
}

.doshi-chat-avatar {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    background: #ffffff;
    padding: 2px;
}

.doshi-chat-status-dot {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 10px;
    height: 10px;
    background-color: #4caf50;
    border: 2px solid var(--doshi-primary-color, #f44336);
    border-radius: 50%;
}

.doshi-chat-title-group {
    display: flex;
    flex-direction: column;
}

.doshi-chat-title {
    font-weight: 700;
    font-size: 14.5px;
    letter-spacing: 0.2px;
}

.doshi-chat-subtitle {
    font-size: 11px;
    opacity: 0.85;
}

.doshi-chat-close {
    background: transparent;
    border: none;
    color: #ffffff;
    cursor: pointer;
    padding: 4px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    opacity: 0.8;
}

.doshi-chat-close:hover {
    background: rgba(255, 255, 255, 0.15);
    opacity: 1;
}

/* Thân cửa sổ chat chứa nội dung tin nhắn */
.doshi-chat-body {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 15px;
    background-color: #f8f9fa;
}

.doshi-chat-messages {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

/* Style tin nhắn bong bóng */
.doshi-msg-row {
    display: flex;
    width: 100%;
    animation: msgFadeIn 0.3s ease forwards;
}

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

.doshi-msg-bot {
    justify-content: flex-start;
}

.doshi-msg-user {
    justify-content: flex-end;
}

.doshi-msg-bubble {
    max-width: 80%;
    padding: 12px 16px;
    border-radius: 14px;
    font-size: 13.5px;
    line-height: 1.45;
    word-wrap: break-word;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.doshi-msg-bot .doshi-msg-bubble {
    background-color: #ffffff;
    color: #282828;
    border-top-left-radius: 2px;
    border: 1px solid rgba(0,0,0,0.04);
}

.doshi-msg-user .doshi-msg-bubble {
    background-color: var(--doshi-primary-color, #f44336);
    color: #ffffff;
    border-top-right-radius: 2px;
}

/* Typing Indicator (Đang gõ) */
.doshi-chat-typing-hidden {
    display: none !important;
}

.typing-bubble {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 12px 20px;
    min-height: 43px;
}

.typing-dot {
    width: 6px;
    height: 6px;
    background-color: #9e9e9e;
    border-radius: 50%;
    animation: typingBounce 1.4s infinite ease-in-out both;
}

.typing-dot:nth-child(1) { animation-delay: -0.32s; }
.typing-dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes typingBounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

/* Khu vực gợi ý trả lời nhanh (Quick Replies) */
.doshi-chat-quick-replies {
    padding: 8px 15px 12px 15px;
    background-color: #f8f9fa;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    border-top: 1px solid rgba(0,0,0,0.03);
}

.doshi-quick-reply-btn {
    background-color: #ffffff;
    border: 1px solid rgba(244, 67, 54, 0.25);
    color: var(--doshi-primary-color, #f44336);
    padding: 6px 12px;
    border-radius: 18px;
    font-size: 11.5px;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 500;
}

.doshi-quick-reply-btn:hover {
    background-color: var(--doshi-primary-color, #f44336);
    color: #ffffff;
    border-color: var(--doshi-primary-color, #f44336);
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(244, 67, 54, 0.15);
}

.doshi-quick-reply-btn:active {
    transform: translateY(0);
}

/* Footer chứa ô nhập dữ liệu */
.doshi-chat-footer {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    background-color: #ffffff;
    border-top: 1px solid rgba(0,0,0,0.06);
    gap: 10px;
}

#doshi-chat-input {
    flex: 1;
    border: 1px solid rgba(0,0,0,0.12);
    border-radius: 20px;
    padding: 10px 16px;
    outline: none;
    font-size: 13.5px;
    transition: border-color 0.2s;
}

#doshi-chat-input:focus {
    border-color: var(--doshi-primary-color, #f44336);
}

#doshi-chat-send-btn {
    background-color: var(--doshi-primary-color, #f44336);
    color: #ffffff;
    border: none;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

#doshi-chat-send-btn:hover {
    transform: scale(1.05);
    background-color: #d32f2f;
}

#doshi-chat-send-btn:active {
    transform: scale(0.95);
}

#doshi-chat-send-btn svg {
    margin-left: 2px;
}

/* Custom Scrollbar cho phần tin nhắn */
.doshi-chat-body::-webkit-scrollbar {
    width: 6px;
}

.doshi-chat-body::-webkit-scrollbar-track {
    background: transparent;
}

.doshi-chat-body::-webkit-scrollbar-thumb {
    background-color: rgba(0, 0, 0, 0.1);
    border-radius: 10px;
}

.doshi-chat-body::-webkit-scrollbar-thumb:hover {
    background-color: rgba(0, 0, 0, 0.2);
}

/* -----------------------------------------------
   Responsive tối ưu cho các màn hình điện thoại di động
-------------------------------------------------- */
@media screen and (max-width: 480px) {
    #doshi-chatbot-wrapper {
        bottom: 0;
        right: 0;
        width: 100%;
        height: 100%;
        pointer-events: none; /* Chỉ cho phép click vào con */
    }

    #doshi-chat-toggle-btn {
        pointer-events: auto;
        position: fixed;
        bottom: 20px;
        right: 20px;
        z-index: 1000;
    }

    #doshi-chat-window {
        pointer-events: auto;
        position: fixed;
        bottom: 0;
        left: 0;
        width: 100vw;
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
        border: none;
    }
    
    .doshi-chat-window-hidden {
        transform: translateY(100%) scale(1) !important;
        opacity: 0;
    }
}
