﻿.chatcontent {
    height: 100%;
    overflow-y: scroll;
    min-height: 280px;
    max-height: 1000px;
    padding: 10px;
    margin: 2px;
    background-color: #fff;
    border: 1px solid #e6e6e6;
    border-radius: 4px;
    -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, .05);
    box-shadow: inset 0 1px 1px rgba(0, 0, 0, .05);
}

    /* เพิ่ม clearfix เพื่อแก้ปัญหา float */
    .chatcontent::after {
        content: "";
        display: table;
        clear: both;
    }

.chatinfo {
    background-color: #dff0d8;
    padding: 5px;
    margin: 5px 0;
    border-radius: 8px;
    text-align: center;
}

/* ข้อความลูกค้า (chatuser1) - ด้านขวา */
.chattextuser1 {
    background-color: #007bff;
    color: white;
    padding: 10px 15px;
    margin: 2px 0 8px 25%;
    border-radius: 18px 18px 5px 18px;
    text-align: left;
    max-width: 75%;
    word-wrap: break-word;
    float: right;
    clear: both;
    display: block;
    position: relative;
}

/* ข้อความเจ้าหน้าที่ (chatuser2) - ด้านซ้าย */
.chattextuser2 {
    background-color: #f1f1f1;
    color: #333;
    padding: 10px 15px;
    margin: 2px 25% 8px 0;
    border-radius: 18px 18px 18px 5px;
    text-align: left;
    max-width: 75%;
    word-wrap: break-word;
    float: left;
    clear: both;
    display: block;
    position: relative;
}

/* ชื่อผู้ใช้ลูกค้า */
.chatuser {
    color: #007bff;
    background-color: transparent;
    padding: 2px 15px 2px 5px;
    font-weight: 600;
    font-size: 12px;
    text-align: right;
    margin: 0 0 2px 25%;
    clear: both;
    display: block;
}

/* ชื่อเจ้าหน้าที่ */
.chatagent {
    color: #666;
    background-color: transparent;
    padding: 2px 5px 2px 15px;
    font-weight: 600;
    font-size: 12px;
    text-align: left;
    margin: 0 25% 2px 0;
    clear: both;
    display: block;
}

.chatform {
    margin-bottom: 15px;
}

.chatLable {
    font-size: 14px;
    font-weight: 600;
    color: #ffde17;
}

.chattext {
    font-size: 13px;
    font-weight: 400;
}

/* เพิ่ม CSS สำหรับจัดการ bubble chat */
.chat-message {
    margin: 5px 0;
    overflow: hidden;
    clear: both;
}

    .chat-message.user1 {
        text-align: right;
    }

    .chat-message.user2 {
        text-align: left;
    }

/* เพิ่ม responsive สำหรับหน้าจอเล็ก */
@media (max-width: 768px) {
    .chatcontent {
        min-height: 250px;
        max-height: 1000px;
        padding: 8px;
    }

    .chattextuser1,
    .chattextuser2 {
        max-width: 85%;
        margin-left: 5%;
        margin-right: 5%;
        font-size: 14px;
        padding: 8px 12px;
    }

    .chattextuser1 {
        margin: 2px 5% 8px 15%;
    }

    .chattextuser2 {
        margin: 2px 15% 8px 5%;
    }

    .chatuser,
    .chatagent {
        margin-left: 5%;
        margin-right: 5%;
        font-size: 11px;
    }

    .chatuser {
        margin: 0 5% 2px 15%;
    }

    .chatagent {
        margin: 0 15% 2px 5%;
    }

    /* ปรับปุ่มให้เหมาะกับมือถือ */
    .btn {
        touch-action: manipulation;
        min-height: 44px; /* Minimum touch target size */
    }

    /* ปรับ form controls */
    .form-control {
        font-size: 16px; /* Prevent zoom on iOS */
        min-height: 44px;
    }

    /* ปรับ container */
    .container-fluid {
        padding-left: 10px;
        padding-right: 10px;
    }
}

/* เพิ่มสำหรับ tablet */
@media (min-width: 769px) and (max-width: 1024px) {
    .chatcontent {
        min-height: 300px;
        max-height: 1000px;
    }

    .chattextuser1,
    .chattextuser2 {
        max-width: 80%;
        font-size: 15px;
    }

    .chattextuser1 {
        margin: 2px 10% 8px 20%;
    }

    .chattextuser2 {
        margin: 2px 20% 8px 10%;
    }

    .chatuser {
        margin: 0 10% 2px 20%;
    }

    .chatagent {
        margin: 0 20% 2px 10%;
    }
}

/* สำหรับหน้าจอใหญ่ */
@media (min-width: 1025px) {
    .chatcontent {
        min-height: 350px;
        max-height: 1000px;
    }
}

/* เพิ่ม animation สำหรับข้อความใหม่ */
.chattextuser1,
.chattextuser2 {
    animation: fadeInUp 0.3s ease-out;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* เพิ่ม shadow effect */
.chattextuser1,
.chattextuser2 {
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

/* ปรับ scrollbar ให้สวยงาม */
.chatcontent::-webkit-scrollbar {
    width: 6px;
}

.chatcontent::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.chatcontent::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

    .chatcontent::-webkit-scrollbar-thumb:hover {
        background: #a8a8a8;
    }

/* เพิ่ม responsive utility classes */
.responsive-container {
    max-width: 100%;
    margin: 0 auto;
    padding: 15px;
}

.responsive-img {
    width: 100%;
    height: auto;
    max-width: 100%;
}

/* เพิ่ม styles สำหรับปรับปรุงการใช้งานบนมือถือ */
@media (max-width: 480px) {
    .responsive-container {
        padding: 8px;
    }

    .flag-icon {
        width: 40px !important;
        margin-left: 5px !important;
    }

    .welcome-text {
        font-size: 12px !important;
        margin: 8px 0 !important;
    }

    .form-group {
        margin-bottom: 12px;
    }

    .control-label {
        font-size: 14px;
        margin-bottom: 5px;
        display: block;
    }

    .btn {
        width: 100% !important;
        margin: 5px 0;
        font-size: 14px;
    }

    .chat-buttons .btn {
        width: 48% !important;
        margin: 2px 1%;
    }

    .chatcontent {
        min-height: 200px !important;
        max-height: 1000px !important;
        margin-bottom: 10px;
    }
}

/* เพิ่ม styles สำหรับการแสดงผลที่ดีขึ้น */
.form-control:focus {
    border-color: #007bff;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

.btn:focus {
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

/* ปรับปรุงการแสดงผลข้อความ error */
.text-danger, .text-warning {
    font-size: 12px;
    margin-top: 2px;
    display: block;
}

/* เพิ่ม loading animation */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #007bff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}
