/* =========================================================
   即时沟通：前台浮动组件 + 后台聊天列表
   复用 site.css 的 Amazon 风格变量
   ========================================================= */

:root {
    --live-chat-accent: var(--amazon-orange, #ff9900);
    --live-chat-accent-dark: var(--amazon-orange-dark, #f08804);
    --live-chat-ink: var(--amazon-navy, #131921);
    --live-chat-line: var(--amazon-border, #d5d9d9);
    --live-chat-bg: var(--amazon-bg, #f3f3f3);
    --live-chat-surface: var(--surface, #ffffff);
    --live-chat-text: var(--text-main, #0f1111);
    --live-chat-link: var(--amazon-link, #007185);
    --live-chat-radius: 16px;
    --live-chat-shadow: 0 18px 48px rgba(19, 25, 33, .22);
}

/* ---------- 前台：右下角浮动图标 ---------- */
.live-chat-launcher {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 1080;
    width: 60px;
    height: 60px;
    border: 0;
    border-radius: 50%;
    background: var(--live-chat-accent);
    color: var(--live-chat-ink);
    box-shadow: 0 12px 28px rgba(19, 25, 33, .28);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: transform .18s ease, background .18s ease;
}

.live-chat-launcher:hover,
.live-chat-launcher:focus-visible {
    background: var(--live-chat-accent-dark);
    transform: translateY(-2px) scale(1.03);
    outline: none;
}

.live-chat-launcher svg {
    width: 28px;
    height: 28px;
}

.live-chat-launcher-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 22px;
    height: 22px;
    padding: 0 6px;
    border-radius: 999px;
    background: #dc2626;
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    line-height: 22px;
    text-align: center;
}

.live-chat-launcher-badge[hidden],
.live-chat-panel[hidden],
.live-chat-attachment-preview[hidden] {
    display: none !important;
}

/* ---------- 前台：聊天面板 ---------- */
.live-chat-panel {
    position: fixed;
    right: 20px;
    bottom: 92px;
    z-index: 1080;
    width: min(380px, calc(100vw - 32px));
    height: min(560px, calc(100vh - 132px));
    display: flex;
    flex-direction: column;
    background: var(--live-chat-surface);
    border: 1px solid var(--live-chat-line);
    border-radius: var(--live-chat-radius);
    box-shadow: var(--live-chat-shadow);
    overflow: hidden;
}

.live-chat-panel-head {
    background: var(--live-chat-ink);
    color: #fff;
    padding: 14px 16px;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.live-chat-panel-title {
    font-size: 16px;
    font-weight: 700;
    margin: 0;
}

.live-chat-panel-sub {
    font-size: 12px;
    opacity: .82;
    margin-top: 2px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.live-chat-panel-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #22c55e;
    display: inline-block;
}

.live-chat-panel-dot.is-offline {
    background: #f59e0b;
}

.live-chat-panel-close {
    border: 0;
    background: transparent;
    color: #fff;
    opacity: .8;
    cursor: pointer;
    padding: 2px;
    line-height: 0;
}

.live-chat-panel-close:hover {
    opacity: 1;
}

.live-chat-body {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.live-chat-room {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.live-chat-room[hidden],
.live-chat-login-gate[hidden] {
    display: none !important;
}

.live-chat-login-gate {
    padding: 24px 20px;
    overflow-y: auto;
}

.live-chat-login-gate h3 {
    font-size: 16px;
    margin: 0 0 8px;
}

.live-chat-login-gate p {
    font-size: 13px;
    color: #565959;
    margin: 0 0 16px;
    line-height: 1.6;
}

.live-chat-login-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.live-chat-rules {
    margin-top: 20px;
    padding: 12px 14px;
    background: var(--live-chat-bg);
    border-radius: 12px;
    font-size: 12px;
    color: #565959;
    line-height: 1.8;
}

.live-chat-rules strong {
    color: var(--live-chat-text);
    display: block;
    margin-bottom: 4px;
}

/* ---------- 消息流（前后台共用） ---------- */
.live-chat-launcher[hidden] {
    display: none !important;
}

.live-chat-messages {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 16px;
    background: var(--live-chat-bg);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.live-chat-empty {
    margin: auto;
    text-align: center;
    color: #565959;
    font-size: 13px;
    line-height: 1.8;
    padding: 24px 12px;
}

.live-chat-message {
    max-width: 86%;
    padding: 10px 12px;
    border-radius: 14px;
    background: var(--live-chat-surface);
    border: 1px solid var(--live-chat-line);
    align-self: flex-start;
    font-size: 13px;
    line-height: 1.65;
    color: var(--live-chat-text);
    overflow-wrap: anywhere;
}

.live-chat-message.is-customer,
.live-chat-message.is-mine {
    align-self: flex-end;
    background: #fff3e0;
    border-color: #ffd9a8;
}

.live-chat-message-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 8px;
    font-size: 11px;
    color: #565959;
    margin-bottom: 4px;
}

.live-chat-message-meta strong {
    font-size: 12px;
    color: var(--live-chat-text);
}

.live-chat-message-text {
    margin: 0;
    white-space: pre-wrap;
}

.live-chat-attachment-image {
    display: block;
    margin-top: 8px;
}

.live-chat-attachment-image img {
    display: block;
    max-width: 100%;
    max-height: 220px;
    border-radius: 10px;
    border: 1px solid var(--live-chat-line);
    background: #fff;
}

.live-chat-attachment-video {
    display: block;
    width: 100%;
    max-height: 240px;
    margin-top: 8px;
    border-radius: 10px;
    background: #000;
}

.live-chat-attachment-file {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
    padding: 8px 10px;
    border-radius: 10px;
    background: var(--live-chat-bg);
    border: 1px solid var(--live-chat-line);
    color: var(--live-chat-link);
    text-decoration: none;
    font-size: 12px;
}

.live-chat-attachment-file:hover {
    text-decoration: underline;
}

.live-chat-attachment-file svg {
    width: 16px;
    height: 16px;
    flex: none;
}

.live-chat-attachment-file span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.live-chat-attachment-file em {
    margin-left: auto;
    font-style: normal;
    color: #565959;
    flex: none;
}

/* ---------- 前台：输入区 ---------- */
.live-chat-composer {
    border-top: 1px solid var(--live-chat-line);
    background: var(--live-chat-surface);
    padding: 12px;
}

.live-chat-attachment-preview {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    margin-bottom: 8px;
    border-radius: 10px;
    background: var(--live-chat-bg);
    border: 1px dashed var(--live-chat-line);
    font-size: 12px;
}

.live-chat-attachment-preview img {
    width: 42px;
    height: 42px;
    object-fit: cover;
    border-radius: 6px;
    border: 1px solid var(--live-chat-line);
    flex: none;
}

.live-chat-attachment-preview-name {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--live-chat-text);
}

.live-chat-attachment-preview button {
    border: 0;
    background: transparent;
    color: #b42318;
    cursor: pointer;
    font-size: 12px;
    flex: none;
}

.live-chat-composer-row {
    display: flex;
    align-items: flex-end;
    gap: 8px;
}

.live-chat-composer textarea {
    flex: 1;
    min-height: 44px;
    max-height: 120px;
    resize: none;
    border: 1px solid var(--live-chat-line);
    border-radius: 12px;
    padding: 11px 12px;
    font-size: 13px;
    line-height: 1.5;
    background: var(--live-chat-surface);
    color: var(--live-chat-text);
}

.live-chat-composer textarea:focus {
    outline: none;
    border-color: var(--live-chat-accent);
}

.live-chat-icon-button {
    width: 42px;
    height: 42px;
    flex: none;
    border: 1px solid var(--live-chat-line);
    border-radius: 12px;
    background: var(--live-chat-surface);
    color: var(--live-chat-ink);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.live-chat-icon-button:hover {
    background: var(--live-chat-bg);
}

.live-chat-icon-button svg {
    width: 18px;
    height: 18px;
}

.live-chat-send {
    height: 42px;
    padding: 0 18px;
    border: 0;
    border-radius: 12px;
    background: var(--live-chat-accent);
    color: var(--live-chat-ink);
    font-weight: 700;
    cursor: pointer;
    flex: none;
}

.live-chat-send:hover {
    background: var(--live-chat-accent-dark);
}

.live-chat-send:disabled {
    opacity: .55;
    cursor: not-allowed;
}

.live-chat-status-line {
    margin-top: 8px;
    font-size: 11px;
    color: #565959;
    line-height: 1.7;
    min-height: 16px;
}

.live-chat-status-line.is-error {
    color: #b42318;
}

/* ---------- 后台：聊天列表 + 会话详情 ---------- */
.live-chat-admin {
    align-items: flex-start;
}

.live-chat-list {
    background: var(--live-chat-surface);
    border: 1px solid var(--live-chat-line);
    border-radius: 14px;
    overflow: hidden;
    max-height: 70vh;
    overflow-y: auto;
}

.live-chat-list-item {
    position: relative;
    display: block;
    padding: 12px 14px;
    border-bottom: 1px solid var(--live-chat-line);
    text-decoration: none;
    color: var(--live-chat-text);
    background: var(--live-chat-surface);
}

.live-chat-list-item:last-child {
    border-bottom: 0;
}

.live-chat-list-item:hover {
    background: var(--live-chat-bg);
}

.live-chat-list-item.is-active {
    background: #fff3e0;
    box-shadow: inset 3px 0 0 var(--live-chat-accent);
}

.live-chat-list-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 4px;
}

.live-chat-list-name {
    font-weight: 600;
    font-size: 14px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.live-chat-list-preview {
    font-size: 12px;
    color: #565959;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-bottom: 4px;
}

.live-chat-list-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    font-size: 11px;
    color: #8a8f94;
}

.live-chat-list-unread {
    position: absolute;
    right: 12px;
    bottom: 12px;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 999px;
    background: var(--live-chat-accent);
    color: var(--live-chat-ink);
    font-size: 11px;
    font-weight: 700;
    line-height: 20px;
    text-align: center;
}

.live-chat-detail {
    background: var(--live-chat-surface);
    border: 1px solid var(--live-chat-line);
    border-radius: 14px;
    padding: 16px;
}

.live-chat-detail-head {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--live-chat-line);
}

.live-chat-status-form {
    min-width: 220px;
}

.live-chat-detail .live-chat-messages {
    margin: 14px 0;
    min-height: 260px;
    max-height: 52vh;
    border: 1px solid var(--live-chat-line);
    border-radius: 12px;
}

.live-chat-reply {
    border-top: 1px solid var(--live-chat-line);
    padding-top: 14px;
}

/* 后台回复区：附件控件 + 发送按钮整体居中对齐 */
.live-chat-reply-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-top: 14px;
    padding: 12px 14px;
    border: 1px dashed var(--live-chat-line);
    border-radius: 12px;
    background: var(--live-chat-bg);
}

.live-chat-reply-file {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin-bottom: 0;
    cursor: pointer;
    white-space: nowrap;
}

.live-chat-reply-file svg {
    width: 16px;
    height: 16px;
}

.live-chat-reply-file:focus-within {
    outline: 2px solid var(--live-chat-accent);
    outline-offset: 2px;
}

.live-chat-reply-file-input {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.live-chat-reply-file-name {
    font-size: 12px;
    color: #565959;
    max-width: 280px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.live-chat-reply-file-clear {
    border: 0;
    background: transparent;
    color: #b42318;
    font-size: 12px;
    cursor: pointer;
    padding: 0;
    text-decoration: underline;
}

.live-chat-reply-file-clear[hidden] {
    display: none !important;
}

.live-chat-reply-actions .btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    white-space: nowrap;
}

.live-chat-reply-actions .btn-primary svg {
    width: 16px;
    height: 16px;
}

@media (max-width: 991.98px) {
    .live-chat-list {
        max-height: 42vh;
    }

    .live-chat-detail .live-chat-messages {
        max-height: 46vh;
    }

    .live-chat-panel {
        right: 12px;
        bottom: 84px;
    }

    .live-chat-launcher {
        right: 12px;
        bottom: 12px;
    }
}



/* ---------- 粘贴 / 拖拽 / 移动端附件入口 ---------- */
.live-chat-attach-wrap {
    position: relative;
    flex: none;
}

.live-chat-attach-menu {
    position: absolute;
    left: 0;
    bottom: calc(100% + 8px);
    z-index: 5;
    min-width: 148px;
    padding: 6px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    background: var(--live-chat-surface);
    border: 1px solid var(--live-chat-line);
    border-radius: 12px;
    box-shadow: 0 12px 28px rgba(19, 25, 33, .18);
}

.live-chat-attach-menu[hidden] {
    display: none !important;
}

.live-chat-attach-menu button {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 12px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--live-chat-text);
    font-size: 13px;
    text-align: left;
    cursor: pointer;
}

.live-chat-attach-menu button:hover,
.live-chat-attach-menu button:focus-visible {
    background: var(--live-chat-bg);
    outline: none;
}

.live-chat-attach-menu button svg {
    width: 18px;
    height: 18px;
    flex: none;
}

.live-chat-composer-hint {
    margin-top: 6px;
    font-size: 11px;
    line-height: 1.6;
    color: #8a8f94;
    text-align: center;
}

[data-live-chat].is-dragging .live-chat-panel {
    outline: 2px dashed var(--live-chat-accent);
    outline-offset: -2px;
}

[data-live-chat].is-dragging .live-chat-messages {
    background: #fff7ec;
}

@media (max-width: 575.98px) {
    .live-chat-attach-menu {
        left: auto;
        right: 0;
        min-width: 160px;
    }

    .live-chat-composer-hint {
        font-size: 10px;
    }
}


/* 后台回复区：附件按钮 + 拖拽状态 */
.live-chat-reply-attach {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    white-space: nowrap;
}

.live-chat-reply-attach svg {
    width: 16px;
    height: 16px;
}

.live-chat-reply-actions .live-chat-attach-wrap {
    flex: none;
}

form.live-chat-reply.is-dragging {
    outline: 2px dashed var(--live-chat-accent);
    outline-offset: 4px;
    border-radius: 12px;
}

form.live-chat-reply.is-dragging .live-chat-reply-actions {
    background: #fff7ec;
}

