/* Khung chat trực tuyến phía khách. Tiền tố lc- để không đụng CSS của site. */
.lc {
    --lc-blue: #1a73e8;
    --lc-blue-2: #4aa3ff;
    --lc-text: #1f2a37;
    --lc-muted: #6b7a8c;
    --lc-line: #e5e9ef;
    position: fixed; z-index: 10000; right: 16px; bottom: 16px;
    width: 380px; max-width: calc(100vw - 24px);
    height: min(640px, calc(100vh - 32px)); height: min(640px, calc(100dvh - 32px));
    display: flex; flex-direction: column; overflow: hidden;
    background: #fff; border-radius: 18px; color: var(--lc-text);
    box-shadow: 0 18px 60px rgba(15, 40, 80, .28), 0 2px 10px rgba(15, 40, 80, .12);
    font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif; font-size: 14px;
    animation: lc-in .22s ease-out;
}
.lc[hidden] { display: none; }
.lc *, .lc *::before, .lc *::after { box-sizing: border-box; }
.lc button { font-family: inherit; cursor: pointer; }
.lc :focus-visible { outline: 2px solid var(--lc-blue); outline-offset: 2px; }
@keyframes lc-in { from { opacity: 0; transform: translateY(14px) scale(.98); } to { opacity: 1; transform: none; } }

/* ---------- Đầu khung ---------- */
.lc-head {
    flex: 0 0 auto; position: relative; padding: 12px 14px 16px; text-align: center; color: #fff;
    background:
        radial-gradient(circle at 12% 20%, rgba(255, 255, 255, .16) 0, transparent 38%),
        radial-gradient(circle at 90% 70%, rgba(255, 255, 255, .12) 0, transparent 34%),
        linear-gradient(160deg, var(--lc-blue-2), var(--lc-blue));
    border-radius: 0 0 22px 22px;
}
.lc-head-top { display: flex; align-items: center; justify-content: space-between; }
.lc-head-spacer { width: 68px; }
.lc-pill { display: inline-flex; align-items: center; gap: 8px; padding: 7px 18px; border-radius: 999px; background: rgba(255, 255, 255, .16); border: 2px solid rgba(255, 255, 255, .55); font-weight: 600; font-size: 14px; }
.lc-head-actions { position: relative; display: flex; width: 68px; justify-content: flex-end; }
.lc-icon-btn { width: 32px; height: 32px; border: 0; border-radius: 50%; background: transparent; color: #fff; font-size: 15px; display: inline-flex; align-items: center; justify-content: center; }
.lc-icon-btn:hover { background: rgba(255, 255, 255, .2); }
.lc-menu { position: absolute; top: 36px; right: 0; z-index: 5; min-width: 220px; background: #fff; border-radius: 10px; box-shadow: 0 8px 28px rgba(15, 40, 80, .22); overflow: hidden; }
.lc-menu[hidden] { display: none; }
.lc-menu button { width: 100%; text-align: left; border: 0; background: #fff; padding: 11px 14px; font-size: 13.5px; color: var(--lc-text); display: flex; gap: 10px; align-items: center; }
.lc-menu button:hover { background: #f3f6fa; }

.lc-avatars { display: flex; justify-content: center; margin: 14px 0 10px; }
.lc-avatars span { width: 44px; height: 44px; margin-left: -8px; border-radius: 50%; border: 3px solid #fff; color: #fff; display: flex; align-items: center; justify-content: center; font-size: 17px; }
.lc-avatars span:first-child { margin-left: 0; }
.lc-headline { font-weight: 700; font-size: 15.5px; }
.lc-status { margin-top: 4px; font-size: 12.5px; opacity: .95; display: flex; align-items: center; justify-content: center; gap: 6px; }
.lc-dot { width: 9px; height: 9px; border-radius: 50%; background: #3ddc6f; display: inline-block; }
.lc-dot.is-off { background: #b6c2d0; }

@media (max-height: 700px) { .lc-avatars { display: none; } .lc-head { padding-bottom: 12px; } }

/* ---------- Nội dung ---------- */
.lc-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 14px 14px 6px; display: flex; flex-direction: column; gap: 6px; overscroll-behavior: contain; scrollbar-width: thin; }
.lc-row { display: flex; align-items: flex-end; gap: 8px; max-width: 100%; }
.lc-row.lc-out { justify-content: flex-end; }
.lc-ava { flex: 0 0 30px; width: 30px; height: 30px; border-radius: 50%; background: linear-gradient(135deg, var(--lc-blue-2), var(--lc-blue)); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 13px; }
.lc-row.lc-in + .lc-row.lc-in .lc-ava { visibility: hidden; }
.lc-bubble { max-width: 78%; padding: 9px 13px; border-radius: 16px; line-height: 1.45; word-break: break-word; white-space: pre-wrap; }
.lc-in .lc-bubble { background: #f0f2f5; color: var(--lc-text); border-bottom-left-radius: 5px; }
.lc-out .lc-bubble { background: var(--lc-blue); color: #fff; border-bottom-right-radius: 5px; }
.lc-out .lc-bubble a { color: #fff; }
.lc-bubble a { color: var(--lc-blue); text-decoration: underline; }
.lc-row.is-pending .lc-bubble { opacity: .6; }
.lc-time { display: block; margin-top: 2px; font-size: 10.5px; opacity: .6; text-align: right; }
.lc-img { display: block; max-width: 100%; max-height: 220px; border-radius: 10px; margin-top: 4px; cursor: zoom-in; }
.lc-file { display: flex; align-items: center; gap: 8px; margin-top: 4px; padding: 8px 10px; border-radius: 10px; background: rgba(0, 0, 0, .06); color: inherit !important; text-decoration: none !important; font-weight: 500; }
.lc-out .lc-file { background: rgba(255, 255, 255, .18); }
.lc-day { align-self: center; margin: 8px 0 4px; font-size: 11.5px; color: var(--lc-muted); }

/* ---------- Thông tin liên hệ (trước tin đầu tiên) ---------- */
.lc-info { flex: 0 0 auto; margin: 0 14px 8px; padding: 10px 12px; background: #f5f9ff; border: 1px solid #d9e8ff; border-radius: 12px; }
.lc-info[hidden] { display: none; }
.lc-info p { margin: 0 0 8px; font-size: 12.5px; color: #3d5a80; }
.lc-info p span { color: var(--lc-muted); }
.lc-info-row { display: flex; gap: 8px; }
.lc-info input { flex: 1; min-width: 0; height: 34px; padding: 0 10px; border: 1px solid #cfe0f7; border-radius: 8px; background: #fff; font-size: 13px; color: var(--lc-text); }
.lc-info input:focus { outline: none; border-color: var(--lc-blue); }

.lc-files { flex: 0 0 auto; display: flex; flex-wrap: wrap; gap: 6px; padding: 0 14px 6px; }
.lc-files[hidden] { display: none; }
.lc-chip { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; padding: 4px 8px 4px 10px; border-radius: 999px; background: #eef4ff; color: #2b4f86; font-size: 12px; }
.lc-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 170px; }
.lc-chip button { border: 0; background: transparent; color: #6b7a8c; padding: 0 2px; }
.lc-hint { flex: 0 0 auto; margin: 0 14px 6px; padding: 7px 10px; border-radius: 8px; background: #fdeaea; color: #b3261e; font-size: 12.5px; }
.lc-hint[hidden] { display: none; }

/* ---------- Ô soạn tin ---------- */
.lc-composer { flex: 0 0 auto; padding: 8px 12px 12px; }
.lc-box { position: relative; padding: 10px 12px 8px; border: 1px solid var(--lc-line); border-radius: 16px; background: #fff; box-shadow: 0 1px 4px rgba(15, 40, 80, .06); }
.lc-box:focus-within { border-color: var(--lc-blue-2); }
.lc-box textarea { display: block; width: 100%; max-height: 96px; min-height: 24px; border: 0; padding: 0; resize: none; background: transparent; font: inherit; color: var(--lc-text); line-height: 1.45; }
.lc-box textarea:focus { outline: none; }
.lc-trap { position: absolute !important; left: -9999px !important; width: 1px; height: 1px; opacity: 0; }
.lc-tools { display: flex; align-items: center; gap: 2px; margin-top: 6px; }
.lc-tool { width: 32px; height: 32px; border: 0; border-radius: 50%; background: transparent; color: #4b5d73; font-size: 17px; display: inline-flex; align-items: center; justify-content: center; }
.lc-tool:hover { background: #f0f2f5; }
.lc-send { margin-left: auto; width: 34px; height: 34px; border: 0; border-radius: 50%; background: transparent; color: var(--lc-blue); font-size: 18px; display: inline-flex; align-items: center; justify-content: center; }
.lc-send:disabled { color: #b6c2d0; cursor: default; }
.lc-send:not(:disabled):hover { background: #eaf2ff; }
.lc-emoji { position: absolute; left: 0; bottom: calc(100% + 6px); z-index: 6; width: 268px; max-width: 100%; padding: 8px; display: flex; flex-wrap: wrap; gap: 2px; background: #fff; border: 1px solid var(--lc-line); border-radius: 12px; box-shadow: 0 8px 28px rgba(15, 40, 80, .18); }
.lc-emoji[hidden] { display: none; }
.lc-emoji button { width: 36px; height: 36px; border: 0; background: transparent; border-radius: 8px; font-size: 21px; line-height: 1; }
.lc-emoji button:hover { background: #f0f2f5; }

/* ---------- Điện thoại: toàn màn hình ---------- */
@media (max-width: 575.98px) {
    .lc { inset: 0; right: 0; bottom: 0; width: 100%; max-width: none; height: 100vh; height: 100dvh; border-radius: 0; }
}
@media (prefers-reduced-motion: reduce) { .lc { animation: none; } }
