.andudo-chat-admin-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    background: white;
}

.andudo-chat-sidebar {
    width: 100%;
    border-bottom: 1px solid #ddd;
    background: #f8f9fa;
    display: flex;
    flex-direction: column;
    height: 100vh; /* 100% ของความสูงหน้าจอสำหรับคอมพิวเตอร์ */
    overflow: hidden;
}

.andudo-chat-sidebar h3 {
    padding: 15px;
    margin: 0;
    background: #5e605f;
    color: white;
    font-size: 16px;
    flex-shrink: 0;
}

.andudo-user-list {
    flex: 1;
    overflow-y: auto;
    padding: 0;
    height: calc(100% - 60px); /* ความสูงเต็มที่เหลือหลังจากหักส่วนหัว */
}

.andudo-user-item {
    display: flex;
    align-items: center;
    padding: 12px 15px;
    cursor: pointer;
    border-bottom: 1px solid #eee;
    position: relative;
    transition: background 0.2s;
}

.andudo-user-item:hover {
    background: #e9ecef;
}

.andudo-user-item.active {
    background: #5e605f;
    color: white;
}

.user-avatar {
    margin-right: 10px;
    flex-shrink: 0;
}

.user-info {
    flex: 1;
    min-width: 0;
}

.user-name {
    font-weight: bold;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-role {
    font-size: 12px;
    color: #666;
}

.andudo-user-item.active .user-role {
    color: #ccc;
}

.unread-badge {
    background: #28a745;
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
    flex-shrink: 0;
    margin-left: 10px;
}

/* Modal styles - เหมือนกับฝั่งผู้ใช้ */
.andudo-chat-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 400px;
    height: 500px;
    background: white;
    border: 1px solid #ddd;
    border-radius: 8px;
    box-shadow: 0 5px 25px rgba(0,0,0,0.2);
    z-index: 1001;
    display: none;
}

.chat-modal-content {
    height: 100%;
    display: flex;
    flex-direction: column;
}

.chat-modal-content .chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    background: #ebeff2;
    color: #5e605f;
    border-radius: 8px 8px 0 0;
    flex-shrink: 0;
}

.chat-modal-content .chat-header h3 {
    margin: 0;
    font-size: 16px;
}

.close-chat {
    background: none;
    border: none;
    color: #5e605f;
    font-size: 20px;
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-modal-content .chat-messages {
    flex: 1;
    padding: 15px;
    overflow-y: auto;
    background: #f3f3f3;
    max-height: calc(100% - 120px);
    min-height: 200px;
}

/* สไตล์สำหรับ scrollbar */
.chat-modal-content .chat-messages::-webkit-scrollbar {
    width: 6px;
}

.chat-modal-content .chat-messages::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.chat-modal-content .chat-messages::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.chat-modal-content .chat-messages::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* Reuse message styles from admin */
.chat-modal-content .message {
    margin-bottom: 10px;
    max-width: 85%;
}

.chat-modal-content .message.own {
    margin-left: auto;
    text-align: right;
}

.chat-modal-content .message.other {
    margin-right: auto;
}

/* สไตล์สำหรับข้อความ */
.chat-modal-content .message.text-message .message-content {
    padding: 8px 12px;
    border-radius: 15px;
    display: inline-block;
    word-wrap: break-word;
    font-size: 13px;
    max-width: 100%;
}

.chat-modal-content .message.text-message.own .message-content {
    background: #5e605f;
    color: white;
}

.chat-modal-content .message.text-message.other .message-content {
    background: #e9ecef;
    color: #333;
}

/* เพิ่มสไตล์สำหรับลิงก์ในข้อความแชท */
.chat-modal-content .message.text-message .message-content a {
    color: inherit !important;
    text-decoration: underline;
}

.chat-modal-content .message.text-message.own .message-content a {
    color: white !important;
    text-decoration: underline;
}

.chat-modal-content .message.text-message.other .message-content a {
    color: #333 !important;
    text-decoration: underline;
}


/* สไตล์สำหรับรูปภาพ */
.chat-modal-content .message.image-message .image-container {
    padding: 0;
    border-radius: 8px;
    display: inline-block;
    max-width: 100%;
}

.chat-modal-content .message.image-message .message-content {
    background: transparent;
    padding: 0;
}

.chat-modal-content .message-time {
    font-size: 10px;
    color: #999;
    margin-top: 3px;
}

.chat-modal-content .chat-image {
    max-width: 150px;
    border-radius: 8px;
    display: block;
    background: transparent;
}

.chat-modal-content .chat-input {
    padding: 15px;
    border-top: 1px solid #ddd;
    background: #f8f9fa;
    border-radius: 0 0 8px 8px;
    flex-shrink: 0;
}

.chat-modal-content .chat-input textarea {
    width: 100%;
    border: 1px solid #ddd;
    border-radius: 20px;
    padding: 8px 12px;
    resize: vertical;
    font-family: inherit;
    font-size: 13px;
    height: 40px;
    min-height: 40px;
    max-height: 80px;
}

/* ปรับโครงสร้าง chat-actions */
.chat-modal-content .chat-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 8px;
    gap: 10px;
}

.chat-modal-content .chat-action-left {
    display: flex;
    gap: 5px;
    align-items: center;
}

.chat-modal-content .chat-action-right {
    display: flex;
    align-items: center;
}

.chat-modal-content .btn-image, 
.chat-modal-content .btn-send {
    padding: 6px 12px;
    border: none;
    border-radius: 15px;
    cursor: pointer;
    font-size: 12px;
}

.chat-modal-content .btn-image {
    background: #5e605f;
    color: white;
}

.chat-modal-content .btn-send {
    background: #5e605f;
    color: white;
}

/* สไตล์ปุ่มลบประวัติการสนทนา */
.chat-modal-content .btn-clear-history {
    padding: 6px 12px;
    border: none;
    border-radius: 15px;
    cursor: pointer;
    font-size: 12px;
    background: #dc3545;
    color: white;
    white-space: nowrap;
}

.chat-modal-content .btn-clear-history:hover {
    background: #c82333;
    opacity: 0.9;
}




/* สำหรับเมื่อไม่มีข้อความ */
.chat-modal-content .no-messages {
    text-align: center;
    color: #999;
    padding: 20px;
    font-style: italic;
    font-size: 14px;
}

/* Overlay background */
.andudo-chat-modal::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: -1;
}

/* Responsive - สำหรับมือถือ */
@media (max-width: 768px) {
    .andudo-chat-admin-container {
        height: 100vh;
    }
    
    .andudo-chat-sidebar {
        height: 80vh; /* 80% ของความสูงหน้าจอสำหรับมือถือด้วย */
        max-height: none; /* ลบ max-height เดิม */
    }
    
    .andudo-user-list {
        height: calc(100% - 60px); /* ความสูงเต็มที่เหลือหลังจากหักส่วนหัว */
    }
    
    .andudo-chat-modal {
        width: 100%;
        height: 80vh; /* 80% ของความสูงหน้าจอ */
        border-radius: 0;
        top: 20vh; /* เริ่มจาก 20% จากด้านบน */
        left: 0;
        transform: none;
        position: fixed;
    }
    
    .chat-modal-content {
        border-radius: 0;
    }
    
    .chat-modal-content .chat-header {
        border-radius: 0;
    }
    
    .chat-modal-content .chat-input {
        border-radius: 0;
    }
    
    /* ปรับขนาดฟอนต์และ padding สำหรับมือถือ */
    .andudo-user-item {
        padding: 10px 12px;
    }
    
    .user-name {
        font-size: 14px;
    }
    
    .user-role {
        font-size: 11px;
    }
    
    .chat-modal-content .chat-header h3 {
        font-size: 14px;
    }
    
    .chat-modal-content .chat-input textarea {
        font-size: 12px;
        padding: 6px 10px;
    }
    
    .chat-modal-content .btn-image,
    .chat-modal-content .btn-send,
    .chat-modal-content .btn-clear-history {
        font-size: 11px;
        padding: 5px 10px;
    }
}

/* สำหรับหน้าจอขนาดเล็กมาก (เช่น มือถือแนวตั้ง) */
@media (max-width: 480px) {
    .andudo-chat-sidebar {
        height: 80vh;
    }
    
    .andudo-chat-modal {
        height: 80vh;
        top: 20vh;
    }
    
    .chat-modal-content .chat-actions {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-top: 8px;
        gap: 5px;
    }
    
    .chat-modal-content .chat-action-left {
        display: flex;
        gap: 5px;
        flex: 1;
    }
    
    .chat-modal-content .chat-action-right {
        display: flex;
        flex: 1;
        justify-content: flex-end;
    }
    
    /* ทำให้ปุ่มทั้งหมดมีขนาดเท่ากัน */
    .chat-modal-content .btn-image, 
    .chat-modal-content .btn-send,
    .chat-modal-content .btn-clear-history {
        padding: 6px 12px;
        border: none;
        border-radius: 15px;
        cursor: pointer;
        font-size: 11px;
        height: 32px;
        display: flex;
        align-items: center;
        justify-content: center;
        white-space: nowrap;
        flex-shrink: 0;
    }
    
    /* จัดเรียงลำดับปุ่ม */
    .chat-modal-content .chat-action-left {
        order: 1;
    }
    
    .chat-modal-content .chat-action-right {
        order: 2;
    }
    
    /* ปุ่มส่งรูปภาพ */
    .chat-modal-content .btn-image {
        order: 1;
    }
    
    /* ปุ่มลบประวัติการสนทนา */
    .chat-modal-content .btn-clear-history {
        order: 2;
        background: #dc3545;
        color: white;
        margin: 0 5px;
    }
    
    /* ปุ่มส่งข้อความ */
    .chat-modal-content .btn-send {
        order: 3;
    }
}