/* =============================
   สไตล์สำหรับหน้าติดต่อทีมงาน
   ============================= */

/* สไตล์การ์ดข้อความ */
.message-card {
    background-color: #2a2a2a;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
    border: 1px solid #444;
    transition: all 0.3s ease;
    margin-bottom: 15px;
    cursor: pointer;
    position: relative;
}

.message-card:hover, .message-card-hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 20px rgba(0, 170, 255, 0.3);
    border-color: #00aaff;
}

.message-card::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border-radius: 12px;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.1);
    pointer-events: none;
}

/* Custom Modal สำหรับรายละเอียดข้อความ */
.custom-modal {
    display: none;
    position: fixed;
    z-index: 1050;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.7);
    animation: fadeIn 0.3s ease;
}

.custom-modal-content {
    position: relative;
    background-color: #222;
    margin: 5% auto;
    padding: 0;
    border: 1px solid #444;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    width: 80%;
    max-width: 800px;
    animation: modalSlideIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes modalSlideIn {
    from { transform: translateY(-50px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.custom-modal-header {
    background: linear-gradient(135deg, #1a1a1a, #2a2a2a);
    border-bottom: 1px solid #444;
    padding: 15px 20px;
    border-radius: 15px 15px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.custom-modal-header h5 {
    color: #00aaff;
    font-weight: 600;
    margin: 0;
}

.custom-modal-close {
    color: #aaa;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    line-height: 1;
}

.custom-modal-close:hover {
    color: #fff;
}

.custom-modal-body {
    padding: 20px;
    color: #eee;
    max-height: 70vh;
    overflow-y: auto;
}

.custom-modal-footer {
    background-color: rgba(0, 0, 0, 0.2);
    border-top: 1px solid #444;
    border-radius: 0 0 15px 15px;
    padding: 15px 20px;
    text-align: right;
}

.custom-modal-body::-webkit-scrollbar {
    width: 8px;
}

.custom-modal-body::-webkit-scrollbar-track {
    background: #1a1a1a;
    border-radius: 10px;
}

.custom-modal-body::-webkit-scrollbar-thumb {
    background: #444;
    border-radius: 10px;
}

.custom-modal-body::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* ปรับแต่งเพิ่มเติมสำหรับรายละเอียดข้อความ */
.message-detail-meta {
    background-color: rgba(0, 0, 0, 0.2);
    padding: 15px;
    margin: -20px -20px 20px -20px;
    border-bottom: 1px solid #333;
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
}

.meta-item {
    display: flex;
    align-items: center;
    gap: 8px;
    background-color: rgba(0, 0, 0, 0.3);
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 0.9rem;
}

.meta-item i {
    color: #00aaff;
}

/* ===== ปรับแต่งใหม่เพื่อให้แน่ใจว่าการจัดวางถูกต้อง ===== */
.chat-container {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 20px;
    width: 100%;
}

.chat-message {
    display: flex;
    flex-direction: column;
    max-width: 85%;
    position: relative;
    margin-bottom: 15px;
}

/* ========== แก้ไขส่วนของการจัดวาง user/admin message ========== */
/* ข้อความจากผู้ส่ง (ผู้ใช้) - ให้อยู่ทางซ้าย */
.user-message {
    align-self: flex-start !important;
    margin-right: auto !important;
    margin-left: 0 !important;
}

/* ข้อความจากทีมงาน (แอดมิน) - ให้อยู่ทางขวา */
.admin-message {
    align-self: flex-end !important;
    margin-left: auto !important;
    margin-right: 0 !important;
}

/* ========== แก้ไขส่วนของ header (ชื่อผู้ส่งและเวลา) ========== */
.message-header {
    width: 100%;
    display: flex;
    justify-content: space-between;
    margin-bottom: 5px;
    font-size: 0.85rem;
    color: #aaa;
}

/* ชื่อผู้ส่งอยู่ซ้าย เวลาอยู่ขวา */
.user-message .message-header {
    text-align: left !important;
    flex-direction: row !important;
}

/* ชื่อทีมงานอยู่ขวา เวลาอยู่ซ้าย */
.admin-message .message-header {
    text-align: right !important;
    flex-direction: row-reverse !important;
}

.sender-name {
    font-weight: 600;
}

.user-message .sender-name {
    color: #ffc107;
}

.admin-message .sender-name {
    color: #00aaff;
}

/* ========== แก้ไขส่วนของ bubble (กล่องข้อความ) ========== */
.message-bubble {
    padding: 12px 15px;
    border-radius: 12px;
    position: relative;
    white-space: pre-line;
    line-height: 1.5;
    width: fit-content;
}

/* กล่องข้อความผู้ใช้ - ชี้ไปทางซ้าย */
.user-message .message-bubble {
    background-color: #3a3a3a;
    color: #eee;
    border-bottom-left-radius: 0 !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    border-left: 3px solid #ffc107 !important;
    border-right: none !important;
    align-self: flex-start !important;
    margin-right: auto !important;
    margin-left: 0 !important;
}

/* กล่องข้อความทีมงาน - ชี้ไปทางขวา */
.admin-message .message-bubble {
    background-color: #00508a;
    color: #fff;
    border-bottom-right-radius: 0 !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    border-right: 3px solid #00aaff !important;
    border-left: none !important;
    align-self: flex-end !important;
    margin-left: auto !important;
    margin-right: 0 !important;
}

/* ========== แก้ไขการแสดงรูปภาพ ========== */
.message-image {
    margin-top: 10px;
}

/* รูปภาพของผู้ใช้ชิดซ้าย */
.user-message .message-image {
    text-align: left !important;
}

/* รูปภาพของทีมงานชิดขวา */
.admin-message .message-image {
    text-align: right !important;
}

.attached-image {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    border: 1px solid #444;
    max-height: 300px;
    object-fit: contain;
    background-color: #1a1a1a;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    transition: transform 0.3s ease;
}

.attached-image:hover {
    transform: scale(1.02);
}

/* ฟอร์มตอบกลับ */
.reply-form-container {
    background-color: rgba(0, 0, 0, 0.2);
    padding: 15px;
    border-radius: 12px;
    border: 1px solid #444;
}

.reply-form-title {
    color: #00aaff;
    margin-bottom: 15px;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.reply-form-title::before {
    content: '\f3e5';
    font-family: 'Font Awesome 5 Free';
    font-weight: 900;
}

.reply-form textarea {
    background-color: #2a2a2a;
    border: 1px solid #444;
    color: #eee;
    transition: all 0.3s ease;
    resize: vertical;
}

.reply-form textarea:focus {
    background-color: #333;
    border-color: #00aaff;
    box-shadow: 0 0 0 0.25rem rgba(0, 170, 255, 0.25);
}

.reply-form button {
    margin-top: 10px;
    padding: 10px 15px;
    background: linear-gradient(135deg, #007bff, #0056b3);
    border: none;
    transition: all 0.3s ease;
}

.reply-form button:hover {
    background: linear-gradient(135deg, #0056b3, #003d80);
    transform: translateY(-2px);
}

/* เพิ่มเอฟเฟ็กต์ ripple เมื่อคลิกที่การ์ด */
.message-card {
    position: relative;
    overflow: hidden;
}

.message-card:active::after {
    transform: scale(0, 0);
    opacity: 0.3;
    transition: 0s;
}

/* เพิ่มเอฟเฟ็กต์ glow เมื่อมีการตอบกลับ */
.message-card:has(.reply-badge) {
    border-left: 3px solid #ffc107;
}

.reply-badge {
    background-color: rgba(255, 193, 7, 0.2);
    color: #ffc107;
    padding: 5px 10px;
    border-radius: 15px;
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    gap: 5px;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(255, 193, 7, 0.4); }
    70% { box-shadow: 0 0 0 8px rgba(255, 193, 7, 0); }
    100% { box-shadow: 0 0 0 0 rgba(255, 193, 7, 0); }
}

/* เพิ่มเติมสำหรับการแสดงผลที่ดีขึ้น */
.empty-history {
    padding: 50px 20px;
    text-align: center;
    color: #666;
}

.empty-history i {
    margin-bottom: 15px;
    opacity: 0.5;
    color: #888;
}

.message-history-header {
    background: linear-gradient(135deg, #1a1a1a, #2a2a2a);
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #333;
}

.message-history-header h3 {
    color: #00aaff;
    margin: 0;
    display: flex;
    align-items: center;
    font-size: 1.4rem;
}

.message-history-header h3 i {
    margin-right: 10px;
}

.message-count {
    background-color: #00aaff;
    color: #fff;
    padding: 5px 10px;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 500;
}

.message-list {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.message-card-header {
    background-color: #333;
    padding: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #444;
}

.message-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

.message-card-preview {
    padding: 15px;
    color: #ccc;
    font-size: 0.95rem;
    min-height: 50px;
    max-height: 80px;
    overflow: hidden;
    text-overflow: ellipsis;
    border-bottom: 1px solid #333;
}

.message-card-footer {
    padding: 12px 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: rgba(0, 0, 0, 0.2);
}

/* สไตล์สำหรับ form-container */
.form-container {
    background-color: #2a2a2a;
    border-radius: 12px;
    padding: 25px;
    margin-bottom: 30px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
    border: 1px solid #444;
}

.form-container h3 {
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid #444;
}

/* สไตล์สำหรับ radio options */
.radio-container {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 10px;
}

.contact-option {
    background-color: #333;
    border-radius: 8px;
    padding: 10px 15px;
    transition: all 0.3s ease;
    cursor: pointer;
    border: 1px solid #444;
    flex: 1 0 calc(50% - 10px);
    display: flex;
    align-items: center;
}

.contact-option:hover {
    background-color: #3a3a3a;
    border-color: #00aaff;
}

.contact-option input[type="radio"] {
    margin-right: 10px;
}

/* สไตล์สำหรับ announcement box */
.announcement-box {
    background-color: #2a2a2a;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 25px;
    border: 1px solid #444;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

.announcement-box h4 {
    color: #00aaff;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid #444;
    display: flex;
    align-items: center;
    gap: 10px;
}

.announcement-box p {
    margin-bottom: 10px;
    color: #ddd;
    display: flex;
    align-items: center;
    gap: 8px;
}

.announcement-box a {
    color: #00aaff;
    text-decoration: none;
    transition: color 0.3s;
}

.announcement-box a:hover {
    color: #66ccff;
    text-decoration: underline;
}

/* สไตล์สำหรับปุ่มอัพโหลดรูปภาพ */
.custom-file-upload {
    margin-top: 10px;
}

.image-preview {
    display: none;
    max-width: 100%;
    max-height: 200px;
    margin-top: 15px;
    border-radius: 8px;
    border: 1px solid #444;
}

/* สไตล์ CAPTCHA */
input#captcha, input#captcha-reply {
    background-color: #2a2a2a;
    border: 1px solid #444;
    color: #fff;
    transition: all 0.3s ease;
    font-size: 1.1rem;
    letter-spacing: 1px;
    text-align: center;
}

input#captcha:focus, input#captcha-reply:focus {
    background-color: #333;
    border-color: #00aaff;
    box-shadow: 0 0 0 0.25rem rgba(0, 170, 255, 0.25);
}

/* สำหรับฟิลด์เพิ่มเติมที่ซ่อนไว้ */
.additional-fields {
    display: none;
    background-color: rgba(0, 0, 0, 0.2);
    padding: 15px;
    border-radius: 8px;
    margin-top: 5px;
    border: 1px solid #444;
}

/* สำหรับหน้าจอขนาดเล็ก */
@media (max-width: 768px) {
    .custom-modal-content {
        width: 95%;
        margin: 10% auto;
    }
    
    .message-detail-meta {
        flex-direction: column;
        gap: 10px;
    }
    
    .meta-item {
        width: 100%;
    }
    
    .message-info {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    
    .message-card-footer {
        flex-wrap: wrap;
        gap: 10px;
    }
    
    .chat-message {
        max-width: 95%;
    }
    
    .contact-option {
        flex: 1 0 100%;
    }
    
    .radio-container {
        flex-direction: column;
    }
    
    .form-container, .announcement-box {
        padding: 15px;
    }
}

/* สำหรับหน้าจอขนาดกลาง */
@media (min-width: 769px) and (max-width: 1199px) {
    .contact-option {
        flex: 1 0 calc(33.33% - 10px);
    }
}

/* การเคลื่อนไหวสำหรับปุ่มต่างๆ */
.btn {
    transition: all 0.3s ease;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

.btn:active {
    transform: translateY(1px);
}

/* สไตล์สำหรับสถานะข้อความ */
.status-read {
    color: #00aaff;
}

.status-unread {
    color: #aaa;
}

/* เพิ่มเติมสำหรับการแสดงเวลา */
.message-time {
    color: #888;
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    gap: 5px;
}

.message-time i {
    font-size: 0.9rem;
}

/* สไตล์สำหรับประเภทข้อความ */
.message-type {
    display: flex;
    align-items: center;
    gap: 5px;
    background-color: rgba(0, 170, 255, 0.1);
    padding: 5px 10px;
    border-radius: 15px;
    font-size: 0.85rem;
    color: #00aaff;
}

/* ปรับแต่งสไตล์สำหรับปุ่มในส่วนท้ายข้อความ */
.view-message, .delete-message {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 5px 10px;
    font-size: 0.85rem;
    border-radius: 5px;
    transition: all 0.3s ease;
}

.view-message:hover {
    background-color: #007bff;
    color: white;
    border-color: #007bff;
}

.delete-message:hover {
    background-color: #dc3545;
    color: white;
    border-color: #dc3545;
}
