/* ── FAB ── */
#chatbot-fab {
    position: fixed;
    bottom: 16px;
    right: 16px;
    width: 200px;
    height: auto;
    border-radius: 0;
    background: transparent;
    border: none;
    outline: none;
    cursor: pointer;
    z-index: 9999;
    padding: 0;
    margin: 0;
    box-shadow: none;
    transition: transform 0.2s;
    overflow: visible;
    display: block;
    line-height: 0;
    font-size: 0;
    -webkit-tap-highlight-color: transparent;
}

#chatbot-fab:focus,
#chatbot-fab:active {
    outline: none;
    box-shadow: none;
}

#chatbot-fab:hover {
    transform: scale(1.08);
}

#chatbot-fab::before,
#chatbot-fab::after {
    display: none !important;
    content: none !important;
}

#chatbot-fab img {
    width: 200px;
    height: auto;
    border-radius: 0;
    display: block;
    object-fit: contain;
    margin: 0;
    padding: 0;
    filter: drop-shadow(0 4px 12px rgba(0,0,0,0.25));
}

/* ── Box ── */
#chatbot-box {
    position: fixed;
    bottom: 120px;
    right: 24px;
    width: 33vw;
    min-width: 340px;
    max-width: 480px;
    height: 70vh;
    max-height: 700px;
    background: #fff;
    border-radius: 18px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.22);
    display: none;
    flex-direction: column;
    z-index: 9998;
    font-family: 'Kanit', sans-serif;
    overflow: hidden;
}

#chatbot-box.open {
    display: flex;
}

/* ── Header ── */
#chatbot-header {
    background: #3CB879;
    color: #fff;
    padding: 12px 14px;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
    border-radius: 18px 18px 0 0;
}

#chatbot-header-avatar {
    width: 150px;
    height: auto;
    border-radius: 0;
    flex-shrink: 0;
    overflow: visible;
    line-height: 0;
    font-size: 0;
}

#chatbot-header-avatar img {
    width: 150px !important;
    height: auto !important;
    object-fit: contain;
    display: block !important;
    border-radius: 0;
    margin: 0;
    padding: 0;
    max-width: none;
    filter: drop-shadow(0 2px 6px rgba(0,0,0,0.2));
}

#chatbot-header-text {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1px;
}

#chatbot-header-title {
    font-size: 14px;
    font-weight: 700;
    line-height: 1.2;
}

#chatbot-header-subtitle {
    font-size: 11px;
    opacity: 0.85;
    line-height: 1.2;
}

#chatbot-close {
    background: #e74c3c;
    border: none;
    color: #fff;
    font-size: 25px;
    cursor: pointer;
    line-height: 1;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-weight: 700;
    padding-top: 0;
}

#chatbot-close:hover {
    background: #c0392b;
}

/* ── Messages ── */
#chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 14px 12px 10px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-height: 0;
    background: #fff;
}

.cb-msg-row {
    display: flex;
    align-items: flex-end;
    gap: 6px;
}

.cb-msg-row.bot {
    align-self: flex-start;
}

.cb-msg-row.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.cb-avatar-sm {
    width: 80px;
    height: auto;
    border-radius: 0;
    flex-shrink: 0;
    overflow: visible;
    line-height: 0;
    font-size: 0;
}

.cb-avatar-sm img {
    width: 80px !important;
    height: auto !important;
    object-fit: contain;
    display: block !important;
    border-radius: 0;
    margin: 0;
    padding: 0;
    max-width: none;
    filter: drop-shadow(0 1px 4px rgba(0,0,0,0.15));
}

.cb-bubble-wrap {
    display: flex;
    flex-direction: column;
    gap: 2px;
    max-width: 76%;
}

.cb-bubble-wrap.user {
    align-items: flex-end;
}

.cb-bubble {
    padding: 9px 13px;
    border-radius: 14px;
    font-size: 13px;
    line-height: 1.55;
    white-space: pre-wrap;
    word-break: break-word;
}

.cb-bubble.bot {
    background: #f0f4f8;
    color: #222;
    border-bottom-left-radius: 3px;
}

.cb-bubble.user {
    background: #3CB879;
    color: #fff;
    border-bottom-right-radius: 3px;
}

.cb-time {
    font-size: 10px;
    color: #aaa;
    padding: 0 4px;
}

/* ── Quick replies (category grid) ── */
#chatbot-quickreply {
    padding: 10px 10px 6px;
    background: #f8faf9;
    border-top: 1px solid #ececec;
    flex-shrink: 0;
}

#chatbot-quickreply .cb-qr-label {
    font-size: 11px;
    color: #888;
    margin-bottom: 8px;
    padding-left: 2px;
}

#chatbot-qr-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 7px;
}
#chatbot-qr-grid.cols-1 { grid-template-columns: repeat(1, 1fr); }
#chatbot-qr-grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
#chatbot-qr-grid.cols-3 { grid-template-columns: repeat(3, 1fr); }


.cb-qr-item {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px 4px 7px;
    cursor: pointer;
    font-size: 11px;
    color: #333;
    font-family: 'Kanit', sans-serif;
    transition: background 0.15s, border-color 0.15s;
    text-align: center;
    gap: 5px;
    line-height: 1.35;
}

.cb-qr-item:hover {
    background: #eafaf3;
    border-color: #3CB879;
    color: #2a9060;
}

.cb-qr-icon {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 17px;
    flex-shrink: 0;
}

/* ── Input bar ── */
#chatbot-input-bar {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 10px 10px;
    background: #fff;
    border-top: 1px solid #ececec;
    flex-shrink: 0;
}

#chatbot-attach-btn,
#chatbot-mic-btn,
#chatbot-send-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    color: #aaa;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: color 0.15s;
}

#chatbot-attach-btn:hover,
#chatbot-mic-btn:hover {
    color: #666;
}

#chatbot-send-btn {
    color: #3CB879;
    font-size: 20px;
}

#chatbot-send-btn:hover {
    color: #2a9060;
}

#chatbot-input {
    flex: 1;
    border: none;
    outline: none;
    font-family: 'Kanit', sans-serif;
    font-size: 13px;
    color: #333;
    background: transparent;
    padding: 4px 0;
}

#chatbot-input::placeholder {
    color: #bbb;
}

/* ── Sub-questions list (shown in messages area) ── */
.cb-q-list {
    display: flex;
    flex-direction: column;
    gap: 5px;
    align-self: flex-start;
    max-width: 90%;
}

.cb-q-btn {
    background: #fff;
    border: 1px solid #3CB879;
    color: #3CB879;
    border-radius: 8px;
    padding: 6px 12px;
    font-size: 12px;
    cursor: pointer;
    text-align: left;
    font-family: 'Kanit', sans-serif;
    transition: background 0.15s, color 0.15s;
    white-space: normal;
    word-break: break-word;
}

.cb-q-btn:hover {
    background: #3CB879;
    color: #fff;
}

.cb-q-btn.back {
    border-color: #aaa;
    color: #666;
    font-size: 11px;
}

.cb-q-btn.back:hover {
    background: #eee;
    color: #333;
}

.cb-q-btn.home {
    border-color: #888;
    color: #444;
    font-size: 11px;
}

.cb-q-btn.home:hover {
    background: #f0f0f0;
    color: #000;
}

/* ── Typing indicator ── */
.cb-typing {
    display: flex;
    gap: 4px;
    align-items: center;
    padding: 10px 14px;
    background: #f0f4f8;
    border-radius: 14px;
    border-bottom-left-radius: 3px;
    width: fit-content;
}

.cb-typing span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #aaa;
    animation: cb-bounce 1.2s infinite ease-in-out;
}

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

@keyframes cb-bounce {
    0%, 80%, 100% { transform: scale(0.7); opacity: 0.5; }
    40% { transform: scale(1); opacity: 1; }
}
