﻿/* Chatbox hỗ trợ trực tuyến (Views\Shared\_ChatBox.cshtml + Contents\JS\chatbox.js) — màu lấy từ nsx\tokens.css */
.ckb-widget { position: fixed; right: var(--sp-4); bottom: var(--sp-6); z-index: 950; font-family: var(--font); }

/* ---- Nút tròn mở chat ---- */
.ckb-icon {
    position: relative;
    width: 56px; height: 56px; border-radius: 50%;
    background-color: #fff; color: var(--surface);
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; box-shadow: var(--shadow);
    transition: background-color var(--dur) var(--ease);
    animation: ckb-pulse 2.4s infinite, ckb-fab-shake 6s ease-in-out infinite;
}
.ckb-icon:hover { background-color: var(--accent-2); }
.ckb-icon:focus-visible { outline: none; box-shadow: var(--focus-ring); }

.ckb-icon-dot {
    position: absolute; top: 50%; right: -5px;
    width: 12px; height: 12px; border-radius: 50%;
    background: var(--accent-2); border: 2px solid var(--bg-0);
    animation: ckb-dot-pulse 2s infinite;
}

.ckb-widget.ckb-open .ckb-icon { animation: none; }

@keyframes ckb-pulse {
    0% { box-shadow: 0 0 0 0 rgba(32, 232, 90, .55); }
    50% { box-shadow: 0 0 0 12px rgba(32, 232, 90, .15); }
    100% { box-shadow: 0 0 0 22px rgba(32, 232, 90, 0); }
}

@keyframes ckb-dot-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(32, 232, 90, .55); }
    50% { box-shadow: 0 0 0 5px rgba(32, 232, 90, 0); }
}

/* Lắc nhẹ: mỗi chu kỳ 6s chỉ lắc ~1s đầu (±8°, biên độ giảm dần như chuông rung), phần còn lại đứng yên */
@keyframes ckb-fab-shake {
    0%, 20%, 100% { transform: rotate(0); }
    3%  { transform: rotate(-8deg); }
    6%  { transform: rotate(8deg); }
    9%  { transform: rotate(-6deg); }
    12% { transform: rotate(5deg); }
    15% { transform: rotate(-3deg); }
    18% { transform: rotate(2deg); }
}

/* Máy bật "giảm chuyển động" (Windows: Animation effects tắt): tắt vòng sáng nhấp nháy, nhưng VẪN giữ cú lắc nhẹ của icon
   (chỉ ~1s mỗi 6s, ±8°) theo yêu cầu khách. !important để thắng quy tắc tắt animation toàn trang trong nsx/base.css. */
@media (prefers-reduced-motion: reduce) {
    .ckb-icon-dot, .ckb-dots span { animation: none; }
    .ckb-widget:not(.ckb-open) .ckb-icon { animation: ckb-fab-shake 6s ease-in-out infinite !important; }
}

/* ---- Bong bóng lời chào ---- */
.ckb-bubble {
    position: absolute; right: 64px; bottom: 0; width: 210px;
    background: var(--surface); color: var(--text-2);
    border: 1px solid var(--accent-line); border-radius: var(--radius-lg);
    padding: var(--sp-3) var(--sp-6) var(--sp-3) var(--sp-3);
    box-shadow: var(--shadow);
    font-size: var(--fs-sm); line-height: 1.45;
}
.ckb-bubble-close {
    position: absolute; top: var(--sp-1); right: var(--sp-2); cursor: pointer;
    color: var(--muted); font-size: var(--fs-base); line-height: 1;
}
.ckb-bubble-close:hover { color: var(--text); }

/* ---- Khung chat: cùng theme trang Liên hệ (Views/Contact) — đầu khung nền xanh đậm chữ in hoa + viền dưới --surface,
   thân nền kem, ô nhập nền kem đậm, nút nền --surface chữ trắng, chữ tông đậm (--cream-ink) ---- */
.ckb-panel {
    position: absolute; right: 0; bottom: 72px;
    width: 340px; max-width: calc(100vw - 2 * var(--sp-4));
    height: 480px; max-height: 70vh;
    background: var(--cream); color: var(--cream-ink-2);
    border: 1px solid var(--surface); border-radius: var(--radius-lg); overflow: hidden;
    box-shadow: var(--shadow-lg);
    display: flex; flex-direction: column;
}

.ckb-header {
    background-color: var(--bg-1); color: var(--text);
    border-bottom: 3px solid var(--surface);
    padding: var(--sp-3) var(--sp-4); font-weight: var(--fw-bold); font-size: var(--fs-sm);
    letter-spacing: .03em; text-transform: uppercase;
    display: flex; justify-content: space-between; align-items: center;
}
.ckb-close { cursor: pointer; font-size: var(--fs-h4); line-height: 1; color: var(--text-2); }
.ckb-close:hover { color: var(--accent); }

.ckb-body { flex: 1; overflow-y: auto; padding: var(--sp-4); }

.ckb-form-info { display: flex; flex-direction: column; justify-content: center; }

.ckb-loichao { font-size: var(--fs-sm); color: var(--cream-ink-2); margin: 0 0 var(--sp-3); }

.ckb-input {
    width: 100%; box-sizing: border-box;
    border: 1px solid var(--cream-line); border-radius: var(--radius);
    background: var(--cream-2); color: var(--cream-ink);
    padding: var(--sp-2) var(--sp-3); font-size: var(--fs-sm); margin-bottom: var(--sp-2);
    transition: border-color var(--dur-fast), box-shadow var(--dur-fast);
}
.ckb-input::placeholder { color: var(--cream-ink-2); opacity: .75; }
.ckb-input:hover { border-color: var(--surface); }
.ckb-input:focus { outline: none; border-color: var(--surface); box-shadow: 0 0 0 3px var(--cream-line); }
.ckb-textarea { resize: vertical; min-height: 70px; }

.ckb-btn-submit {
    width: 100%; background-color: var(--surface); color: var(--text); border: 1px solid var(--surface);
    border-radius: var(--radius); padding: var(--sp-2) var(--sp-3);
    font-size: var(--fs-sm); font-weight: var(--fw-bold);
    cursor: pointer; margin-bottom: var(--sp-2);
    transition: background-color var(--dur-fast), border-color var(--dur-fast);
}
.ckb-btn-submit:hover { background-color: var(--surface-2); border-color: var(--surface-2); }
.ckb-btn-submit:focus-visible { outline: none; box-shadow: var(--focus-ring); }

/* Zalo / Gọi điện: nút viền xanh --surface như nút Chat Zalo / Facebook trang Liên hệ */
.ckb-contact-row { display: flex; gap: var(--sp-2); margin-bottom: var(--sp-2); }
.ckb-btn-contact {
    flex: 1; display: flex; align-items: center; justify-content: center; gap: var(--sp-2);
    border: 1px solid var(--surface); border-radius: var(--radius);
    padding: var(--sp-2); background: transparent; color: var(--surface);
    font-size: var(--fs-xs); font-weight: var(--fw-bold); text-decoration: none;
    cursor: pointer; transition: background-color var(--dur-fast), color var(--dur-fast);
}
.ckb-btn-contact svg { color: currentColor; }
.ckb-btn-contact:hover { background: var(--surface); color: var(--text); }
.ckb-btn-contact:focus-visible { outline: none; box-shadow: var(--focus-ring); }

.ckb-btn-google {
    width: 100%; background: transparent; color: var(--cream-ink-2); border: 1px solid var(--cream-line);
    border-radius: var(--radius); padding: var(--sp-2); font-size: var(--fs-xs); cursor: pointer;
}
.ckb-btn-google:hover { border-color: var(--surface); color: var(--surface); }

.ckb-error { color: var(--danger); font-size: var(--fs-xs); margin-top: var(--sp-2); }

/* ---- Hội thoại ---- */
.ckb-chat { display: flex; flex-direction: column; padding: 0; }

.ckb-lienhe-banner {
    background: var(--cream-2); color: var(--cream-ink); font-size: var(--fs-xs);
    padding: var(--sp-2) var(--sp-3); border-bottom: 1px solid var(--cream-line);
}
.ckb-lienhe-banner a { color: var(--surface); font-weight: var(--fw-bold); }

.ckb-messages { flex: 1; overflow-y: auto; padding: var(--sp-3); }

.ckb-msg {
    max-width: 85%; padding: var(--sp-2) var(--sp-3); border-radius: var(--radius-lg);
    font-size: var(--fs-sm); line-height: 1.45; margin-bottom: var(--sp-2); word-wrap: break-word;
}
.ckb-msg a { color: inherit; text-decoration: underline; font-weight: var(--fw-semibold); }
.ckb-msg-khach {
    background-color: var(--surface); color: var(--text);
    margin-left: auto; border-bottom-right-radius: var(--radius-sm);
}
.ckb-msg-ai {
    background: var(--cream-2); color: var(--cream-ink);
    border: 1px solid var(--cream-line);
    margin-right: auto; border-bottom-left-radius: var(--radius-sm);
}
.ckb-msg-ai a, .ckb-msg-admin a { color: var(--surface); }
.ckb-msg-admin {
    background: var(--cream-2); color: var(--cream-ink);
    border-left: 3px solid var(--surface);
    margin-right: auto; border-bottom-left-radius: var(--radius-sm);
}
.ckb-msg-loi {
    background: rgba(255, 107, 107, .12); color: var(--cream-ink);
    border: 1px solid var(--danger);
    margin-right: auto; border-bottom-left-radius: var(--radius-sm);
}

.ckb-loading { padding: 0 var(--sp-3) var(--sp-2); font-size: var(--fs-xs); color: var(--cream-ink-2); }

.ckb-dots { display: inline-block; margin-left: 3px; }
.ckb-dots span {
    display: inline-block; width: 4px; height: 4px; margin-left: 2px;
    border-radius: 50%; background: var(--surface);
    animation: ckb-dot-bounce 1.2s infinite ease-in-out both;
}
.ckb-dots span:nth-child(2) { animation-delay: .2s; }
.ckb-dots span:nth-child(3) { animation-delay: .4s; }

@keyframes ckb-dot-bounce {
    0%, 60%, 100% { transform: translateY(0); opacity: .4; }
    30% { transform: translateY(-3px); opacity: 1; }
}

.ckb-inputrow {
    display: flex; align-items: center; gap: var(--sp-2);
    padding: var(--sp-2) var(--sp-3); border-top: 1px solid var(--cream-line);
    background: var(--cream);
}
.ckb-inputrow .ckb-input { margin-bottom: 0; }
.ckb-btn-send {
    width: 40px; height: 40px; border-radius: 50%; border: 0; flex: none;
    background-color: var(--surface); color: var(--text); cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: background-color var(--dur-fast);
}
.ckb-btn-send:hover { background-color: var(--surface-2); }
.ckb-btn-send:focus-visible { outline: none; box-shadow: var(--focus-ring); }

/* Thanh cuộn trong khung chat */
.ckb-body, .ckb-messages { scrollbar-width: thin; scrollbar-color: var(--cream-line) transparent; }

@media (max-width: 575.98px) {
    .ckb-widget { right: var(--sp-3); bottom: var(--sp-4); }
    .ckb-panel { width: calc(100vw - 2 * var(--sp-3)); right: 0; }
}

/* Chữ nhỏ in đậm → Roboto (quy ước ở cuối nsx/components.css) */
.ckb-header, .ckb-btn-submit, .ckb-btn-contact, .ckb-lienhe-banner a, .ckb-msg a,
:where(.ckb-bubble, .ckb-loichao, .ckb-error, .ckb-lienhe-banner, .ckb-msg, .ckb-loading) :is(strong, b) { font-family: var(--font-sm-bold); }
