/* ═══════════════════════════════════════════════════════
   智能电商售后中控系统 — 暗色主题样式
   ═══════════════════════════════════════════════════════ */

/* ── 设计令牌 ── */
:root {
    --bg-primary: #08080f;
    --bg-secondary: #0e0e1a;
    --bg-card: #151525;
    --bg-card-hover: #1c1c35;
    --bg-input: #12121f;
    --bg-surface: rgba(255, 255, 255, 0.03);

    --accent: #7c6bf0;
    --accent-light: #a29bfe;
    --accent-glow: rgba(124, 107, 240, 0.25);
    --accent-gradient: linear-gradient(135deg, #7c6bf0, #6c5ce7);
    --green: #00b894;
    --green-dark: #1a3a2a;
    --red: #ff6b6b;
    --orange: #fdcb6e;
    --blue: #74b9ff;

    --text-primary: #e4e4ec;
    --text-secondary: #6e6e8a;
    --text-muted: #44445a;

    --border: rgba(255, 255, 255, 0.06);
    --border-focus: rgba(124, 107, 240, 0.5);

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --radius-pill: 999px;

    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 20px var(--accent-glow);

    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── 全局重置 ── */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    font-family: var(--font);
    background: var(--bg-primary);
    color: var(--text-primary);
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
}

/* ── 滚动条 ── */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: var(--text-muted);
    border-radius: var(--radius-pill);
}
::-webkit-scrollbar-thumb:hover { background: var(--text-secondary); }

/* ── 应用容器 ── */
.app-container {
    display: flex;
    height: 100vh;
    width: 100vw;
}

.hidden { display: none !important; }

/* ── 面板基础 ── */
.panel {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

.customer-panel {
    flex: 0 0 45%;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
}

.agent-panel {
    flex: 1;
    background: var(--bg-primary);
}

.divider {
    width: 1px;
    background: linear-gradient(to bottom, transparent, var(--accent), transparent);
    opacity: 0.3;
}

/* ── 面板头部 ── */
.panel-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    background: linear-gradient(to right, rgba(124, 107, 240, 0.08), transparent);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.panel-header-icon {
    font-size: 28px;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--accent-gradient);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-glow);
}

.panel-header h1 {
    font-size: 16px;
    font-weight: 600;
    letter-spacing: -0.3px;
}

.panel-subtitle {
    font-size: 12px;
    color: var(--text-secondary);
}

.agent-header {
    background: linear-gradient(to right, rgba(0, 184, 148, 0.08), transparent);
}

.agent-header .panel-header-icon {
    background: linear-gradient(135deg, #00b894, #00a884);
    box-shadow: 0 0 20px rgba(0, 184, 148, 0.25);
}

/* ═══════ 欢迎页 ═══════ */
.screen {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.welcome-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    padding: 40px 24px;
    text-align: center;
}

.welcome-icon {
    font-size: 56px;
    margin-bottom: 16px;
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0px); }
    50% { transform: translateY(-10px); }
}

.welcome-content h2 {
    font-size: 22px;
    font-weight: 600;
    margin-bottom: 8px;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.welcome-desc {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 32px;
    max-width: 360px;
}

.mode-cards {
    display: flex;
    gap: 16px;
    width: 100%;
    max-width: 420px;
}

.mode-card {
    flex: 1;
    padding: 24px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all var(--transition);
    text-align: center;
}

.mode-card:hover, .mode-card:focus {
    background: var(--bg-card-hover);
    border-color: var(--accent);
    transform: translateY(-4px);
    box-shadow: var(--shadow-glow);
}

.mode-icon {
    font-size: 36px;
    margin-bottom: 12px;
}

.mode-card h3 {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 6px;
}

.mode-card p {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.5;
}

/* ═══════ 客户选择页 ═══════ */
.select-content {
    padding: 24px;
    flex: 1;
}

.back-btn {
    background: none;
    border: none;
    color: var(--accent-light);
    font-size: 13px;
    cursor: pointer;
    padding: 6px 0;
    margin-bottom: 20px;
    font-family: var(--font);
    transition: opacity var(--transition);
}

.back-btn:hover { opacity: 0.7; }

.select-content h2 {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 24px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 8px;
    font-weight: 500;
}

.form-group select {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 14px;
    font-family: var(--font);
    appearance: none;
    cursor: pointer;
    transition: border-color var(--transition);
    background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%236e6e8a' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
}

.form-group select:focus {
    outline: none;
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

/* ── 订单列表 ── */
.order-list {
    margin-bottom: 24px;
}

.order-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    margin-bottom: 10px;
    transition: border-color var(--transition);
}

.order-item:hover {
    border-color: rgba(124, 107, 240, 0.3);
}

.order-tag {
    font-size: 11px;
    padding: 3px 8px;
    border-radius: var(--radius-pill);
    font-weight: 500;
    white-space: nowrap;
}

.order-tag.shipped { background: rgba(116, 185, 255, 0.15); color: var(--blue); }
.order-tag.transit { background: rgba(253, 203, 110, 0.15); color: var(--orange); }
.order-tag.delivered { background: rgba(0, 184, 148, 0.15); color: var(--green); }
.order-tag.pending { background: rgba(255, 107, 107, 0.15); color: var(--red); }

.order-info-text {
    flex: 1;
}

.order-info-text .order-id {
    font-size: 12px;
    color: var(--text-secondary);
    font-family: 'Courier New', monospace;
}

.order-info-text .order-product {
    font-size: 14px;
    font-weight: 500;
    margin-top: 2px;
}

.primary-btn {
    width: 100%;
    padding: 14px;
    background: var(--accent-gradient);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-size: 15px;
    font-weight: 600;
    font-family: var(--font);
    cursor: pointer;
    transition: all var(--transition);
    box-shadow: var(--shadow-glow);
}

.primary-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 0 30px var(--accent-glow);
}

/* ═══════ 聊天界面 ═══════ */
.messages-area {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.message {
    display: flex;
    gap: 10px;
    max-width: 85%;
    animation: messageIn 0.3s ease-out;
}

@keyframes messageIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.message.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.message.assistant,
.message.agent {
    align-self: flex-start;
}

.message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
}

.message.user .message-avatar {
    background: var(--accent-gradient);
}

.message.assistant .message-avatar {
    background: linear-gradient(135deg, #2d3436, #636e72);
}

.message.agent .message-avatar {
    background: linear-gradient(135deg, var(--green), #00a884);
}

.message-bubble {
    padding: 10px 14px;
    border-radius: var(--radius-lg);
    font-size: 14px;
    line-height: 1.6;
    word-break: break-word;
    white-space: pre-wrap;
}

.message.user .message-bubble {
    background: var(--accent-gradient);
    color: white;
    border-bottom-right-radius: 4px;
}

.message.assistant .message-bubble {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-bottom-left-radius: 4px;
}

.message.agent .message-bubble {
    background: var(--green-dark);
    border: 1px solid rgba(0, 184, 148, 0.2);
    border-bottom-left-radius: 4px;
}

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

.message.assistant .message-time,
.message.agent .message-time {
    text-align: left;
}

/* ── 系统消息 ── */
.system-message {
    text-align: center;
    padding: 8px 16px;
    animation: messageIn 0.3s ease-out;
}

.system-message span {
    font-size: 12px;
    color: var(--text-secondary);
    background: var(--bg-card);
    padding: 4px 14px;
    border-radius: var(--radius-pill);
    border: 1px solid var(--border);
}

.system-message.escalation span {
    color: var(--red);
    border-color: rgba(255, 107, 107, 0.2);
    background: rgba(255, 107, 107, 0.08);
}

/* ── 打字指示器 ── */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 20px;
    font-size: 12px;
    color: var(--text-secondary);
}

.typing-dots {
    display: flex;
    gap: 3px;
}

.typing-dots span {
    width: 6px;
    height: 6px;
    background: var(--accent-light);
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-6px); opacity: 1; }
}

/* ── 输入区域 ── */
.input-area {
    display: flex;
    gap: 10px;
    padding: 12px 16px;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}

.input-area input {
    flex: 1;
    padding: 12px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-pill);
    color: var(--text-primary);
    font-size: 14px;
    font-family: var(--font);
    transition: border-color var(--transition);
}

.input-area input:focus {
    outline: none;
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.input-area input::placeholder {
    color: var(--text-muted);
}

.send-btn {
    width: 44px;
    height: 44px;
    background: var(--accent-gradient);
    border: none;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
    flex-shrink: 0;
}

.send-btn:hover {
    transform: scale(1.08);
    box-shadow: var(--shadow-glow);
}

.send-btn:active {
    transform: scale(0.95);
}

/* ═══════ 右面板: 客服端 ═══════ */
.agent-body {
    display: flex;
    flex: 1;
    overflow: hidden;
}

.contact-list {
    width: 260px;
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.contact-list-header {
    padding: 14px 16px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.contacts {
    flex: 1;
    overflow-y: auto;
}

.contact-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    cursor: pointer;
    border-bottom: 1px solid var(--border);
    transition: background var(--transition);
}

.contact-item:hover {
    background: var(--bg-surface);
}

.contact-item.active {
    background: rgba(124, 107, 240, 0.08);
    border-left: 3px solid var(--accent);
}

.contact-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: 600;
    color: white;
    flex-shrink: 0;
}

.contact-avatar.small {
    width: 32px;
    height: 32px;
    font-size: 13px;
}

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

.contact-name {
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 2px;
}

.contact-last-msg {
    font-size: 12px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.contact-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 6px;
}

.contact-time {
    font-size: 11px;
    color: var(--text-muted);
}

.badge {
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    background: var(--red);
    color: white;
    font-size: 11px;
    font-weight: 600;
    border-radius: var(--radius-pill);
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ── 新消息通知动画 ── */
.contact-item.new-escalation {
    animation: escalationPulse 0.6s ease-out;
}

@keyframes escalationPulse {
    0% { background: rgba(255, 107, 107, 0.3); transform: translateX(-5px); }
    50% { background: rgba(255, 107, 107, 0.15); }
    100% { background: transparent; transform: translateX(0); }
}

/* ── 客服聊天区 ── */
.agent-chat {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.agent-chat-placeholder {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
}

.placeholder-icon {
    font-size: 48px;
    margin-bottom: 12px;
    opacity: 0.5;
}

.agent-chat-active {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.agent-chat-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-secondary);
}

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

.agent-chat-status {
    font-size: 11px;
    color: var(--green);
    display: block;
}

.agent-messages {
    background: var(--bg-primary);
}

.agent-panel .input-area {
    background: var(--bg-primary);
}

/* ═══════ 头像颜色 ═══════ */
.avatar-color-0 { background: linear-gradient(135deg, #6c5ce7, #a29bfe); }
.avatar-color-1 { background: linear-gradient(135deg, #00b894, #55efc4); }
.avatar-color-2 { background: linear-gradient(135deg, #e17055, #fab1a0); }
.avatar-color-3 { background: linear-gradient(135deg, #0984e3, #74b9ff); }
.avatar-color-4 { background: linear-gradient(135deg, #fdcb6e, #ffeaa7); }

/* ═══════ 响应式 ═══════ */
@media (max-width: 1024px) {
    .customer-panel { flex: 0 0 40%; }
    .contact-list { width: 200px; }
}

@media (max-width: 768px) {
    .app-container { flex-direction: column; }
    .customer-panel { flex: 0 0 50%; }
    .divider { width: 100%; height: 1px; }
    .contact-list { width: 180px; }
}
