﻿.livechat-fab { position: fixed; right: max(18px, env(safe-area-inset-right)); bottom: max(18px, env(safe-area-inset-bottom)); min-width: 64px; height: 64px; padding: 0 18px; border-radius: 999px; border: 0; background: linear-gradient(135deg,#2563eb,#7c3aed); color: #fff; box-shadow: 0 16px 40px rgba(37,99,235,.35); font: 700 16px system-ui; cursor: pointer; z-index: 2147483000; }
.livechat-fab.hidden { display: none; }
.livechat-panel { position: fixed; right: max(24px, env(safe-area-inset-right)); bottom: 100px; width: min(420px, calc(100vw - 32px)); height: min(640px, calc(var(--livechat-viewport-height, 100dvh) - 132px)); min-height: 0; display: none; grid-template-rows: auto minmax(0, 1fr) auto; border-radius: 22px; overflow: hidden; background: #fff; box-shadow: 0 24px 80px rgba(15,23,42,.24); font-family: Inter, "Microsoft YaHei", system-ui, sans-serif; z-index: 2147483001; }
.livechat-panel.open { display: grid; }
.livechat-header { padding: 18px 20px; background: linear-gradient(135deg,#111827,#2563eb); color: #fff; display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.livechat-header strong { display: block; font-size: clamp(17px, 2vw, 20px); line-height: 1.25; }
.livechat-header span { display: block; margin-top: 4px; opacity: .82; font-size: 13px; line-height: 1.4; }
.livechat-minimize { flex: 0 0 auto; width: 32px; height: 32px; border: 0; border-radius: 999px; background: rgba(255,255,255,.16); color: #fff; font-size: 22px; line-height: 1; cursor: pointer; }
.livechat-messages { min-width: 0; min-height: 0; padding: 16px; overflow: auto; overscroll-behavior: contain; background: #f6f8fc; display: flex; flex-direction: column; gap: 10px; }
.livechat-message { max-width: min(82%, 520px); padding: 10px 12px; border-radius: 15px; background: #fff; color: #111827; box-shadow: 0 4px 16px rgba(15,23,42,.06); font-size: 14px; line-height: 1.55; word-break: break-word; }
.livechat-message.visitor { align-self: flex-end; background: #2563eb; color: #fff; }
.livechat-message.system { align-self: flex-start; background: #fff; }
.livechat-message .translation { margin-top: 6px; padding-top: 6px; border-top: 1px dashed rgba(127,127,127,.35); font-size: 12px; opacity: .78; }
.livechat-signature { margin-top: 8px; color: #64748b; font-size: 12px; }
.livechat-composer { min-width: 0; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; padding: 12px; border-top: 1px solid #e5e7eb; background: #fff; }
.livechat-composer input { box-sizing: border-box; width: 100%; min-width: 0; border: 1px solid #d1d5db; border-radius: 999px; padding: 12px 14px; font: inherit; outline: none; }
.livechat-composer input:focus { border-color: #2563eb; box-shadow: 0 0 0 3px rgba(37,99,235,.12); }
.livechat-composer button { border: 0; border-radius: 999px; padding: 0 16px; min-height: 44px; background: #111827; color: #fff; cursor: pointer; white-space: nowrap; }
.livechat-send { max-width: min(120px, 34vw); overflow: hidden; text-overflow: ellipsis; }
body.livechat-page { margin: 0; min-height: 100vh; min-height: 100dvh; background: radial-gradient(circle at 50% 20%, #eef4ff 0, #fff 42%, #f8fafc 100%); overflow: hidden; }
body.livechat-page #livechat { width: 100%; height: var(--livechat-viewport-height, 100dvh); min-height: 0; display: grid; place-items: center; padding: clamp(12px, 3vw, 36px); box-sizing: border-box; }
body.livechat-page .livechat-panel { position: static; width: min(920px, 100%); height: min(760px, calc(var(--livechat-viewport-height, 100dvh) - clamp(24px, 6vw, 72px))); max-height: 100%; border-radius: clamp(18px, 2vw, 28px); box-shadow: 0 30px 90px rgba(15,23,42,.18); }
body.livechat-page .livechat-message { max-width: min(76%, 620px); }
@media (max-width: 640px) { .livechat-panel { inset: var(--livechat-viewport-offset-top, 0px) 0 auto 0; width: auto; height: var(--livechat-viewport-height, 100dvh); max-height: var(--livechat-viewport-height, 100dvh); border-radius: 0; } .livechat-fab { right: 16px; bottom: 16px; } body.livechat-page #livechat { height: var(--livechat-viewport-height, 100dvh); padding: 0; } body.livechat-page .livechat-panel { width: 100vw; height: 100%; max-height: 100%; border-radius: 0; } .livechat-composer { padding-bottom: max(12px, env(safe-area-inset-bottom)); } }
@media (min-width: 1280px) { body.livechat-page .livechat-panel { width: min(980px, 72vw); } }


.livechat-composer { grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; }
.livechat-upload { width: 42px; padding: 0; font-size: 22px; background: #eef2ff !important; color: #2563eb !important; }
.livechat-file-preview { grid-column: 1 / -1; min-width: 0; display: flex; flex-wrap: wrap; gap: 8px; overflow: hidden; font-size: 12px; color: #475569; }
.livechat-file-preview span { max-width: 100%; display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; overflow-wrap: anywhere; border-radius: 999px; background: #eef2ff; }
.livechat-file-preview button { border: 0; background: transparent; color: #ef4444; cursor: pointer; padding: 0; min-height: 0; }
.livechat-status { grid-column: 1 / -1; min-height: 0; color: #64748b; font-size: 12px; line-height: 1.35; }
.livechat-status:empty { display: none; }
.livechat-status.error { color: #b91c1c; }
.livechat-row { display: flex; gap: 8px; align-items: flex-end; width: 100%; }
.livechat-row.agent { justify-content: flex-start; }
.livechat-row.visitor { flex-direction: row-reverse; justify-content: flex-start; }
.livechat-row .livechat-message { flex: 0 1 auto; width: fit-content; max-width: min(76%, 520px); }
.livechat-row.agent .livechat-message { border-bottom-left-radius: 6px; }
.livechat-row.visitor .livechat-message { border-bottom-right-radius: 6px; }
body.livechat-page .livechat-row .livechat-message { max-width: min(70%, 560px); }
.livechat-avatar { width: 30px; height: 30px; border-radius: 999px; object-fit: cover; flex: 0 0 auto; background: #fff; border: 1px solid #e2e8f0; }
.livechat-avatar.fallback { display: inline-grid; place-items: center; background: #dbeafe; color: #1d4ed8; font-size: 11px; font-weight: 800; }
.livechat-attachment { display: inline-grid; place-items: center; margin-top: 8px; padding: 0; border: 0; border-radius: 12px; background: rgba(255,255,255,.28); color: inherit; cursor: zoom-in; overflow: hidden; }
.livechat-attachment.image img { width: 170px; max-width: min(56vw, 220px); max-height: 150px; border-radius: 10px; object-fit: cover; display: block; }
.livechat-attachment.file { width: 54px; height: 54px; font-size: 24px; }

.livechat-avatar.fallback { overflow: hidden; padding: 0; }
.livechat-avatar.fallback svg { width: 100%; height: 100%; display: block; }

.livechat-preview-modal { position: fixed; inset: 0; z-index: 2147483600; display: grid; place-items: center; padding: 24px; background: rgba(15,23,42,.72); }
.livechat-preview-modal.hidden { display: none; }
.livechat-preview-body { max-width: min(92vw, 980px); max-height: 86vh; display: grid; place-items: center; }
.livechat-preview-body img { max-width: 100%; max-height: 86vh; border-radius: 14px; box-shadow: 0 24px 80px rgba(0,0,0,.32); }
.livechat-preview-body a { width: 96px; height: 96px; display: grid; place-items: center; border-radius: 24px; background: #fff; font-size: 42px; text-decoration: none; }
.livechat-preview-close { position: fixed; right: 24px; top: 24px; width: 42px; height: 42px; border: 0; border-radius: 999px; background: rgba(255,255,255,.92); color: #0f172a; font-size: 28px; cursor: pointer; }
