/* style.css - Phiên bản nâng cao (với AI và UX) */

:root {
    --primary-color: #007bff;
    --secondary-color: #6c757d;
    --success-color: #28a745;
    --danger-color: #dc3545;
    --ai-color: #9c27b0; /* NEW: Màu cho AI Assistant (Tím) */
    --bg-color: #f8f9fa;
    --white-color: #ffffff;
    --shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

body {
    font-family: Arial, sans-serif;
    background-color: var(--bg-color);
    margin: 0;
    padding: 0;
    line-height: 1.6;
}

/* --- Header & Localization --- */
.support-header {
    background-color: var(--white-color);
    color: #333;
    padding: 20px 40px;
    box-shadow: var(--shadow);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.localization-controls .loc-select {
    padding: 8px 12px;
    border: 1px solid #ccc;
    border-radius: 4px;
    margin-left: 10px;
    cursor: pointer;
    /* BỔ SUNG: Chuyển đổi mượt mà */
    transition: border-color 0.2s;
}

/* --- Main Content --- */
.support-container {
    max-width: 900px;
    margin: 30px auto;
    padding: 20px;
}

.support-section, .support-action {
    background: var(--white-color);
    padding: 25px;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
    margin-bottom: 20px;
}

/* BỔ SUNG: Khoảng cách giữa các FAQ item */
.faq-item {
    margin-bottom: 5px;
}

.faq-question {
    cursor: pointer;
    color: var(--primary-color);
    padding: 10px 0;
    border-bottom: 1px solid #eee;
    margin-top: 0;
    font-weight: 600; /* Tăng độ đậm */
}

.faq-answer {
    display: none; /* Mặc định ẩn, sẽ được hiển thị bằng JS */
    padding: 10px 0 20px 0;
    border-bottom: 1px solid #eee;
    color: #555;
}

/* --- Buttons & Forms --- */
.primary-button {
    background-color: var(--primary-color);
    color: var(--white-color);
    border: none;
    padding: 10px 20px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 16px;
    transition: background-color 0.2s, box-shadow 0.2s;
}

.primary-button:hover {
    background-color: #0056b3;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.full-width {
    width: 100%;
    margin-top: 15px;
}

/* BỔ SUNG: Focus/Accessibility Styles cho tất cả Inputs/Selects/Textareas */
.localization-controls .loc-select:focus,
.modal-body input[type="text"]:focus, 
.modal-body textarea:focus, 
.modal-body select:focus,
#faqSearchInput:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
    outline: none;
}


/* --- Floating Chat Button (Cập nhật màu AI) --- */
.chat-toggle-btn {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background-color: var(--ai-color); /* Đổi màu nút nổi sang màu AI */
    color: var(--white-color);
    border: none;
    font-size: 24px;
    cursor: pointer;
    box-shadow: var(--shadow);
    z-index: 1000;
    transition: background-color 0.2s;
}

.chat-toggle-btn:hover {
    background-color: #7b1fa2;
}

/* --- Modals (Chat & Ticket) --- */
.modal {
    display: none; /* Mặc định ẩn */
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0,0,0,0.4); /* Backdrop */
}

.modal-content {
    background-color: var(--white-color);
    margin: 10% auto;
    padding: 20px;
    border-radius: 8px;
    box-shadow: var(--shadow);
    width: 90%;
    max-width: 500px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #eee;
    padding-bottom: 10px;
    margin-bottom: 15px;
}

.close-button {
    color: var(--secondary-color);
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    border: none;
    background: none;
    transition: color 0.2s;
}
.close-button:hover {
    color: #333;
}

.modal-body label {
    display: block;
    margin-top: 10px;
    font-weight: bold;
}

.modal-body input[type="text"], 
.modal-body textarea, 
.modal-body select {
    width: 100%;
    padding: 10px;
    margin-top: 5px;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-sizing: border-box;
    transition: border-color 0.2s;
}

/* --- Chat Specific Styles --- */
.chat-modal .modal-content {
    position: fixed;
    bottom: 100px; 
    right: 30px;
    margin: 0;
    max-width: 350px;
    width: 350px;
    height: 450px;
    display: flex;
    flex-direction: column;
    padding: 0;
}

.chat-header {
    background-color: var(--primary-color);
    color: var(--white-color);
    padding: 15px;
    border-radius: 8px 8px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-header h3 {
    margin: 0;
    font-size: 18px;
}

.chat-header .close-button {
    color: var(--white-color);
}

.chat-body {
    flex-grow: 1;
    padding: 15px;
    overflow-y: auto;
    background-color: #f0f0f0;
    display: flex;
    flex-direction: column; /* Quan trọng cho message alignment */
}

.message {
    padding: 8px 12px;
    border-radius: 15px;
    margin-bottom: 10px;
    max-width: 80%;
    word-wrap: break-word; /* Xử lý tràn chữ */
}

/* Tin nhắn Nhân viên Hỗ trợ (Chung) */
.support-message {
    background-color: var(--white-color);
    align-self: flex-start;
    margin-right: auto;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

/* Tin nhắn Người dùng */
.user-message {
    background-color: #d4edda;
    color: #155724;
    align-self: flex-end;
    margin-left: auto;
    text-align: left; /* Đảm bảo text align left để dễ đọc */
}

/* BỔ SUNG: Tin nhắn từ AI */
.message.ai-message {
    background-color: #e1bee7; /* Màu nhạt AI */
    color: #4a148c;
    align-self: flex-start;
    margin-right: auto;
    font-weight: 500;
}

/* BỔ SUNG: Thông báo chuyển đổi sang Nhân viên */
.message.human-transfer {
    background-color: #f7d794; /* Màu cảnh báo (vàng) */
    color: #856404;
    text-align: center;
    max-width: 100%;
    font-size: 13px;
    margin: 10px 0;
    padding: 5px 10px;
}

.chat-input {
    display: flex;
    padding: 10px;
    border-top: 1px solid #ccc;
}

#chatInput {
    flex-grow: 1;
    margin-right: 10px;
}

#chatSendBtn {
    background-color: var(--primary-color);
    color: var(--white-color);
    border: none;
    padding: 5px 15px;
    border-radius: 5px;
    cursor: pointer;
}

/* Message Status */
.form-message {
    margin-top: 15px;
    padding: 10px;
    border-radius: 4px;
    text-align: center;
}
.success-message {
    background-color: #d4edda;
    color: #155724;
}
.error-message {
    background-color: #f8d7da;
    color: #721c24;
}


/* --- FAQ Search Bar (MỚI) --- */
.search-bar {
    position: relative;
    margin-bottom: 20px;
}

#faqSearchInput {
    width: 100%;
    padding: 12px 12px 12px 40px; /* Thêm padding bên trái cho icon */
    border: 1px solid #ddd;
    border-radius: 20px;
    font-size: 16px;
    box-sizing: border-box;
    transition: border-color 0.2s;
}

.search-icon {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--secondary-color);
}


/* --- Chat Status & Typing Indicator (AI Integration) (MỚI) --- */
.ai-status-indicator {
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: bold;
    margin-left: 10px;
    color: var(--white-color);
    /* BỔ SUNG: căn giữa text */
    display: flex;
    align-items: center;
    height: 20px;
}

.ai-status-indicator.online {
    background-color: var(--ai-color); /* AI Online (Dùng màu AI) */
}

.ai-status-indicator.human {
    background-color: var(--danger-color); /* Chuyển sang Nhân viên */
}

.ai-status-indicator.offline {
    background-color: var(--secondary-color);
}


/* Typing Indicator Animation */
.typing-indicator {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    border-radius: 15px;
    margin-bottom: 10px;
    max-width: 80px;
    background-color: var(--white-color);
}

.typing-indicator .dot {
    width: 6px;
    height: 6px;
    background: #555;
    border-radius: 50%;
    margin: 0 2px;
    animation: typing-dots 1.5s infinite;
}

.typing-indicator .dot:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-indicator .dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing-dots {
    0%, 80%, 100% {
        transform: scale(0.6);
        opacity: 0.6;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* --- Responsive Adjustments (Giữ nguyên) --- */
@media (max-width: 768px) {
    .support-header {
        flex-direction: column;
        align-items: flex-start;
    }
    .localization-controls {
        margin-top: 10px;
    }
    .support-container {
        padding: 10px;
    }
    .chat-modal .modal-content {
        right: 10px;
        bottom: 80px;
        width: 90%;
        max-width: none;
    }
}