/* Container chính */
.chat-modern {
    width: 380px;
    height: 550px;
    background: #fff;
    border-radius: 20px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.15);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid #eee;
}

/* Hiệu ứng chuyển động mượt mà khi hiện khung chat */
.chat-modern {
    transition: all 0.3s ease-in-out;
    position: absolute;
    bottom: -120px; /* Cách trên nút Robot một khoảng */
    right: 50px;
}

/* Header mượt mà */
.chat-header {
    background: #fff;
    padding: 15px;
    border-bottom: 1px solid #f0f0f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
    z-index: 3;
}
.header-actions {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex: 0 0 auto;
}
.chat-header-btn {
    width: 34px;
    height: 34px;
    border: 1px solid #eee;
    border-radius: 8px;
    background: #fff;
    color: #555;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}
.chat-header-btn:hover {
    background: #fff1f0;
    color: #da251d;
    border-color: #f8c1bd;
}

.status-online {
    color: #28a745;
    font-size: 0.75rem;
}
.status-online::before {
    content: "●";
    margin-right: 4px;
}

/* Body & Tin nhắn */
.chat-body {
    flex: 1;
    padding: 15px;
    background:
        linear-gradient(135deg, rgba(218,37,29,.05), rgba(255,204,0,.06)),
        #f8f9fa;
    overflow-y: auto;
}

.chat-message-row {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin-bottom: 12px;
    width: 100%;
}
.bot-message-row {
    justify-content: flex-start;
}
.user-message-row {
    justify-content: flex-end;
}
.chat-message-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: 2px solid #ffcc00;
    background: #fff;
    box-shadow: 0 2px 8px rgba(0,0,0,.12);
    flex: 0 0 auto;
}
.chat-bubble {
    max-width: min(78%, 720px);
    padding: 10px 12px;
    border-radius: 14px;
    box-shadow: 0 6px 16px rgba(15,23,42,.08);
    font-size: .9rem;
    line-height: 1.48;
}
.bot-bubble {
    background: #fff;
    color: #111827;
    border: 1px solid #f1d6d3;
    border-left: 4px solid #da251d;
    border-top-left-radius: 4px;
}
.user-bubble {
    background: linear-gradient(135deg, #da251d, #b91c1c);
    color: #fff;
    border: 1px solid #ffcc00;
    border-top-right-radius: 4px;
}
.chat-bubble-role {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 5px;
    font-size: 11px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: .2px;
}
.bot-bubble .chat-bubble-role {
    color: #da251d;
}
.user-bubble .chat-bubble-role {
    justify-content: flex-end;
    color: #ffec99;
}
.chat-bubble-text {
    overflow-wrap: anywhere;
}
.chat-mode-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 7px;
    border-radius: 999px;
    font-size: 10px;
    text-transform: none;
    letter-spacing: 0;
}
.chat-badge-system {
    background: #da251d;
    color: #fff;
}
.chat-badge-internet {
    background: #0d6efd;
    color: #fff;
}
.is-typing {
    color: #6b7280;
    font-size: 12px;
}

.bot-msg-container { display: flex; align-items: flex-start; gap: 8px; }
.bot-msg {
    background: #fff;
    padding: 10px 15px;
    border-radius: 15px 15px 15px 5px;
    max-width: 80%;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    font-size: 0.9rem;
}

.chat-history-panel {
    background: #fff;
    border: 1px solid #f4c7c3;
    border-left: 4px solid #da251d;
    border-radius: 12px;
    padding: 10px;
    margin-bottom: 12px;
    box-shadow: 0 6px 18px rgba(15,23,42,.06);
}
.chat-history-panel:not(.is-expanded) {
    padding: 8px 10px;
}
.chat-history-head,
.chat-history-pager {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}
.chat-history-head {
    color: #9f1d17;
    font-size: 12px;
    font-weight: 900;
    text-transform: uppercase;
}
.chat-history-actions {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex: 0 0 auto;
}
.chat-history-head button,
.chat-history-pager button {
    min-width: 28px;
    height: 28px;
    border: 1px solid #f1b8b4;
    border-radius: 8px;
    background: #fff7f6;
    color: #da251d;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 0 8px;
    font-size: 11px;
    font-weight: 800;
}
.chat-history-head button:not(#chat-history-toggle),
.chat-history-pager button {
    width: 28px;
    padding: 0;
}
.chat-history-head button:hover,
.chat-history-pager button:hover:not(:disabled) {
    background: #da251d;
    color: #fff;
}
.chat-history-pager button:disabled {
    opacity: .45;
    cursor: not-allowed;
}
.chat-history-list {
    display: grid;
    gap: 6px;
    max-height: 190px;
    overflow-y: auto;
    padding: 8px 0;
}
.chat-history-item {
    display: grid;
    gap: 3px;
    width: 100%;
    text-align: left;
    background: linear-gradient(135deg, #fff, #fff8e1);
    border: 1px solid #f6df9a;
    border-radius: 10px;
    padding: 8px 9px;
    color: #111827;
}
.chat-history-item:hover {
    border-color: #da251d;
    box-shadow: 0 4px 14px rgba(218,37,29,.12);
}
.chat-history-question {
    font-weight: 800;
    font-size: 12px;
    color: #9f1d17;
}
.chat-history-meta {
    color: #6b7280;
    font-size: 10px;
}
.chat-history-answer {
    color: #374151;
    font-size: 11px;
    line-height: 1.35;
}
.chat-history-empty {
    padding: 8px;
    color: #6b7280;
    font-size: 12px;
    text-align: center;
}
.chat-history-pager {
    border-top: 1px dashed #f1d6d3;
    padding-top: 7px;
    font-size: 11px;
    color: #6b7280;
}

/* Nút gợi ý nhanh giống ảnh 3 */
.btn-quick {
    background: #fff;
    border: 1px solid #eee;
    border-radius: 10px;
    width: 100%;
    text-align: left;
    font-size: 0.85rem;
    padding: 10px;
    transition: 0.3s;
}
.btn-quick:hover { background: #f0f0f0; border-color: #ccc; }

/* Nút bấm nổi giống ảnh 2 */
.chat-trigger {
    cursor: pointer;
    transition: transform 0.3s;
}
.chat-trigger:hover { transform: scale(1.1); }
.floating-robot {
    width: 65px;
    height: 65px;
    filter: drop-shadow(0 5px 10px rgba(0,0,0,0.2));
}

.avatar-sm { width: 35px; height: 35px; border-radius: 50%; }
.avatar-xs { width: 25px; height: 25px; border-radius: 50%; }

/* Footer & Input */
.chat-footer {
    padding: 15px;
    background: #fff;
    position: relative;
    z-index: 3;
}
.input-wrapper {
    background: #f0f0f0;
    border-radius: 15px;
    padding: 8px 15px;
    display: flex;
    align-items: center;
}
#chat-input {
    border: none;
    background: transparent;
    width: 100%;
    outline: none;
    resize: none;
    font-size: 0.9rem;
}
.input-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    flex: 0 0 auto;
}
.input-actions button,
.input-actions > i {
    width: 30px;
    height: 30px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}
#chat-voice-button.text-danger i {
    animation: chatVoicePulse 1s ease-in-out infinite;
}
@keyframes chatVoicePulse {
    50% { transform: scale(1.18); opacity: 0.65; }
}
.chat-close-bottom {
    width: 100%;
    margin-top: 10px;
    border: 1px solid #f1b8b4;
    background: #fff5f5;
    color: #da251d;
    border-radius: 10px;
    padding: 8px 10px;
    font-weight: 700;
}
.chat-close-bottom:hover {
    background: #da251d;
    color: #fff;
}
.chat-modern.is-fullscreen {
    position: fixed !important;
    inset: 12px !important;
    width: auto !important;
    height: auto !important;
    max-width: none !important;
    max-height: none !important;
    border-radius: 12px !important;
    z-index: 2147483000 !important;
}
.chat-modern.is-fullscreen .chat-body {
    min-height: 0;
}
@media (max-width: 575.98px) {
    .chat-modern {
        width: min(94vw, 380px);
        height: min(72vh, 550px);
        right: 0;
    }
    .chat-footer { padding: 10px; }
    .input-wrapper { padding: 6px 8px; }
    .chat-bubble {
        max-width: 86%;
    }
    .chat-modern.is-fullscreen {
        inset: 0 !important;
        border-radius: 0 !important;
    }
}

/* Đảm bảo khung chat luôn ẩn khi mới load trang */
.chat-modern.d-none {
    display: none !important;
}

/* Tăng cường hiển thị để không bị các nút chức năng bên phải đè lên */
#chatbot-container {
    z-index: 10001 !important; /* Cao hơn các nút đỏ bên phải trong ảnh của đồng chí */
}
