/* Modernized theme: gradient background, accent colors, premium look */
body {
    font-family: 'Prompt', 'Inter', Arial, sans-serif;
    background: linear-gradient(135deg, #f4f4f9 0%, #e3f0ff 100%);
    min-height: 100vh;
    margin: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow-x: hidden;
}

/* ✅ ปรับขนาดแชทให้เต็มหน้าจอ */
.container {
    width: 100%;
    max-width: 480px;
    display: flex;
    flex-direction: column;
    min-height: 80vh;
    position: relative;
    margin: 32px auto;
    z-index: 2;
}

/* ✅ ปรับการ์ดแชท */
.chat-card {
    background: #fff;
    border-radius: 18px;
    box-shadow: 0 8px 32px rgba(0, 123, 255, 0.10), 0 1.5px 8px rgba(0, 0, 0, 0.06);
    padding: 32px 24px 56px 24px;
    text-align: center;
    width: 100%;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    position: relative;
    transition: box-shadow 0.2s;
    min-height: 500px;
    /* เพิ่มความสูงขั้นต่ำให้กล่องแชท */
}

.chat-card:hover {
    box-shadow: 0 12px 40px rgba(0, 123, 255, 0.18), 0 2px 12px rgba(0, 0, 0, 0.10);
}


/* ✅ ปรับกล่องแชท */
.chat-box {
    max-width: 100%;
    flex-grow: 1;
    height: 70px;
    overflow-y: auto;
    border: 1px solid #ccc;
    padding: 10px;
    background: #fff;
    border-radius: 10px;
    display: flex;
    flex-direction: column-reverse;
    /* ✅ แสดงข้อความล่าสุดด้านล่าง */
    scroll-behavior: smooth;
}

/* ✅ ปรับกล่องแชท */
#chatBox {
    display: flex;
    flex-direction: column;
    height: 70%;
    /* ✅ ปรับขนาดแชท */
    overflow-y: auto;
    padding: 10px;
    background-color: #f9f9f9;
    border-radius: 10px;
    scrollbar-width: thin;
    scrollbar-color: #007bff #f4f4f9;
    min-height: 350px;
    /* เพิ่มความสูงขั้นต่ำให้กล่องข้อความ */
}

/* ✅ สไตล์ Scroll Bar */
#chatBox::-webkit-scrollbar {
    width: 8px;
}

#chatBox::-webkit-scrollbar-thumb {
    background-color: #007bff;
    border-radius: 5px;
}

#chatBox::-webkit-scrollbar-track {
    background-color: #f0f0f0;
}

/* ✅ ทำให้ช่อง Input อยู่ด้านล่างตลอด */
.input-area {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px;
    gap: 10px;
    background: #fff;
    border-top: 1px solid #ddd;
    position: sticky;
    bottom: 0;
    width: 95%;
}

.input-area input,
.input-area button {
    font-family: 'Prompt', 'Inter', Arial, sans-serif;
}

/* ✅ ปรับช่องพิมพ์ข้อความ */
.input-area input {
    flex: 1;
    padding: 14px;
    font-size: 17px;
    border: 2px solid #e3eafc;
    border-radius: 12px;
    outline: none;
    background: #f8fbff;
    transition: border 0.2s;
}

.input-area input:focus {
    border: 2px solid #007bff;
    background: #fff;
}

/* ✅ ปรับปุ่มส่ง */
.input-area button {
    width: 54px;
    height: 54px;
    font-size: 22px;
    border-radius: 12px;
    border: none;
    background: linear-gradient(135deg, #007bff 60%, #00c6ff 100%);
    color: #fff;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 123, 255, 0.10);
    transition: background 0.2s, box-shadow 0.2s;
}

.input-area button:hover {
    background: linear-gradient(135deg, #0056b3 60%, #00aaff 100%);
    box-shadow: 0 4px 16px rgba(0, 123, 255, 0.18);
}

/* Responsive for mobile */
@media (max-width: 600px) {
    .container {
        max-width: 100vw;
        margin: 0;
        padding: 0 2vw;
    }

    .chat-card {
        padding: 16px 4px 48px 4px;
    }
}

/* ✅ ข้อความผู้ใช้ */
.user-message,
.bot-message {
    display: flex;
    align-items: center;
    border-radius: 10px;
    padding: 12px;
    max-width: 95%;
    word-wrap: break-word;
    word-break: break-word;
    margin: 8px 0;
    font-size: 16px;
}

/* ✅ ข้อความของผู้ใช้ */
.user-message {
    justify-content: flex-end;
    background-color: #d1ecf1;
    text-align: right;
}

/* ✅ ข้อความของบอท */
.bot-message {
    justify-content: flex-start;
    background-color: #e8faeb;
    text-align: left;
    display: flex;
    flex-wrap: wrap;
}

/* ✅ ปรับขนาดไอคอน */
.user-message img,
.bot-message img.icon {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    object-fit: cover;
    margin-right: 10px;
}

/* ✅ ปรับขนาดรูปภาพที่แนบมา */
.bot-message img:not(.icon) {
    max-width: 240px;
    max-height: 240px;
    border-radius: 8px;
    margin-top: 5px;
}

/* ✅ ปรับไอคอนให้ข้อความอยู่แนวเดียวกัน */
.bot-message .icon {
    align-self: flex-start;
}

/* Remove the link icon and text for bot messages containing links */
.bot-message a {
    text-decoration: none;
    color: #007bff;
    font-weight: bold;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    white-space: nowrap;
    /* Prevent links from wrapping */
}

/* Remove the link icon */
.bot-message a::before {
    content: none;
    /* Remove the link icon */
}

/* ✅ ปรับสไตล์ลิงก์ */
.bot-message a:hover {
    text-decoration: underline;
    color: #0056b3;
}

/* ✅ ปรับขนาดรูปภาพในแชท */
.chat-image {
    max-width: 240px;
    max-height: 240px;
    border-radius: 8px;
    margin-top: 8px;
}

/* ✅ แสดงไอคอนให้เหมาะสมกับประเภทของเนื้อหา */
.bot-message .link-preview {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #f1f1f1;
    padding: 10px;
    border-radius: 10px;
    margin-top: 5px;
}

.bot-message .link-preview img {
    width: 24px;
    height: 24px;
}

/* ✅ แอนิเมชัน "กำลังพิมพ์..." */
@keyframes typingDots {
    0% {
        opacity: 0.3;
    }

    50% {
        opacity: 1;
    }

    100% {
        opacity: 0.3;
    }
}

.typing-animation span {
    display: inline-block;
    animation: typing 1s steps(1) infinite;
}

.typing-animation span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-animation span:nth-child(3) {
    animation-delay: 0.4s;
}

/* ✅ ปรับสไตล์ข้อความ "กำลังพิมพ์..." */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 5px;
}

.typing-indicator img {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    object-fit: cover;
    margin-right: 10px;
}

.icon {
    display: inline-block;
    width: 24px;
    height: 24px;
    margin-right: 8px;
    vertical-align: middle;
}

.user-icon {
    background-color: #4CAF50;
    /* สีเขียว */
    border-radius: 50%;
}

.bot-icon {
    background-color: #2196F3;
    /* สีน้ำเงิน */
    border-radius: 50%;
}

.link-icon::before {
    content: "🔗";
}

.pdf-icon::before {
    content: "📄";
}

@keyframes typing {
    0% {
        opacity: 0;
    }

    50% {
        opacity: 1;
    }

    100% {
        opacity: 0;
    }
}

/* ✅ ปรับสไตล์ไอคอน */
.chat-link {
    text-decoration: none;
    font-weight: bold;
    color: #007bff;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.chat-link:hover {
    text-decoration: underline;
    color: #0056b3;
}

/* ✅ ปรับขนาดไอคอนให้ข้อความ */
.chat-link::before {
    font-size: 18px;
}

/* ✅ ปรับขนาดรูปภาพในแชท */
.chat-image {
    max-width: 240px;
    max-height: 240px;
    border-radius: 8px;
    margin-top: 8px;
}

/* CSS สำหรับ Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    /* เพิ่ม z-index ให้สูงกว่ากล่องแชท */
    padding-top: 60px;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgb(0, 0, 0);
    background-color: rgba(0, 0, 0, 0.9);
}

.modal-content {
    margin: auto;
    display: block;
    width: 80%;
    max-width: 700px;
}

.close {
    position: absolute;
    top: 15px;
    right: 35px;
    color: #f1f1f1;
    font-size: 40px;
    font-weight: bold;
    transition: 0.3s;
}

.close:hover,
.close:focus {
    color: #bbb;
    text-decoration: none;
    cursor: pointer;
}

/* ✅ ปรับปรุงไอคอนของบอท */
.bot-icon {
    display: inline-block;
    width: 40px;
    height: 40px;
    background: url("/static/icons/owl-icon.png") no-repeat center center;
    background-size: contain;
    margin-right: 8px;
}

/* ✅ ปรับปรุงไอคอนของผู้ใช้ */
.user-icon {
    display: inline-block;
    width: 40px;
    height: 40px;
    background: url("/static/icons/user-icon.png") no-repeat center center;
    background-size: contain;
    margin-right: 8px;
}

/* ✅ ปรับขนาดตัวอักษรในแชท */
.bot-message,
.user-message {
    display: flex;
    align-items: center;
    padding: 10px;
    border-radius: 10px;
    font-size: 16px;
}

/* ✅ ปรับแต่งปุ่มจอง */
#openBookingFormBtn {
    background: linear-gradient(135deg, #28a745 60%, #42e695 100%);
    color: white;
    border: none;
    padding: 12px 32px;
    font-size: 20px;
    cursor: pointer;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(40, 167, 69, 0.10);
    position: absolute;
    top: 50%;
    right: -32px;
    transform: translateY(-50%);
    display: block;
    transition: background 0.2s, box-shadow 0.2s;
    z-index: 10;
}

#openBookingFormBtn:hover {
    background: linear-gradient(135deg, #218838 60%, #42e695 100%);
    box-shadow: 0 4px 16px rgba(40, 167, 69, 0.18);
}

/* Responsive for mobile */
@media (max-width: 600px) {
    #openBookingFormBtn {
        position: static;
        margin: 16px auto 0 auto;
        transform: none;
        right: 0;
        top: auto;
        width: 90%;
    }
}

/* ✅ สไตล์แบบฟอร์มจอง */
#bookingFormContainer {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    justify-content: center;
    align-items: center;
}

.modal-content {
    background: white;
    padding: 20px;
    border-radius: 10px;
    width: 90%;
    max-width: 400px;
    text-align: center;
}

.modal-content input,
.modal-content textarea {
    width: 100%;
    padding: 10px;
    margin: 8px 0;
    border: 1px solid #ddd;
    border-radius: 5px;
}

.modal-content button {
    background-color: #007bff;
    color: white;
    padding: 10px;
    border: none;
    width: 100%;
    border-radius: 5px;
    font-size: 18px;
    cursor: pointer;
}

.modal-content button:hover {
    background-color: #0056b3;
}

.close {
    position: absolute;
    right: 15px;
    top: 10px;
    font-size: 24px;
    cursor: pointer;
}

/* ✅ ปรับขนาดของ chat box และส่วนที่เกี่ยวข้องลดลง 15% */
#chatPopup {
    position: fixed;
    bottom: 20px;
    right: 20px;
    /* ชิดขอบขวาของ web page และห่างจากขอบด้านขวา 20px เสมอ */
    width: 306px;
    /* ลดขนาดลง 15% จาก 360px */
    max-height: 425px;
    /* ลดขนาดลง 15% จาก 500px */
    min-height: 255px;
    /* ลดขนาดลง 15% จาก 300px */
    background: white;
    border: 1px solid #ccc;
    border-radius: 10px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.chat-footer input {
    flex: 1;
    padding: 8.5px;
    /* ลดขนาดลง 15% จาก 10px */
    font-size: 12px;
    /* ลดขนาดลง 15% จาก 14px */
}

.chat-footer button {
    padding: 8.5px 17px;
    /* ลดขนาดลง 15% จาก 10px 20px */
    font-size: 12px;
    /* ลดขนาดลง 15% จาก 14px */
}

/* เพิ่ม CSS สำหรับ #closeBookingFormBtn ให้ปุ่ม X มีขนาดใหญ่ขึ้น มองเห็นชัดเจน และเปลี่ยนสีเมื่อ hover */
#closeBookingFormBtn {
    font-size: 2.5rem !important;
    color: #888;
    font-weight: bold;
    cursor: pointer;
    position: absolute;
    top: 12px;
    right: 18px;
    z-index: 20;
    transition: color 0.2s;
}

#closeBookingFormBtn:hover {
    color: #d32f2f;
}

/* ✅ สไตล์ refinement options */
.refine-option {
    display: inline-block;
    margin: 4px 8px 4px 0;
    padding: 4px 12px;
    background: #f3f6fa;
    border-radius: 16px;
    cursor: pointer;
    border: 1px solid #e0e6ed;
    transition: background 0.2s, box-shadow 0.2s;
    font-size: 1em;
}

.refine-option:hover {
    background: #e6f0fa;
    box-shadow: 0 2px 8px rgba(80, 120, 200, 0.07);
}

/* เพิ่มสไตล์สำหรับบล็อกทัวร์ */
.tour-block {
    margin-bottom: 18px;
    padding-bottom: 8px;
    border-bottom: 1px solid #f0f0f0;
}

.tour-block:last-child {
    border-bottom: none;
}

/* เพิ่มสไตล์สำหรับปุ่มนำทางในทัวร์ */
.tour-nav-btns {
    display: flex;
    flex-direction: row;
    justify-content: flex-start;
    align-items: center;
    gap: 18px;
    margin-top: 8px;
}

.nav-btn {
    display: inline-block;
    padding: 6px 18px;
    margin: 0 8px 0 0;
    background: #f3f6fa;
    border-radius: 16px;
    cursor: pointer;
    border: 1px solid #e0e6ed;
    font-size: 1em;
    transition: background 0.2s, box-shadow 0.2s;
}

.nav-btn:last-child {
    margin-right: 0;
}

.nav-btn:hover {
    background: #e6f0fa;
    box-shadow: 0 2px 8px rgba(80, 120, 200, 0.07);
}

/* Modernize and fix table overflow for chat history */
#chat-history-table-container {
    width: 100%;
    overflow-x: auto;
    margin-top: 18px;
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 2px 12px #b6e0fe33;
    padding: 18px 0 18px 0;
}

#chat-history-table-container table {
    width: 100%;
    border-collapse: collapse;
    min-width: 800px;
    background: #fff;
    border-radius: 12px;
    overflow: hidden;
    font-size: 1em;
    box-shadow: 0 1px 6px #b6e0fe22;
}

#chat-history-table-container th,
#chat-history-table-container td {
    padding: 12px 10px;
    border-bottom: 1px solid #e3eafc;
    text-align: left;
    vertical-align: top;
    word-break: break-word;
}

#chat-history-table-container th {
    background: #e3f0ff;
    color: #2563eb;
    font-weight: 700;
    font-size: 1.05em;
}

#chat-history-table-container tr:last-child td {
    border-bottom: none;
}

@media (max-width: 900px) {
    #chat-history-table-container table {
        min-width: 600px;
        font-size: 0.98em;
    }

    .main-content {
        padding: 12px 2vw;
    }
}

@media (max-width: 600px) {
    #chat-history-table-container {
        padding: 4px 0 4px 0;
    }

    #chat-history-table-container table {
        min-width: 480px;
        font-size: 0.95em;
    }
}