/* =====================================================================
   AI CSKH HOMESTAY - CHAT WIDGET STYLE
   Ghi chú: Màu chủ đạo (--ai-cskh-primary) sẽ được ghi đè bằng inline
   style từ giá trị Admin chọn trong trang Settings (xem chat-widget.js)
   ===================================================================== */

#ai-cskh-widget-container {
    --ai-cskh-primary: #1a73e8; /* Giá trị mặc định, sẽ bị JS ghi đè */
    --ai-cskh-radius: 18px;
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 999999;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* ---------- Nút bấm tròn để mở/đóng Chat ---------- */
#ai-cskh-toggle-btn {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: none;
    background: var(--ai-cskh-primary);
    color: #fff;
    font-size: 26px;
    cursor: pointer;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

#ai-cskh-toggle-btn:hover {
    transform: scale(1.08);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

#ai-cskh-toggle-btn .ai-cskh-icon-close {
    display: none;
}

/* Khi widget đang mở, đổi icon 💬 thành ✕ */
#ai-cskh-widget-container.ai-cskh-open #ai-cskh-toggle-btn .ai-cskh-icon-chat {
    display: none;
}
#ai-cskh-widget-container.ai-cskh-open #ai-cskh-toggle-btn .ai-cskh-icon-close {
    display: inline;
}

/* ---------- Cửa sổ Chat ---------- */
#ai-cskh-chat-window {
    position: absolute;
    bottom: 76px;
    right: 0;
    width: 360px;
    max-width: calc(100vw - 32px);
    height: 520px;
    max-height: calc(100vh - 140px);
    background: #ffffff;
    border-radius: var(--ai-cskh-radius);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: translateY(12px);
    opacity: 0;
    pointer-events: none;
    transition: transform 0.25s ease, opacity 0.25s ease;
}

#ai-cskh-chat-window.ai-cskh-visible {
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
}

.ai-cskh-hidden {
    display: none !important;
}

/* ---------- Header ---------- */
#ai-cskh-header {
    background: var(--ai-cskh-primary);
    color: #fff;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-weight: 600;
    font-size: 15px;
}

#ai-cskh-close-btn {
    background: transparent;
    border: none;
    color: #fff;
    font-size: 16px;
    cursor: pointer;
    opacity: 0.85;
}
#ai-cskh-close-btn:hover {
    opacity: 1;
}

/* ---------- Khu vực tin nhắn ---------- */
#ai-cskh-messages {
    flex: 1;
    padding: 14px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: #f7f8fa;
}

.ai-cskh-msg {
    max-width: 80%;
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 14px;
    line-height: 1.45;
    word-wrap: break-word;
    white-space: pre-wrap;
}

.ai-cskh-msg-user {
    align-self: flex-end;
    background: var(--ai-cskh-primary);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.ai-cskh-msg-bot {
    align-self: flex-start;
    background: #ffffff;
    color: #222;
    border: 1px solid #e6e6e6;
    border-bottom-left-radius: 4px;
}

.ai-cskh-msg-error {
    align-self: flex-start;
    background: #fdecea;
    color: #b3261e;
    border: 1px solid #f5c6c3;
}

/* ---------- Hiệu ứng đang gõ (Typing indicator) ---------- */
#ai-cskh-typing {
    padding: 6px 14px;
    font-size: 12px;
    color: #888;
    display: flex;
    align-items: center;
    gap: 6px;
    background: #f7f8fa;
}

#ai-cskh-typing span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #aaa;
    display: inline-block;
    animation: ai-cskh-blink 1.2s infinite ease-in-out;
}
#ai-cskh-typing span:nth-child(2) { animation-delay: 0.2s; }
#ai-cskh-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes ai-cskh-blink {
    0%, 80%, 100% { opacity: 0.2; }
    40% { opacity: 1; }
}

/* ---------- Khu vực nhập liệu ---------- */
#ai-cskh-input-area {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 10px;
    border-top: 1px solid #eee;
    background: #fff;
}

#ai-cskh-input {
    flex: 1;
    resize: none;
    border: 1px solid #ddd;
    border-radius: 20px;
    padding: 10px 14px;
    font-size: 14px;
    max-height: 90px;
    outline: none;
    font-family: inherit;
}
#ai-cskh-input:focus {
    border-color: var(--ai-cskh-primary);
}

#ai-cskh-send-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: var(--ai-cskh-primary);
    color: #fff;
    font-size: 16px;
    cursor: pointer;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.2s ease;
}
#ai-cskh-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* =====================================================================
   RESPONSIVE - ĐIỆN THOẠI
   Trên màn hình nhỏ, khung chat chiếm gần toàn bộ chiều rộng/chiều cao
   ===================================================================== */
@media (max-width: 480px) {
    #ai-cskh-widget-container {
        bottom: 16px;
        right: 16px;
    }

    #ai-cskh-chat-window {
        width: calc(100vw - 24px);
        height: calc(100vh - 110px);
        right: -8px;
        bottom: 72px;
        border-radius: 16px;
    }

    #ai-cskh-toggle-btn {
        width: 54px;
        height: 54px;
        font-size: 22px;
    }
}
