/* CSS CƠ BẢN */
#ai-chat-widget-container { position: fixed; z-index: 9999; font-family: 'Open Sans', sans-serif; }

.ai-cta-button { padding: 10px 16px; background-color: #198754; color: white; border: none; border-radius: 8px; box-shadow: 0 4px 12px rgba(0,0,0,0.2); cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 13px; position: relative; }

.ai-tooltip { position: absolute; bottom: calc(100% + 15px); right: 0; background: white; padding: 10px 30px 10px 15px; border-radius: 8px; box-shadow: 0 4px 15px rgba(0,0,0,0.15); font-size: 13px; font-weight: 500; color: #333; white-space: nowrap; animation: bounceIn 0.5s ease; border: 1px solid #e0e0e0; }
.ai-tooltip::after { content: ''; position: absolute; bottom: -6px; right: 20px; width: 12px; height: 12px; background: white; border-right: 1px solid #e0e0e0; border-bottom: 1px solid #e0e0e0; transform: rotate(45deg); }
.close-tooltip-btn { position: absolute; top: 5px; right: 8px; background: none; border: none; font-size: 16px; color: #999; cursor: pointer; line-height: 1; }

.online-dot { width: 8px; height: 8px; background-color: #28a745; border-radius: 50%; display: inline-block; box-shadow: 0 0 0 rgba(40, 167, 69, 0.7); animation: pulse_online 2s infinite; border: 1px solid #fff; }
@keyframes pulse_online { 0% { box-shadow: 0 0 0 0 rgba(40, 167, 69, 0.7); } 70% { box-shadow: 0 0 0 6px rgba(40, 167, 69, 0); } 100% { box-shadow: 0 0 0 0 rgba(40, 167, 69, 0); } }

/* Lựa chọn nhanh HÀNG DỌC */
.quick-replies-vertical { display: flex; flex-direction: column; gap: 8px; padding-left: 10px; margin-top: 5px; margin-bottom: 10px; max-width: 85%; }
.qr-btn-vertical { background: white; border: 1px solid #198754; color: #198754; padding: 8px 14px; border-radius: 16px; font-size: 13px; text-align: left; cursor: pointer; transition: all 0.2s ease; font-weight: 500; box-shadow: 0 2px 4px rgba(0,0,0,0.05); }
.qr-btn-vertical:hover { background: #198754; color: white; transform: translateX(3px); box-shadow: 0 3px 6px rgba(0,0,0,0.1); }

/* Layout Chat */
.chat-window { background: white; border-radius: 12px; box-shadow: 0 5px 25px rgba(0,0,0,0.2); display: flex; flex-direction: column; overflow: hidden; border: 1px solid #e0e0e0; animation: slideInUp 0.3s ease; }
.chat-header { background-color: #198754; color: white; padding: 10px 12px; display: flex !important; flex-wrap: nowrap !important; justify-content: space-between; align-items: center; border-bottom: 1px solid #146c43; gap: 6px; }
.chat-header > div:first-child { flex: 1; min-width: 0; display: flex !important; flex-wrap: nowrap !important; align-items: center; gap: 8px; overflow: hidden; }
.close-btn { background: none; border: none; color: white; font-size: 28px; cursor: pointer; line-height: 1; }
/* Thanh 2 dòng: dòng 1 warning / dòng 2 icons căn giữa + nút Gửi phải */
.qc-btn { display: inline-flex; transition: transform 0.2s ease-in-out; }
.qc-btn img { border-radius: 50%; box-shadow: 0 2px 5px rgba(0,0,0,0.15); }
.qc-btn:hover { transform: scale(1.12) translateY(-1px); }
/* Keep old class for dark mode reference */
.chat-quick-contact { border-bottom: 1px solid #e0e0e0; }
.chat-body { flex: 1; padding: 15px; overflow-y: auto; background-color: #f8f9fa; display: flex; flex-direction: column; gap: 10px; }
.message { display: flex; margin-bottom: 5px; }
.bot-message { justify-content: flex-start; }
.user-message { justify-content: flex-end; }
.msg-bubble { max-width: 80%; padding: 10px 14px; border-radius: 15px; font-size: 14px; line-height: 1.4; word-wrap: break-word; }
.bot-message .msg-bubble { background-color: #e9ecef; color: #333; border-top-left-radius: 2px; }
.user-message .msg-bubble { background-color: #198754; color: white; border-top-right-radius: 2px; }
/* Link trong chat bot — xanh đậm, in đậm */
.bot-message .msg-bubble a { color: #0d6efd; font-weight: 700; text-decoration: underline; background: rgba(13,110,253,0.07); border-radius: 3px; padding: 0 2px; }
.bot-message .msg-bubble a:hover { color: #0d47a1; }
.dark-mode .bot-message .msg-bubble a { color: #64b5f6; }

.chat-footer { padding: 8px 10px 6px; border-top: 1px solid #eee; background: white; }
/* Hàng 1: textarea + nút Gửi */
.chat-footer-row { display: flex; align-items: flex-end; gap: 8px; margin-bottom: 6px; }
.chat-input-textarea {
    flex: 1; min-width: 0; box-sizing: border-box;
    min-height: 52px; max-height: 120px;
    border: 1.5px solid #ced4da; border-radius: 10px;
    font-size: 14px; line-height: 1.5; padding: 9px 12px;
    resize: none; outline: none; font-family: inherit;
    overflow-y: auto; transition: border-color 0.2s;
}
/* Hàng 2: cảnh báo + icons trên 1 dòng */
.chat-contact-bar { display: flex; align-items: center; flex-wrap: nowrap; gap: 5px; padding: 4px 0 2px; border-top: 1px solid #f0f0f0; overflow: hidden; }
.chat-contact-warn { font-size: 9px; color: #c0392b; font-style: italic; line-height: 1.3; white-space: nowrap; flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.chat-contact-icons { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }
.chat-input-textarea:focus { border-color: #198754; box-shadow: 0 0 0 2px rgba(25,135,84,0.15); }
.chat-input-textarea::placeholder { color: #aaa; }
/* Nút Gửi trong thanh 3 cột */
.send-btn { border-radius: 20px; height: 34px; padding: 0 14px; display: flex; align-items: center; justify-content: center; background-color: #198754; border-color: #198754; font-weight: 500; font-size: 13px; cursor: pointer; }
.send-btn:hover { background-color: #146c43; border-color: #146c43; }

/* DARK MODE LỘT XÁC */
.dark-mode .chat-window { background-color: #1e1e1e; border-color: #333; }
.dark-mode .chat-body { background-color: #121212; }
.dark-mode .chat-footer-hint { color: #555; }
.dark-mode .chat-contact-bar { border-top-color: #333; }
.dark-mode .chat-contact-warn { color: #e57373; }
.dark-mode .bot-message .msg-bubble { background-color: #333; color: #eee; }
.dark-mode .user-message .msg-bubble { background-color: #146c43; }
.dark-mode .form-control { background-color: #333; color: white; border-color: #444; }
.dark-mode .form-control::placeholder { color: #888; }
.dark-mode .chat-input-textarea { background-color: #333; color: #eee; border-color: #555; }
.dark-mode .chat-input-textarea::placeholder { color: #888; }
.dark-mode .chat-send-hint { color: #666; }
.dark-mode .chat-quick-contact span { color: #aaa !important; }
.dark-mode .qr-btn-vertical { background: #1e1e1e; border-color: #146c43; color: #d1e7dd; box-shadow: none; }
.dark-mode .qr-btn-vertical:hover { background: #146c43; color: white; }

/* Hiệu ứng */
.typing-indicator span { display: inline-block; width: 6px; height: 6px; background-color: #999; border-radius: 50%; margin: 0 2px; 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% { transform: translateY(0); } 50% { transform: translateY(-5px); } }
@keyframes slideInUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
@keyframes bounceIn { 0% { transform: scale(0.8); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
.d-none { display: none !important; }

/* Responsive */
@media (min-width: 769px) {
    #ai-chat-widget-container { bottom: 16px; right: 24px; }
    .chat-window { position: absolute; bottom: 80px; right: 0; width: 500px; height: 600px; }
    .ai-cta-shaking-desktop { animation: shake_desktop 2.5s infinite; }
    @keyframes shake_desktop { 0%, 100% { transform: scale(1); } 5%, 15%, 25% { transform: scale(1) translateX(-3px) rotate(-2deg); } 10%, 20% { transform: scale(1) translateX(3px) rotate(2deg); } 30%, 100% { transform: scale(1); } }
}

@media (max-width: 768px) {
    #ai-chat-widget-container { bottom: 20px; right: 15px; }
    .ai-cta-button { padding: 9px 13px; font-size: 12px; border-radius: 6px; animation: vibrate_mobile 3s infinite; }
    @keyframes vibrate_mobile { 0%, 100% { transform: scale(1); } 10%, 20% { transform: scale(1.02); } 15% { transform: scale(1.02) translateX(-1px); } 30%, 100% { transform: scale(1); } }
    .chat-window { position: fixed; bottom: 20px; right: 15px; width: calc(100vw - 30px); height: calc(100vh - 120px); z-index: 100000; }
    .ai-tooltip { right: -5px; } 
}
