/*
 * Chamspace AI Chat Widget CSS
 * Glass pillshape — matches dock exactly
 * Positioned dynamically by JS: above dock, aligned right, 16px gap
 */

/* ===============================
   CHAT WINDOW
   =============================== */
.chat-window {
    position: fixed;
    z-index: 9998;
    width: 380px;
    /* Exact dock inner glass style */
    background: linear-gradient(180deg, rgba(30,30,30,0.88) 0%, rgba(15,15,15,0.96) 100%);
    backdrop-filter: blur(30px) saturate(180%);
    -webkit-backdrop-filter: blur(30px) saturate(180%);
    border-radius: 28px;
    border: 1px solid rgba(255,255,255,0.1);
    box-shadow: 0 -10px 50px rgba(0,0,0,0.2), inset 0 1px 0 rgba(255,255,255,0.15);
    display: flex;
    flex-direction: column;
    transform: translateY(10px) scale(0.96);
    opacity: 0;
    pointer-events: none;
    transition: transform 0.35s cubic-bezier(0.76, 0, 0.24, 1),
                opacity 0.25s ease;
    font-family: 'Plus Jakarta Sans', -apple-system, sans-serif;
    overflow: hidden;
    /* Initial hidden position — JS sets actual coords */
    right: 16px;
    bottom: 120px;
    height: 520px;
    max-height: 60vh;
}
.chat-window.open {
    transform: translateY(0) scale(1);
    opacity: 1;
    pointer-events: auto;
}

/* ===============================
   HEADER
   =============================== */
.chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    flex-shrink: 0;
}
.chat-header-brand {
    display: flex;
    align-items: center;
    gap: 10px;
}
.chat-logo {
    width: 26px;
    height: auto;
    filter: brightness(0) invert(1);
}
.chat-header-text {
    display: flex;
    flex-direction: column;
    gap: 1px;
}
.chat-title {
    color: #fff;
    font-size: 14px;
    font-weight: 700;
}
.chat-subtitle {
    color: rgba(255,255,255,0.4);
    font-size: 11px;
    font-weight: 400;
}

.chat-close {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: rgba(255,255,255,0.06);
    border: none;
    color: rgba(255,255,255,0.45);
    font-size: 15px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}
.chat-close:hover {
    background: rgba(255,255,255,0.12);
    color: #fff;
}

/* ===============================
   MESSAGES
   =============================== */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.08) transparent;
}
.chat-messages::-webkit-scrollbar {
    width: 4px;
}
.chat-messages::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.08);
    border-radius: 2px;
}

/* Message row */
.chat-msg {
    display: flex;
    gap: 8px;
    max-width: 88%;
}
.chat-msg.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}
.chat-msg.ai {
    align-self: flex-start;
}

.chat-msg-avatar {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    flex-shrink: 0;
    background: rgba(255,255,255,0.06);
    color: #fff;
    position: relative;
}
.chat-msg-avatar .av-online-dot {
    position: absolute;
    bottom: -1px; right: -1px;
    width: 7px; height: 7px;
    border-radius: 50%;
    background: #22c55e;
    box-shadow: 0 0 6px rgba(34,197,94,0.6);
    animation: onlinePulse 2s ease-in-out infinite;
}
.chat-msg.user .chat-msg-avatar {
    background: rgba(255,255,255,0.12);
}

/* Bubble */
.chat-msg-bubble {
    padding: 9px 13px;
    border-radius: 16px;
    font-size: 12.5px;
    line-height: 1.5;
    word-break: break-word;
}
.chat-msg.ai .chat-msg-bubble {
    background: rgba(255,255,255,0.06);
    color: rgba(255,255,255,0.85);
    border-bottom-left-radius: 5px;
}
.chat-msg.user .chat-msg-bubble {
    background: rgba(255,255,255,0.12);
    color: #fff;
    border-bottom-right-radius: 5px;
}

.chat-msg-bubble p {
    margin: 0 0 5px 0;
}
.chat-msg-bubble p:last-child { margin-bottom: 0; }
.chat-msg-bubble ul {
    margin: 3px 0;
    padding-left: 14px;
}
.chat-msg-bubble li {
    margin-bottom: 1px;
    font-size: 11.5px;
    color: rgba(255,255,255,0.7);
}
.chat-msg-bubble a {
    color: #fff;
    text-decoration: underline;
    font-weight: 600;
}

/* Typing indicator */
.chat-msg-bubble.typing {
    display: flex;
    align-items: center;
    gap: 3px;
    padding: 11px 14px;
}
.chat-msg-bubble.typing span {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: rgba(255,255,255,0.35);
    animation: typingDot 1.4s ease-in-out infinite;
}
.chat-msg-bubble.typing span:nth-child(2) { animation-delay: 0.2s; }
.chat-msg-bubble.typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingDot {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-4px); }
}

/* ===============================
   INPUT AREA
   =============================== */
.chat-input-area {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    border-top: 1px solid rgba(255,255,255,0.08);
    flex-shrink: 0;
}

.chat-input {
    flex: 1;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 100px;
    padding: 9px 14px;
    color: #fff;
    font-size: 12.5px;
    font-family: 'Plus Jakarta Sans', sans-serif;
    outline: none;
    transition: border-color 0.2s;
}
.chat-input::placeholder { color: rgba(255,255,255,0.25); }
.chat-input:focus { border-color: rgba(255,255,255,0.2); }

.chat-send {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255,255,255,0.08);
    border: none;
    color: rgba(255,255,255,0.5);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.2s;
}
.chat-send:hover { background: rgba(255,255,255,0.18); color: #fff; }


/* ===============================
   BUBBLE TIP — "Chat với Chamspace"
   =============================== */
.chat-bubble-tip {
    position: fixed;
    z-index: 101;
    cursor: pointer;
    animation: bubbleFloat 3s ease-in-out infinite;
    -webkit-tap-highlight-color: transparent !important;
    pointer-events: auto;
}
.chat-bubble-tip .cbt-inner {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255,255,255,0.92);
    backdrop-filter: blur(16px) saturate(180%);
    -webkit-backdrop-filter: blur(16px) saturate(180%);
    border-radius: 100px;
    padding: 8px 16px;
    white-space: nowrap;
    border: 1px solid rgba(0,0,0,0.06);
    box-shadow: 0 4px 20px rgba(0,0,0,0.08), 0 1px 3px rgba(0,0,0,0.04);
    position: relative;
}
.chat-bubble-tip .cbt-icon { font-size: 18px; line-height: 1; }
.chat-bubble-tip .cbt-text {
    font-size: 13px;
    font-weight: 700;
    color: #1a1a1a;
    font-family: 'Plus Jakarta Sans', -apple-system, sans-serif;
    letter-spacing: 0.02em;
}
/* Arrow pointing down to dock button */
.chat-bubble-tip .cbt-inner::after {
    content: '';
    position: absolute;
    bottom: -6px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-top: 6px solid rgba(255,255,255,0.92);
}
/* Hide when dock or menu expands */
body.dock-open .chat-bubble-tip,
body.menu-open .chat-bubble-tip { display: none !important; }

@keyframes bubbleFloat {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-6px); }
}

/* Desktop: slightly bigger bubble */
@media (min-width: 1025px) {
    .chat-bubble-tip { transform: scale(1.2); transform-origin: center bottom; }
    .chat-bubble-tip .cbt-inner { padding: 9px 18px; border-radius: 100px; }
    .chat-bubble-tip .cbt-text { font-size: 14px; }
}
/* Mobile: smaller bubble */
@media (max-width: 1024px) {
    .chat-bubble-tip { display: none !important; }
}

/* ===============================
   MOBILE — same pillshape as desktop, JS positions above dock
   =============================== */
@media (max-width: 1024px) {
    .chat-window {
        width: auto !important;
        transform: translateY(10px) scale(0.96);
        opacity: 0;
    }
    .chat-window.open {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
    .chat-header { padding: 12px 16px; }
    .chat-messages { padding: 10px 12px; }
    .chat-msg { max-width: 88%; }
    .chat-input { font-size: 16px; } /* prevent iOS zoom */
}

@keyframes onlinePulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* ======================================= */
/*   CHAT CTA BUTTON — Nút tư vấn         */
/*   Global: onclick="openHeroPopup()"     */
/* ======================================= */
.chat-cta-btn {
    background: #e20612;
    color: #fff !important;
    border: none;
    border-radius: 100px;
    padding: 12px 28px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    display: inline-block;
    text-decoration: none;
    transition: background 0.2s, transform 0.15s, box-shadow 0.2s;
    box-shadow: 0 4px 16px rgba(226,6,18,0.3);
    letter-spacing: 0.02em;
}
.chat-cta-btn:hover {
    background: #ff1a27;
    transform: translateY(-2px);
    box-shadow: 0 6px 22px rgba(226,6,18,0.4);
}
.chat-cta-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(226,6,18,0.3);
}
