/* css/chatbox.css
   กล่องแชท AI แบบลอย (floating) ที่ใส่ไว้ทุกหน้า
   คลาสทั้งหมดขึ้นต้นด้วย chatbox_ */

/* ซ่อนองค์ประกอบ เผื่อกรณีโหลด Tailwind ไม่ได้ */
.chatbox_overlay.hidden,
.chatbox_context.hidden,
.chatbox_foot.hidden {
    display: none;
}

/* ---------- ปุ่มลอยมุมขวาล่าง ---------- */
.chatbox_fab {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 60;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 18px 12px 14px;
    border: 1px solid #c8a04a;
    border-radius: 999px;
    background-image: linear-gradient(135deg, #2a2412 0%, #171a21 100%);
    color: #e6e8ec;
    font-weight: 700;
    font-size: 14px;
    cursor: pointer;
    box-shadow: 0 10px 30px rgba(0, 0, 0, .55);
}

.chatbox_fab:hover {
    border-color: #ddb45c;
    box-shadow: 0 10px 34px rgba(200, 160, 74, .35);
}

.chatbox_fab-dot {
    position: relative;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background-color: #6fbf7a;
}

/* วงกลมกระพริบแบบสัญญาณเรดาร์ */
.chatbox_fab-dot::after {
    content: "";
    position: absolute;
    inset: -6px;
    border: 1px solid #6fbf7a;
    border-radius: 50%;
    animation: chatbox_radar 2s ease-out infinite;
}

@keyframes chatbox_radar {
    0% { transform: scale(.6); opacity: .9; }
    100% { transform: scale(1.5); opacity: 0; }
}

.chatbox_fab-label span {
    display: block;
    font-size: 11px;
    font-weight: 400;
    letter-spacing: 1px;
    color: #c8a04a;
}

/* ---------- ฉากหลังตอนเปิด modal ---------- */
.chatbox_overlay {
    position: fixed;
    inset: 0;
    z-index: 70;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background-color: rgba(6, 8, 12, .72);
    backdrop-filter: blur(4px);
    animation: chatbox_fade .18s ease-out;
}

@keyframes chatbox_fade {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* ---------- ตัว modal ---------- */
.chatbox_modal {
    width: 100%;
    max-width: 820px;
    max-height: 92vh;
    display: flex;
    flex-direction: column;
    border: 1px solid #3a3425;
    border-radius: 14px;
    background-image: linear-gradient(180deg, #151922 0%, #10131a 100%);
    box-shadow: 0 30px 80px rgba(0, 0, 0, .7);
    overflow: hidden;
    animation: chatbox_rise .22s ease-out;
}

@keyframes chatbox_rise {
    from { transform: translateY(18px) scale(.98); opacity: 0; }
    to { transform: translateY(0) scale(1); opacity: 1; }
}

.chatbox_header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    border-bottom: 1px solid #2a2f3a;
    background-image:
        repeating-linear-gradient(90deg, rgba(200, 160, 74, .07) 0 2px, transparent 2px 6px),
        linear-gradient(135deg, #22200f 0%, #171a21 100%);
}

.chatbox_badge {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: 1px solid #c8a04a;
    border-radius: 8px;
    color: #c8a04a;
    font-size: 18px;
}

.chatbox_header-title {
    font-size: 17px;
    font-weight: 800;
    letter-spacing: 1px;
}

.chatbox_header-sub {
    font-size: 12px;
    color: #8b93a3;
}

.chatbox_close {
    margin-left: auto;
    width: 34px;
    height: 34px;
    border: 1px solid #2a2f3a;
    border-radius: 8px;
    background: transparent;
    color: #b9bfcc;
    font-size: 18px;
    cursor: pointer;
}

.chatbox_close:hover {
    border-color: #e2765a;
    color: #e2765a;
}

.chatbox_context {
    padding: 8px 16px;
    border-bottom: 1px solid #2a2f3a;
    background-color: #1a1e27;
    font-size: 13px;
    color: #b9bfcc;
}

.chatbox_context b {
    color: #c8a04a;
}

/* ---------- พื้นที่ข้อความ ---------- */
.chatbox_log {
    flex: 1;
    min-height: 240px;
    overflow-y: auto;
    padding: 16px;
    background-image: radial-gradient(circle at 20% 0%, rgba(200, 160, 74, .06), transparent 55%);
}

.chatbox_bubble {
    max-width: 86%;
    margin-bottom: 12px;
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.85;
    white-space: pre-wrap;
}

.chatbox_bubble--ai {
    background-color: #1c2230;
    border: 1px solid #2a2f3a;
    border-left: 3px solid #c8a04a;
}

.chatbox_bubble--me {
    margin-left: auto;
    background-color: #332b16;
    border: 1px solid #5a4a20;
}

.chatbox_who {
    font-size: 11px;
    letter-spacing: 1px;
    color: #8b93a3;
    margin-bottom: 3px;
}

/* จุดสามจุดตอน AI กำลังคิด */
.chatbox_typing span {
    display: inline-block;
    width: 6px;
    height: 6px;
    margin-right: 4px;
    border-radius: 50%;
    background-color: #c8a04a;
    animation: chatbox_blink 1.2s infinite;
}

.chatbox_typing span:nth-child(2) { animation-delay: .2s; }
.chatbox_typing span:nth-child(3) { animation-delay: .4s; }

@keyframes chatbox_blink {
    0%, 100% { opacity: .25; }
    50% { opacity: 1; }
}

/* ---------- ส่วนล่าง ---------- */
.chatbox_foot {
    padding: 12px 16px 16px;
    border-top: 1px solid #2a2f3a;
    background-color: #141821;
}

.chatbox_quick {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    margin-bottom: 10px;
}

.chatbox_quick-item {
    padding: 5px 11px;
    border: 1px solid #2a2f3a;
    border-radius: 999px;
    background-color: #171a21;
    color: #b9bfcc;
    font-size: 12px;
    cursor: pointer;
}

.chatbox_quick-item:hover {
    border-color: #c8a04a;
    color: #e6e8ec;
}

.chatbox_form {
    display: flex;
    gap: 8px;
}

.chatbox_input {
    flex: 1;
    padding: 11px 16px;
    border: 1px solid #2a2f3a;
    border-radius: 999px;
    background-color: #0d1016;
    color: #e6e8ec;
    font-size: 14px;
}

.chatbox_input:focus {
    outline: none;
    border-color: #c8a04a;
}

.chatbox_send {
    padding: 11px 26px;
    border: none;
    border-radius: 999px;
    background-color: #c8a04a;
    color: #1a1407;
    font-weight: 700;
    cursor: pointer;
}

.chatbox_send:disabled {
    opacity: .5;
    cursor: wait;
}

.chatbox_status {
    margin-top: 6px;
    min-height: 16px;
    font-size: 12px;
    color: #8b93a3;
}

/* ---------- หน้าจอตอนยังไม่ล็อกอิน ---------- */
.chatbox_lock {
    padding: 40px 24px;
    text-align: center;
}

.chatbox_lock-title {
    font-size: 18px;
    font-weight: 700;
}

.chatbox_lock-text {
    margin: 8px auto 0;
    max-width: 420px;
    font-size: 14px;
    line-height: 1.8;
    color: #8b93a3;
}

.chatbox_lock-box {
    margin-top: 18px;
    display: flex;
    justify-content: center;
}

/* ---------- จอเล็ก ---------- */
@media (max-width: 640px) {
    .chatbox_fab {
        right: 14px;
        bottom: 14px;
        padding: 10px 14px;
    }

    .chatbox_fab-label {
        display: none;
    }

    .chatbox_modal {
        max-height: 100vh;
        height: 100%;
        border-radius: 0;
    }

    .chatbox_overlay {
        padding: 0;
    }
}
