/* Chatbot Popup CSS - Tối ưu cho người dùng tuổi trung niên */
.chatbot-popup {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 16px; /* Tăng font size cơ bản */
}

/* Retry Button Styles */
.retry-btn {
    background: linear-gradient(135deg, #ffa500, #ff8c00);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.3s ease;
    box-shadow: 0 2px 10px rgba(255, 165, 0, 0.3);
    margin-right: 10px;
}

.retry-btn:hover {
    background: linear-gradient(135deg, #ff8c00, #ff6b00);
    transform: translateY(-1px);
    box-shadow: 0 4px 15px rgba(255, 165, 0, 0.4);
}

.test-webhook-btn {
    background: linear-gradient(135deg, #2196f3, #1976d2);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.3s ease;
    box-shadow: 0 2px 10px rgba(33, 150, 243, 0.3);
}

.test-webhook-btn:hover {
    background: linear-gradient(135deg, #1976d2, #1565c0);
    transform: translateY(-1px);
    box-shadow: 0 4px 15px rgba(33, 150, 243, 0.4);
}

.retry-actions {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

.retry-info {
    color: #666;
    font-style: italic;
}

.retry-message {
    background: #fff3e0 !important;
    border-left: 4px solid #ffa500;
}

.retry-message .message-text {
    color: #e65100;
}

.fallback-message {
    background: #f3e5f5 !important;
    border-left: 4px solid #9c27b0;
}

.fallback-message .message-text {
    color: #4a148c;
}

.fallback-suggestions {
    margin-top: 15px;
    padding: 15px;
    background: rgba(156, 39, 176, 0.1);
    border-radius: 10px;
    border-left: 3px solid #9c27b0;
}

.fallback-suggestions small {
    color: #7b1fa2;
    font-weight: 600;
    display: block;
    margin-bottom: 10px;
}

.fallback-suggestions ul {
    margin: 0;
    padding-left: 20px;
    color: #4a148c;
}

.fallback-suggestions li {
    margin: 5px 0;
    line-height: 1.4;
}

.fallback-suggestions strong {
    color: #6a1b9a;
}

/* Message Formatting Styles - Đơn giản hóa cho người dùng tuổi trung niên */
.message-text .highlight {
    /* Loại bỏ highlight */
    background: none;
    padding: 0;
    border-radius: 0;
    color: inherit;
    font-weight: normal;
}

.message-text .stats {
    /* Đơn giản hóa stats */
    background: none;
    padding: 0;
    border-radius: 0;
    margin: 5px 0;
    text-align: left;
    font-weight: 600;
    font-size: inherit;
    box-shadow: none;
    color: #333;
}

.message-text ul {
    margin: 10px 0;
    padding-left: 20px;
}

.message-text li {
    margin: 5px 0;
    line-height: 1.6;
}

.message-text .conclusion {
    /* Đơn giản hóa conclusion - mờ nhạt hơn */
    background: none;
    padding: 0;
    border-radius: 0;
    border-left: none;
    margin: 15px 0 10px 0; /* Tăng margin trên để tách biệt */
    font-style: italic;
    color: #bbb; /* Làm mờ nhạt hơn nữa từ #999 */
    font-size: 13px; /* Giảm font size thêm */
    opacity: 0.7; /* Giảm opacity để mờ nhạt hơn */
    line-height: 1.5; /* Giảm line height */
}

/* Tăng font size và line height cho dễ đọc */
.message-text {
    font-size: 16px;
    line-height: 1.6;
    color: #333;
}

/* Làm đậm các từ khóa quan trọng */
.message-text strong {
    color: #000;
    font-weight: 600;
}

/* Làm nghiêng các câu kết luận */
.message-text em {
    color: #bbb; /* Làm mờ nhạt hơn từ #555 */
    font-style: italic;
    opacity: 0.7; /* Thêm opacity để mờ nhạt */
    display: block; /* Hiển thị block để tách biệt */
    margin: 15px 0 10px 0; /* Tăng margin để tách biệt */
    font-size: 13px; /* Giảm font size */
    line-height: 1.5; /* Giảm line height */
}

/* Error Message Styles */
.bot-message.error {
    background: #ffebee !important;
    border-left: 4px solid #f44336;
}

.bot-message.error .message-text {
    color: #c62828;
}

/* Toggle Button */
.chatbot-toggle {
    display: flex;
    align-items: center;
    background: linear-gradient(135deg, #ffa500, #ff8c00);
    color: white;
    padding: 12px 16px;
    border-radius: 50px;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(255, 165, 0, 0.3);
    transition: all 0.3s ease;
    position: relative;
    min-width: 140px;
}

.chatbot-toggle:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 25px rgba(255, 165, 0, 0.4);
}

.chatbot-toggle.active {
    background: linear-gradient(135deg, #ff8c00, #ff6b00);
}

.chatbot-toggle-icon {
    margin-right: 8px;
    display: flex;
    align-items: center;
}

.chatbot-toggle-text {
    font-weight: 600;
    font-size: 16px; /* Tăng từ 14px lên 16px */
    white-space: nowrap;
}

.chatbot-toggle-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ff4757;
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
    animation: bounce 0.6s ease-in-out;
}

/* Pulse Animation */
.chatbot-toggle.pulse {
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

@keyframes bounce {
    0%, 20%, 50%, 80%, 100% { transform: translateY(0); }
    40% { transform: translateY(-10px); }
    60% { transform: translateY(-5px); }
}

/* Notification Popup */
.chatbot-notification-popup {
    position: fixed;
    bottom: 70px;
    right: 100px;
    width: 300px;
    background: white;
    border-radius: 10px;
    box-shadow: 0 5px 40px rgba(0,0,0,0.16);
    z-index: 1000;
    animation: slideIn 0.3s ease-out;
}

.notification-content {
    display: flex;
    align-items: flex-start;
    padding: 15px;
    position: relative;
}

.notification-content .message-avatar {
    margin-right: 10px;
    flex-shrink: 0;
}

.notification-content .message-text {
    flex-grow: 1;
    font-size: 14px;
    line-height: 1.4;
    color: #333;
    box-shadow: none;
    padding: 0 7px 0 0;
}

.notification-close {
    position: absolute;
    top: 1px;
    right: 7px;
    background: none;
    border: none;
    cursor: pointer;
    color: #666;
    transition: color 0.2s;
}

.notification-close:hover {
    color: #333;
}

/* Animation for popup */
@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Responsive adjustments */
@media (max-width: 480px) {
    .chatbot-notification-popup {
        width: calc(100% - 90px);
        right: 75px;
        bottom: 65px;
    }
}

/* Chatbot Window */
.chatbot-window {
    position: absolute;
    bottom: 70px;
    right: 70px;
    width: 350px;
    height: 500px;
    background: white;
    border-radius: 20px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    display: none;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid #e9ecef;
}

.chatbot-window.open {
    display: flex;
    animation: slideInUp 0.3s ease-out;
}

.chatbot-window.minimized {
    height: 60px;
}

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

/* Header */
.chatbot-header {
    background: linear-gradient(135deg, #ffa500, #ff8c00);
    color: white;
    padding: 8px 20px; /* Giảm từ 16px xuống 8px (50%) */
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-radius: 20px 20px 0 0;
}

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

.chatbot-header-info img {
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.3);
    width: 24px; /* Giảm từ 32px xuống 24px */
    height: 24px; /* Giảm từ 32px xuống 24px */
}

.chatbot-header-info h3 {
    margin: 0;
    font-size: 16px; /* Giảm từ 18px xuống 16px */
    font-weight: 600;
    color: #333;
}

.chatbot-header-info p {
    margin: 3px 0 0 0; /* Giảm từ 5px xuống 3px */
    font-size: 12px; /* Giảm từ 14px xuống 12px */
    color: #666;
    opacity: 0.9;
}

.chatbot-header-actions {
    display: flex;
    gap: 8px;
}

.chatbot-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 24px; /* Giảm từ 28px xuống 24px */
    height: 24px; /* Giảm từ 28px xuống 24px */
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    font-size: 11px; /* Giảm từ 12px xuống 11px */
}

.chatbot-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

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

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

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

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

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

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

/* Message Styles */
.message {
    display: flex;
    gap: 12px;
    max-width: 100%;
}

.bot-message {
    align-self: flex-start;
}

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

.message-avatar {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #ffa500;
    color: white;
    font-size: 14px;
}

.user-message .message-avatar {
    background: #007bff;
}

.message-content {
    flex: 1;
    max-width: 80%;
}

.message-text {
    background: white;
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.4;
    color: #333;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    word-wrap: break-word;
}

.bot-message .message-text {
    background: white;
    border: 1px solid #e9ecef;
}

.user-message .message-text {
    background: #007bff;
    color: white;
}

.message-time {
    font-size: 11px;
    color: #999;
    margin-top: 4px;
    text-align: right;
}

.user-message .message-time {
    text-align: left;
}

/* Enhanced formatting for bot messages */
.bot-message .message-text .status-lead {
    color: #333;
    margin: 0 0 12px 0;
    font-size: 16px;
}

.bot-message .message-text .status-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.bot-message .message-text .status-list.level-1 > li {
    position: relative;
    padding-left: 28px;
    margin: 10px 0;
}

.bot-message .message-text .status-list.level-1 > li::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0.7em;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #ffa500;
    box-shadow: 0 0 6px rgba(255, 165, 0, 0.3);
}

.bot-message .message-text .status-list.level-2 {
    margin-top: 8px;
    margin-left: 6px;
    border-left: 1px dashed #ddd;
    padding-left: 16px;
}

.bot-message .message-text .status-list.level-2 > li {
    position: relative;
    margin: 6px 0;
    padding-left: 22px;
    color: #555;
}

.bot-message .message-text .status-list.level-2 > li::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0.9em;
    width: 10px;
    height: 2px;
    background: #ffa500;
    border-radius: 1px;
    box-shadow: 0 0 4px rgba(255, 165, 0, 0.3);
}

.bot-message .message-text .status-cta {
    margin-top: 14px;
    color: #666;
    padding-top: 14px;
    border-top: 1px solid #eee;
    font-style: italic;
}

/* Fallback for old format */
.bot-message .message-text ul {
    margin: 10px 0;
    padding-left: 20px;
    list-style: disc;
}

.bot-message .message-text li {
    margin: 5px 0;
    line-height: 1.6;
    color: #333;
}

.bot-message .message-text strong {
    color: #2c3e50;
    font-weight: 600;
}

.bot-message .message-text em {
    color: #6c757d;
    font-style: italic;
    background: #fff3cd;
    padding: 2px 6px;
    border-radius: 4px;
    display: inline-block;
    margin-top: 8px;
}

/* Highlight số liệu quan trọng */
.bot-message .message-text strong:has(+ strong) {
    color: #e74c3c;
}

/* Responsive cho danh sách */
@media (max-width: 768px) {
    .bot-message .message-text li {
        padding: 6px 10px;
        margin: 6px 0;
    }
    
    .bot-message .message-text li.sub-item {
        margin-left: 15px;
    }
}

/* Typing Indicator */
.chatbot-typing {
    display: flex;
    gap: 12px;
    padding: 0 20px 20px;
    align-items: center;
}

.typing-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: #ffa500;
    display: flex;
    align-items: center;
    justify-content: center;
}

.typing-content {
    background: white;
    padding: 12px 16px;
    border-radius: 18px;
    border: 1px solid #e9ecef;
}

.typing-dots {
    display: flex;
    gap: 4px;
}

.typing-dots span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #ccc;
    animation: typing 1.4s infinite ease-in-out;
}

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

@keyframes typing {
    0%, 80%, 100% { transform: scale(0.8); opacity: 0.5; }
    40% { transform: scale(1); opacity: 1; }
}

/* Input Area */
.chatbot-input {
    padding: 20px;
    background: white;
    border-top: 1px solid #e9ecef;
}

.input-wrapper {
    display: flex;
    gap: 8px;
    align-items: center;
}

#chatbotInput {
    flex: 1;
    border: 2px solid #e9ecef;
    border-radius: 25px;
    padding: 12px 16px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s ease;
}

#chatbotInput:focus {
    border-color: #ffa500;
}

#chatbotInput::placeholder {
    color: #999;
}

.send-btn {
    background: #ffa500;
    color: white;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    font-size: 16px;
}

.send-btn:hover {
    background: #ff8c00;
    transform: scale(1.05);
}

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

.chatbot-input input {
    flex: 1;
    border: none;
    outline: none;
    padding: 12px 16px; /* Tăng padding */
    font-size: 16px; /* Tăng font size */
    background: transparent;
    color: #333;
}

/* Responsive Design */
@media (max-width: 480px) {
    .chatbot-popup {
        bottom: 10px;
        right: 10px;
    }
    
    .chatbot-window {
        width: calc(100vw - 20px);
        right: 0;
        bottom: 0;
        height: 80vh;
    }
    
    .chatbot-toggle {
        min-width: 120px;
        padding: 10px 14px;
    }
    
    .chatbot-toggle-text {
        font-size: 13px;
    }
}

@media (max-width: 360px) {
    .chatbot-window {
        width: calc(100vw - 20px);
        right: 0;
        bottom: 0;
        height: 80vh;
    }
    
    .chatbot-toggle {
        min-width: 100px;
        padding: 8px 12px;
    }
    
    .chatbot-toggle-text {
        font-size: 12px;
    }
}

/* Dark Mode Support */
/* @media (prefers-color-scheme: dark) {
    .chatbot-window {
        background: #1a1a1a;
        border-color: #333;
    }
    
    .chatbot-messages {
        background: #2a2a2a;
    }
    
    .message-text {
        background: #333;
        color: #fff;
        border-color: #444;
    }
    
    .bot-message .message-text {
        background: #333;
        border-color: #444;
        color: #fff;
    }
    
    .typing-content {
        background: #333;
        border-color: #444;
    }
    
    .chatbot-input {
        background: #1a1a1a;
        border-color: #333;
    }
    
    #chatbotInput {
        background: #333;
        border-color: #444;
        color: #fff;
    }
    
    #chatbotInput::placeholder {
        color: #666;
    }
} */

/* High Contrast Mode */
@media (prefers-contrast: high) {
    .chatbot-toggle {
        border: 2px solid #000;
    }
    
    .chatbot-window {
        border: 2px solid #000;
    }
    
    .message-text {
        border: 1px solid #000;
    }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    .chatbot-toggle,
    .chatbot-window,
    .send-btn {
        transition: none;
    }
    
    .chatbot-window.open {
        animation: none;
    }
    
    .chatbot-toggle.pulse {
        animation: none;
    }
}
