/* iSPACE Chatbot Widget — dùng lại biến màu :root đã định nghĩa trong từng trang */

.ispace-chat-fab {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--accent);
    color: #FFF;
    border: none;
    box-shadow: 0 10px 26px rgba(28,43,58,0.28);
    cursor: pointer;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    transition: transform 0.2s, background 0.25s;
}

.ispace-chat-fab:hover { background: var(--accent-dark); transform: scale(1.06); }
.ispace-chat-fab .fa-xmark { display: none; }
.ispace-chat-fab.open .fa-comment-dots { display: none; }
.ispace-chat-fab.open .fa-xmark { display: block; }

.ispace-chat-fab::before {
    content: "";
    position: absolute;
    inset: -6px;
    border-radius: 50%;
    border: 2px solid var(--accent);
    opacity: 0.55;
    animation: ispace-pulse 2.2s ease-out infinite;
}

.ispace-chat-fab.open::before { animation: none; opacity: 0; }

@keyframes ispace-pulse {
    0% { transform: scale(1); opacity: 0.55; }
    100% { transform: scale(1.35); opacity: 0; }
}

.ispace-chat-panel {
    position: fixed;
    bottom: 98px;
    right: 24px;
    width: 368px;
    max-width: calc(100vw - 32px);
    height: 540px;
    max-height: calc(100vh - 150px);
    background: var(--cream);
    border: 1px solid var(--border);
    border-radius: 18px;
    box-shadow: 0 22px 54px rgba(28,43,58,0.24);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 2000;
    opacity: 0;
    transform: translateY(16px) scale(0.98);
    pointer-events: none;
    transition: opacity 0.22s ease, transform 0.22s ease;
}

.ispace-chat-panel.open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

.ispace-chat-header {
    background: var(--ink);
    color: #E9D6BA;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.ispace-chat-header img {
    height: 30px; width: 30px;
    border-radius: 50%;
    background: #FFF;
    padding: 3px;
    display: block;
}

.ispace-chat-header .ispace-chat-titles { line-height: 1.25; }
.ispace-chat-header .title { color: #FFF; font-weight: 700; font-size: 0.98rem; }
.ispace-chat-header .subtitle { font-size: 0.72rem; color: var(--accent-yellow); display: flex; align-items: center; gap: 5px; }
.ispace-chat-header .subtitle .dot { width: 7px; height: 7px; border-radius: 50%; background: #6FCF97; display: inline-block; }

.ispace-chat-close {
    margin-left: auto;
    background: none;
    border: none;
    color: #E9D6BA;
    font-size: 1.05rem;
    cursor: pointer;
    padding: 6px;
}
.ispace-chat-close:hover { color: #FFF; }

.ispace-chat-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: var(--bg-sky);
}

.ispace-msg {
    max-width: 84%;
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 0.86rem;
    line-height: 1.55;
    white-space: pre-line;
}

.ispace-msg.bot {
    align-self: flex-start;
    background: #FFF;
    border: 1px solid var(--border);
    color: var(--ink);
    border-bottom-left-radius: 4px;
}

.ispace-msg.user {
    align-self: flex-end;
    background: var(--accent);
    color: #FFF;
    border-bottom-right-radius: 4px;
}

.ispace-msg.typing { display: flex; gap: 4px; align-items: center; padding: 12px 16px; }
.ispace-msg.typing span {
    width: 6px; height: 6px; border-radius: 50%;
    background: var(--ink-faint);
    display: inline-block;
    animation: ispace-typing 1s infinite ease-in-out;
}
.ispace-msg.typing span:nth-child(2) { animation-delay: 0.15s; }
.ispace-msg.typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes ispace-typing {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
    30% { transform: translateY(-4px); opacity: 1; }
}

.ispace-chat-cta {
    align-self: flex-start;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    background: var(--accent);
    color: #FFF !important;
    border-radius: 30px;
    font-weight: 700;
    font-size: 0.82rem;
    text-decoration: none;
    box-shadow: 0 8px 18px rgba(224,123,29,0.35);
}
.ispace-chat-cta:hover { background: var(--accent-dark); }
.ispace-chat-cta.outline {
    background: transparent;
    border: 2px solid var(--ink);
    color: var(--ink) !important;
    box-shadow: none;
}
.ispace-chat-cta.outline:hover { border-color: var(--accent); color: var(--accent) !important; }

.ispace-chat-quickreplies {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px 16px;
    background: #FFF;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}

.ispace-chip {
    border: 1.5px solid var(--accent);
    background: #FFF;
    color: var(--accent-dark);
    padding: 7px 13px;
    border-radius: 30px;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
    font-family: inherit;
}
.ispace-chip:hover { background: var(--accent); color: #FFF; }
.ispace-chip.primary { background: var(--accent); color: #FFF; }
.ispace-chip.primary:hover { background: var(--accent-dark); }

.ispace-chat-footer {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border-top: 1px solid var(--border);
    background: #FFF;
    flex-shrink: 0;
}

.ispace-chat-footer input {
    flex: 1;
    border: 1px solid var(--border);
    border-radius: 30px;
    padding: 9px 14px;
    font-size: 0.85rem;
    font-family: inherit;
    outline: none;
    color: var(--ink);
    background: var(--bg-sky);
}
.ispace-chat-footer input:focus { border-color: var(--accent); }

.ispace-chat-footer button {
    width: 38px; height: 38px;
    border-radius: 50%;
    border: none;
    background: var(--accent);
    color: #FFF;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 0.9rem;
}
.ispace-chat-footer button:hover { background: var(--accent-dark); }

@media (max-width: 480px) {
    .ispace-chat-panel { right: 16px; bottom: 90px; width: calc(100vw - 32px); height: calc(100vh - 170px); }
    .ispace-chat-fab { right: 16px; bottom: 16px; }
}
