/* ============================================
   客服聊天系统 - 样式
   Customer Service Chat - Styles
   ============================================ */

/* ===== 聊天浮动按钮 ===== */
.chat-float-btn {
    position: fixed;
    bottom: 28px;
    right: 28px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: #000;
    color: #fff;
    border: none;
    cursor: pointer;
    z-index: var(--z-float-btn);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 18px rgba(0,0,0,0.18);
    transition: all 0.25s;
    touch-action: manipulation;
}
.chat-float-btn:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 24px rgba(0,0,0,0.25);
}
.chat-float-btn:active {
    transform: scale(0.96);
}
.chat-float-btn svg {
    display: block;
}
.dark-mode .chat-float-btn {
    background: #fff;
    color: #000;
    box-shadow: 0 4px 18px rgba(0,0,0,0.4);
}

/* 未读红点 */
.chat-float-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    min-width: 20px;
    height: 20px;
    background: #e53e3e;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    border-radius: 10px;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 0 5px;
    line-height: 1;
    box-shadow: 0 2px 6px rgba(229,62,62,0.4);
}
.chat-float-badge.show {
    display: flex;
}

/* ===== 聊天面板遮罩 ===== */
.chat-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.4);
    z-index: var(--z-announcement);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}
.chat-overlay.open {
    opacity: 1;
    pointer-events: auto;
}

/* ===== 聊天面板 ===== */
.chat-panel {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 400px;
    max-width: 100vw;
    background: #fff;
    z-index: var(--z-popup);
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: -4px 0 24px rgba(0,0,0,0.1);
}
.chat-panel.open {
    transform: translateX(0);
}
.dark-mode .chat-panel {
    background: #1a1a2e;
    box-shadow: -4px 0 24px rgba(0,0,0,0.4);
}

/* ===== 面板头部 ===== */
.chat-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    border-bottom: 1px solid #eee;
    flex-shrink: 0;
    min-height: 56px;
}
.dark-mode .chat-panel-header {
    border-bottom-color: #333;
}
.chat-panel-title {
    font-size: 16px;
    font-weight: 700;
    color: #000;
    display: flex;
    align-items: center;
    gap: 10px;
}
.dark-mode .chat-panel-title {
    color: #fff;
}
.chat-panel-close {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: 1px solid #ddd;
    background: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #888;
    font-size: 16px;
    transition: all 0.2s;
}
.dark-mode .chat-panel-close {
    background: #2a2a3e;
    border-color: #444;
    color: #aaa;
}
.chat-panel-close:hover {
    background: #f5f5f5;
    color: #000;
    border-color: #999;
}
.dark-mode .chat-panel-close:hover {
    background: #333;
    color: #fff;
    border-color: #666;
}
.chat-panel-status {
    font-size: 11px;
    font-weight: 500;
    color: #2f7d4f;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: #eefaf3;
    padding: 2px 10px 2px 8px;
    border-radius: 20px;
    line-height: 1.4;
}
.dark-mode .chat-panel-status {
    color: #4ade80;
    background: #0d2818;
}
.chat-panel-status.offline {
    color: #888;
    background: #f5f5f5;
}
.dark-mode .chat-panel-status.offline {
    color: #999;
    background: #222;
}
.chat-panel-status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #2f7d4f;
}
.chat-panel-status.offline .chat-panel-status-dot {
    background: #ccc;
}

/* ===== 消息列表 ===== */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scrollbar-width: none;
    -ms-overflow-style: none;
}
.chat-messages::-webkit-scrollbar {
    display: none;
}

/* 加载更多提示 */
.chat-load-more {
    text-align: center;
    padding: 8px;
}
.chat-load-more-btn {
    font-size: 12px;
    color: var(--text3);
    background: none;
    border: 1px dashed var(--border);
    border-radius: 6px;
    padding: 6px 16px;
    cursor: pointer;
    transition: all 0.2s;
}
.chat-load-more-btn:hover {
    border-color: var(--accent);
    color: var(--text);
}
.chat-load-more-btn.loading {
    opacity: 0.6;
    cursor: default;
}

/* ===== 消息气泡 ===== */
.chat-msg {
    display: flex;
    flex-direction: column;
    max-width: 80%;
    animation: chatMsgIn 0.2s ease;
}
@keyframes chatMsgIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}
.chat-msg.user {
    align-self: flex-end;
    align-items: flex-end;
}
.chat-msg.admin,
.chat-msg.system {
    align-self: flex-start;
    align-items: flex-start;
}

.chat-msg-bubble {
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 14px;
    line-height: 1.6;
    word-break: break-word;
    white-space: pre-wrap;
}
.chat-msg.user .chat-msg-bubble {
    background: var(--accent);
    color: var(--text-inverse);
    border-bottom-right-radius: 4px;
}
.chat-msg.admin .chat-msg-bubble {
    background: var(--bg-secondary);
    color: var(--text2);
    border-bottom-left-radius: 4px;
}
.chat-msg.system .chat-msg-bubble {
    background: var(--bg-secondary);
    color: var(--accent);
    font-size: 12px;
    text-align: center;
    align-self: center;
    border-radius: 8px;
    padding: 6px 14px;
    max-width: 100%;
}

.chat-msg-time {
    font-size: 11px;
    color: var(--text3);
    margin-top: 3px;
    padding: 0 4px;
}
.chat-msg-status {
    font-size: 10px;
    color: var(--text3);
    margin-top: 1px;
    padding: 0 4px;
}

/* ===== 输入区域 ===== */
.chat-input-area {
    padding: 12px 16px;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 10px;
    align-items: center;
    flex-shrink: 0;
    background: var(--card);
}
.chat-input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 20px;
    font-size: 16px;
    font-family: inherit;
    resize: none;
    min-height: 42px;
    max-height: 120px;
    line-height: 1.5;
    outline: none;
    transition: border-color 0.2s;
    background: var(--bg-secondary);
}
.chat-input:focus {
    border-color: var(--accent);
    background: var(--card);
}
.chat-input:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.chat-send-btn {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: var(--accent);
    color: var(--text-inverse);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.2s;
    touch-action: manipulation;
    padding: 0;
    line-height: 0;
}
.chat-send-btn svg {
    display: block;
}
.chat-send-btn:hover {
    background: #333;
    transform: scale(1.05);
}
.chat-send-btn:active {
    transform: scale(0.95);
}
.chat-send-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
}

/* ===== 关闭提示 ===== */
.chat-closed-notice {
    text-align: center;
    padding: 20px;
    color: #888;
    font-size: 13px;
}
.dark-mode .chat-closed-notice {
    color: #999;
}
.chat-closed-notice a {
    color: #000;
    font-weight: 600;
    cursor: pointer;
    text-decoration: underline;
}
.chat-new-conv-btn {
    display: inline-block;
    margin-top: 10px;
    padding: 8px 20px;
    background: #000;
    color: #fff !important;
    border-radius: 20px;
    font-size: 13px;
    text-decoration: none !important;
    transition: background 0.2s;
}
.chat-new-conv-btn:hover {
    background: #333;
}
.dark-mode .chat-new-conv-btn {
    background: #fff;
    color: #000 !important;
}
.dark-mode .chat-new-conv-btn:hover {
    background: #ddd;
}
.dark-mode .chat-closed-notice a {
    color: #fff;
}

/* ===== 连接状态 ===== */
.chat-connection-status {
    text-align: center;
    padding: 4px;
    font-size: 11px;
    color: #e53e3e;
    background: #fff5f5;
    display: none;
}
.chat-connection-status.show {
    display: block;
}
.dark-mode .chat-connection-status {
    background: #2a1518;
    color: #ff6b6b;
}

/* ===== 历史对话入口 ===== */
.chat-history-link {
    font-size: 12px;
    color: #888;
    text-align: center;
    padding: 6px 0 2px;
    cursor: pointer;
}
.chat-history-link:hover {
    color: #000;
}
.dark-mode .chat-history-link:hover {
    color: #fff;
}

/* ===== 移动端响应式 ===== */
@media (max-width: 768px) {
    .chat-panel {
        width: 100%;
    }
    .chat-float-btn {
        bottom: 20px;
        right: 16px;
        width: 50px;
        height: 50px;
    }
}
@media (max-width: 480px) {
    .chat-panel-header {
        padding: 12px 14px;
    }
    .chat-panel-title {
        font-size: 15px;
    }
    .chat-messages {
        padding: 12px;
        gap: 10px;
    }
    .chat-msg-bubble {
        font-size: 13px;
        padding: 8px 12px;
    }
    .chat-msg {
        max-width: 85%;
    }
    .chat-input-area {
        padding: 10px 12px;
        gap: 8px;
    }
    .chat-input {
        font-size: 16px;
        padding: 8px 12px;
        min-height: 38px;
    }
    .chat-send-btn {
        width: 38px;
        height: 38px;
    }
    .chat-float-btn {
        bottom: 16px;
        right: 12px;
        width: 46px;
        height: 46px;
    }
}

/* ===== 后台客服界面 ===== */
.admin-chat-layout {
    display: flex;
    flex: 1;
    min-height: 0;
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    background: var(--card);
}

/* 会话列表侧栏 */
.admin-chat-sidebar {
    width: 300px;
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    min-height: 0;
    overflow: hidden;
    background: var(--bg-secondary);
}
.admin-chat-sidebar-header {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    font-size: 15px;
    font-weight: 700;
    color: var(--text);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.admin-chat-sidebar-count {
    font-size: 12px;
    color: var(--text3);
    font-weight: 400;
}
.admin-chat-conv-list {
    flex: 1;
    overflow-y: auto;
    scrollbar-width: none;
}
.admin-chat-conv-list::-webkit-scrollbar {
    display: none;
}

.admin-chat-conv-item {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: background 0.15s;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.admin-chat-conv-item:hover {
    background: var(--bg-secondary);
}
.admin-chat-conv-item.active {
    background: var(--bg-secondary);
    border-left: 3px solid var(--accent);
}
.admin-chat-conv-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.admin-chat-conv-user {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
}
.admin-chat-conv-badge {
    min-width: 20px;
    height: 20px;
    background: #e53e3e;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 5px;
}
.admin-chat-conv-preview {
    font-size: 12px;
    color: var(--text3);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.admin-chat-conv-time {
    font-size: 11px;
    color: var(--text3);
}

/* 聊天主区域 */
.admin-chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
}
.admin-chat-main-header {
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}
.admin-chat-main-user {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
}
.admin-chat-main-actions {
    display: flex;
    gap: 8px;
}
.admin-chat-main-actions .btn-sm {
    font-size: 11px;
    padding: 4px 10px;
}
.admin-chat-empty {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text3);
    font-size: 14px;
}

/* 后台消息列表复用 chat-messages */
.admin-chat-main .chat-messages {
    flex: 1;
    min-height: 0;
}

/* 后台输入区域 */
.admin-chat-main .chat-input-area {
    border-top: 1px solid var(--border);
}

/* 后台响应式 */
@media (max-width: 768px) {
    .admin-chat-layout {
        flex-direction: column;
        flex: 1;
        border-radius: 0;
        border-left: none;
        border-right: none;
    }
    .admin-chat-sidebar {
        width: 100%;
        max-height: 42%;
        min-height: 180px;
        border-right: none;
        border-bottom: 1px solid var(--border);
        flex-shrink: 0;
    }
    .admin-chat-main {
        flex: 1;
        min-height: 0;
        max-width: none;
    }
    .admin-chat-tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    .admin-chat-tab {
        flex-shrink: 0;
        min-width: 52px;
        padding: 10px 6px;
        font-size: 12px;
    }
    .customer-info-panel {
        display: none !important;
    }
}

@media (max-width: 480px) {
    .admin-chat-sidebar {
        max-height: 45%;
        min-height: 160px;
    }
    .admin-chat-sidebar-header {
        padding: 10px 14px;
        font-size: 14px;
    }
    .admin-chat-main-header {
        padding: 10px 14px;
    }
    .admin-chat-main-user {
        font-size: 14px;
    }
    .admin-chat-conv-item {
        padding: 12px 14px;
    }
    .admin-chat-layout {
        border-radius: 0;
    }
    .quick-reply-bar {
        padding: 4px 10px;
        gap: 4px;
    }
    .quick-reply-btn {
        padding: 3px 8px;
        font-size: 10px;
    }
    .chat-setting-group {
        padding: 10px;
    }
    .chat-setting-row {
        font-size: 11px;
        gap: 6px;
    }
}

/* ============================================
   黑名单面板
   ============================================ */
.admin-chat-blacklist {
    display: none;
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    flex-direction: column;
    gap: 8px;
}
.admin-chat-blacklist.active {
    display: flex;
}

.blacklist-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 12px;
}
.blacklist-item-info {
    flex: 1;
    min-width: 0;
}
.blacklist-item-user {
    font-weight: 600;
    color: var(--text);
    margin-bottom: 2px;
}
.blacklist-item-reason {
    color: var(--text3);
    font-size: 11px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.blacklist-item-time {
    color: var(--text3);
    font-size: 10px;
    margin-top: 2px;
}

/* ============================================
   客户信息面板（右侧固定栏）
   ============================================ */
.customer-info-panel {
    width: 280px;
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    background: var(--bg-secondary);
    overflow: hidden;
}

.customer-info-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    user-select: none;
    flex-shrink: 0;
    background: var(--card);
}

.customer-info-header-left {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.customer-info-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.customer-info-badge {
    font-size: 11px;
}

.customer-info-header-right {
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.customer-info-body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 12px 16px;
    scrollbar-width: none;
}
.customer-info-body::-webkit-scrollbar {
    display: none;
}

/* 信息分组 */
.customer-info-section {
    margin-bottom: 10px;
}

.customer-info-section-title {
    font-size: 11px;
    font-weight: 600;
    color: var(--text3);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
    padding-bottom: 4px;
    border-bottom: 1px solid var(--border);
}

.customer-info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 3px 0;
    font-size: 12px;
}

.cir-label {
    color: var(--text3);
    flex-shrink: 0;
    margin-right: 12px;
    min-width: 60px;
}

.cir-value {
    color: var(--text2);
    text-align: right;
    word-break: break-all;
}

/* 黑名单标记 */
.blacklist-badge {
    display: inline-block;
    padding: 1px 6px;
    background: #fee2e2;
    color: #e53e3e;
    font-size: 10px;
    font-weight: 600;
    border-radius: 4px;
    vertical-align: middle;
}


/* 会话列表中的黑名单项 */
.admin-chat-conv-item.conv-blocked {
    border-left: 3px solid #e53e3e;
}
.admin-chat-conv-item.conv-blocked.active {
    border-left: 3px solid #e53e3e;
}


/* ============================================
   图片消息
   ============================================ */
.chat-msg-image {
    max-width: 200px;
    max-height: 200px;
    border-radius: 8px;
    cursor: pointer;
    display: block;
    transition: opacity 0.2s;
}
.chat-msg-image:hover {
    opacity: 0.85;
}

/* ============================================
   图片预览遮罩
   ============================================ */
.chat-image-preview-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.85);
    z-index: var(--z-chat-image);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}
.chat-image-preview-img {
    max-width: 90%;
    max-height: 90%;
    object-fit: contain;
    border-radius: 4px;
}
.chat-image-preview-close {
    position: absolute;
    top: 16px;
    right: 24px;
    font-size: 32px;
    color: #fff;
    cursor: pointer;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: rgba(255,255,255,0.15);
    transition: background 0.2s;
    line-height: 1;
}
.chat-image-preview-close:hover {
    background: rgba(255,255,255,0.3);
}

/* ============================================
   图片上传按钮
   ============================================ */
.chat-image-btn {
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    width: 38px;
    height: 38px;
    color: #888;
    flex-shrink: 0;
    transition: color 0.2s;
    border: none;
    background: none;
    font: inherit;
    outline: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}
.chat-image-btn:hover {
    color: #000;
}
.dark-mode .chat-image-btn:hover {
    color: #fff;
}

/* ============================================
   评星组件
   ============================================ */
.chat-rating-stars {
    display: flex;
    gap: 4px;
    justify-content: center;
    margin: 8px 0;
}
.chat-star {
    font-size: 28px;
    color: #ddd;
    cursor: pointer;
    transition: color 0.15s, transform 0.15s;
    user-select: none;
}
.chat-star:hover {
    transform: scale(1.2);
}
.chat-star.active,
.chat-star.filled {
    color: #f59e0b;
}
.dark-mode .chat-star {
    color: #555;
}
.dark-mode .chat-star.active,
.dark-mode .chat-star.filled {
    color: #fbbf24;
}
