/* ==========================================
   蚂蚁兄弟SCRM - 企业微信客服系统
   ========================================== */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #1aad19;
    --primary-hover: #169816;
    --bg: #f5f5f5;
    --white: #fff;
    --border: #e8e8e8;
    --text: #333;
    --text-light: #999;
    --chat-bg: #f0f0f0;
    --msg-send: #95ec69;
    --msg-recv: #fff;
    --danger: #e64340;
    --shadow: 0 2px 8px rgba(0,0,0,0.08);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    background: var(--bg);
    color: var(--text);
    height: 100vh;
    overflow: hidden;
}

/* ---- 通用组件 ---- */

.input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

.input:focus {
    border-color: var(--primary);
}

.input-sm {
    padding: 8px 12px;
    font-size: 13px;
}

.btn {
    padding: 8px 20px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    background: var(--white);
    transition: all 0.2s;
}

.btn:hover {
    background: #f0f0f0;
}

.btn-primary {
    background: var(--primary);
    color: var(--white);
    border: none;
}

.btn-primary:hover {
    background: var(--primary-hover);
}

.btn-block {
    width: 100%;
}

.btn-sm {
    padding: 5px 12px;
    font-size: 12px;
}

.btn-xs {
    padding: 2px 8px;
    font-size: 11px;
    border-radius: 4px;
}

.error-msg {
    color: var(--danger);
    font-size: 13px;
    margin-top: 8px;
    text-align: center;
}

.status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 6px;
}

.status-dot.online { background: var(--primary); }
.status-dot.offline { background: var(--text-light); }

/* ---- 登录页 ---- */

.login-container {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100vh;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.login-box {
    background: var(--white);
    padding: 40px;
    border-radius: 12px;
    box-shadow: var(--shadow);
    width: 340px;
    text-align: center;
}

.login-logo {
    font-size: 48px;
    margin-bottom: 10px;
}

.login-title {
    font-size: 22px;
    margin-bottom: 4px;
    color: var(--text);
}

.login-subtitle {
    font-size: 13px;
    color: var(--text-light);
    margin-bottom: 24px;
}

.login-form .input {
    margin-bottom: 12px;
}

/* ---- 主布局 ---- */

.main-layout {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 20px;
    background: var(--white);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.logo-text {
    font-size: 16px;
    font-weight: 600;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.agent-name {
    font-size: 14px;
}

.main-body {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* ---- 左侧面板 ---- */

.left-panel {
    width: 280px;
    background: var(--white);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.agent-tabs {
    display: flex;
    padding: 10px;
    gap: 6px;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}

.agent-tab {
    padding: 4px 12px;
    font-size: 12px;
    border-radius: 12px;
    background: #f0f0f0;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.agent-tab.active {
    background: var(--primary);
    color: var(--white);
}

.agent-tab:hover:not(.active) {
    background: #e0e0e0;
}

.search-box {
    padding: 10px;
    border-bottom: 1px solid var(--border);
}

.customer-list {
    flex: 1;
    overflow-y: auto;
}

.customer-item {
    display: flex;
    padding: 12px 15px;
    cursor: pointer;
    border-bottom: 1px solid #f5f5f5;
    transition: background 0.15s;
}

.customer-item:hover {
    background: #f8f8f8;
}

.customer-item.active {
    background: #e8f8e6;
}

.customer-avatar-wrapper {
    position: relative;
    flex-shrink: 0;
    margin-right: 10px;
}

.customer-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #e0e0e0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.unread-badge {
    position: absolute;
    top: -4px;
    right: -2px;
    background: #e64340;
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
    font-size: 16px;
}

.customer-info-item {
    flex: 1;
    min-width: 0;
}

.customer-name-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.customer-name {
    font-size: 14px;
    font-weight: 500;
}

.customer-time {
    font-size: 11px;
    color: var(--text-light);
    flex-shrink: 0;
}

.customer-last-msg {
    font-size: 12px;
    color: var(--text-light);
    margin-top: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.customer-tags {
    display: flex;
    gap: 4px;
    margin-top: 4px;
    flex-wrap: wrap;
}

.no-customers {
    padding: 40px 20px;
    text-align: center;
    color: var(--text-light);
    font-size: 13px;
}

/* ---- 聊天面板 ---- */

.chat-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--chat-bg);
    min-width: 0;
}

.chat-header {
    padding: 12px 20px;
    background: var(--white);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    position: relative;
}

.chat-header-text {
    font-size: 15px;
    font-weight: 500;
}

.message-list {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
}

.no-message {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-light);
    font-size: 15px;
}

.no-message .hint {
    font-size: 12px;
    margin-top: 8px;
    color: #ccc;
}

/* 消息气泡 */
.message {
    max-width: 70%;
    margin-bottom: 12px;
    display: flex;
    flex-direction: column;
}

.message.agent {
    align-self: flex-end;
}

.message.customer {
    align-self: flex-start;
}

.message-bubble {
    padding: 8px 14px;
    border-radius: 8px;
    font-size: 14px;
    line-height: 1.6;
    word-wrap: break-word;
    position: relative;
}

.message.agent .message-bubble {
    background: var(--msg-send);
    border-bottom-right-radius: 2px;
}

.message.customer .message-bubble {
    background: var(--msg-recv);
    border-bottom-left-radius: 2px;
}

.message-time {
    font-size: 11px;
    color: var(--text-light);
    margin-top: 4px;
    text-align: right;
}

.message.customer .message-time {
    text-align: left;
}

/* ---- 输入区域 ---- */

.input-area {
    background: var(--white);
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}

.input-toolbar {
    padding: 8px 15px 0;
    display: flex;
    gap: 4px;
}

.toolbar-btn {
    width: 30px;
    height: 30px;
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 18px;
    border-radius: 4px;
    transition: background 0.15s;
}

.toolbar-btn:hover {
    background: #f0f0f0;
}

.input-row {
    display: flex;
    padding: 8px 15px 15px;
    gap: 10px;
    align-items: flex-end;
}

.msg-input {
    flex: 1;
    resize: none;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 8px 12px;
    font-size: 14px;
    outline: none;
    font-family: inherit;
    transition: border-color 0.2s;
}

.msg-input:focus {
    border-color: var(--primary);
}

.send-btn {
    height: 66px;
    width: 80px;
    font-size: 14px;
}

/* ---- 右侧客户信息面板 ---- */

.right-panel {
    width: 260px;
    background: var(--white);
    border-left: 1px solid var(--border);
    padding: 20px;
    overflow-y: auto;
    flex-shrink: 0;
}

.section-title {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.info-row {
    margin-bottom: 8px;
    font-size: 13px;
}

.info-row .label {
    color: var(--text-light);
    margin-right: 4px;
}

.tag-section {
    margin-top: 20px;
}

.tag-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.tag {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 3px;
    font-size: 11px;
    color: var(--white);
}

.tag-red { background: #e64340; }
.tag-blue { background: #4a90d9; }
.tag-green { background: var(--primary); }
.tag-orange { background: #f5a623; }
.tag-purple { background: #9013fe; }
.tag-gray { background: #ccc; color: #666; }

/* ---- 滚动条 ---- */

::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #ddd;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #ccc;
}

/* ---- 转接弹窗 ---- */

.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-box {
    background: #fff;
    border-radius: 10px;
    width: 420px;
    max-height: 80vh;
    box-shadow: 0 8px 30px rgba(0,0,0,0.15);
    overflow: hidden;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid #eee;
}

.modal-header h3 {
    font-size: 16px;
    font-weight: 600;
}

.modal-body {
    padding: 16px 20px 20px;
    max-height: 50vh;
    overflow-y: auto;
}

.transfer-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.transfer-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border: 1px solid #eee;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s;
}

.transfer-item:hover {
    background: #f5f5f5;
    border-color: #ddd;
}

.transfer-item .transfer-status {
    width: 8px; height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.transfer-item .transfer-status.online { background: var(--primary); }
.transfer-item .transfer-status.offline { background: #ccc; }
.transfer-item .transfer-status.paused { background: #e67e22; }

/* ---- 开发模式登录按钮 ---- */

.mock-user-btn {
    display: block;
    width: 100%;
    padding: 12px 16px;
    border: 1px solid #eee;
    border-radius: 8px;
    background: #fafafa;
    cursor: pointer;
    text-align: left;
    transition: all 0.15s;
    margin-bottom: 8px;
}

.mock-user-btn:hover {
    background: #e8f8e6;
    border-color: var(--primary);
}

.mock-user-btn:last-child {
    margin-bottom: 0;
}

/* ---- 设置页面 ---- */

.settings-layout {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

.settings-body {
    flex: 1;
    padding: 30px;
    overflow-y: auto;
    max-width: 700px;
}

.settings-section {
    background: #fff;
    border-radius: 8px;
    padding: 24px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

.settings-title {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 6px;
}

.settings-desc {
    font-size: 13px;
    color: #999;
    margin-bottom: 20px;
}

.settings-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.settings-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: #f9f9f9;
    border-radius: 6px;
    border: 1px solid #eee;
}

.settings-item .color-picker {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    padding: 0;
}

.settings-item .name-input {
    flex: 1;
    padding: 6px 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    outline: none;
}

.settings-item .name-input:focus {
    border-color: var(--primary);
}

.settings-item .btn-remove {
    color: var(--danger);
    background: none;
    border: none;
    cursor: pointer;
    font-size: 18px;
    padding: 4px 8px;
    border-radius: 4px;
}

.settings-item .btn-remove:hover {
    background: #fee;
}

.settings-message {
    margin-top: 12px;
    padding: 8px 14px;
    border-radius: 4px;
    font-size: 13px;
}

.settings-message.success {
    background: #eafaf1;
    color: #27ae60;
    display: block !important;
}

.settings-message.error {
    background: #fdecea;
    color: #e64340;
    display: block !important;
}
