/* AI 智能语音外呼客服系统 V2 - 全局样式 */
:root {
  --primary: #4f6ef7; --primary-dark: #3d58d8; --success: #22c55e; --warning: #f59e0b;
  --danger: #ef4444; --info: #06b6d4; --bg: #f3f5f9; --card: #fff; --text: #1f2937;
  --text2: #6b7280; --border: #e5e7eb; --radius: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 4px 16px rgba(0,0,0,.04);
}
* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif; background: var(--bg); color: var(--text); font-size: 14px; -webkit-font-smoothing: antialiased; }
a { color: var(--primary); text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: 14px; }

/* 布局 */
.layout { display: flex; min-height: 100vh; }
.sidebar { width: 220px; background: #141b2d; color: #cbd5e1; display: flex; flex-direction: column; position: fixed; top: 0; bottom: 0; left: 0; z-index: 50; }
.sidebar .logo { padding: 22px 20px; font-size: 17px; font-weight: 700; color: #fff; border-bottom: 1px solid rgba(255,255,255,.08); }
.sidebar .logo small { display: block; font-size: 11px; color: #64748b; font-weight: 400; margin-top: 4px; }
.sidebar nav { flex: 1; padding: 12px 10px; overflow-y: auto; }
.sidebar nav a { display: flex; align-items: center; gap: 10px; padding: 11px 14px; margin-bottom: 4px; border-radius: 10px; color: #94a3b8; font-size: 14px; transition: .2s; }
.sidebar nav a:hover { background: rgba(255,255,255,.06); color: #e2e8f0; }
.sidebar nav a.active { background: var(--primary); color: #fff; }
.sidebar .user { padding: 14px 20px; border-top: 1px solid rgba(255,255,255,.08); font-size: 13px; color: #94a3b8; }
.main { flex: 1; margin-left: 220px; padding: 24px; max-width: 1400px; }
.page { display: none; }
.page.active { display: block; animation: fadeIn .25s; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.page-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; flex-wrap: wrap; gap: 10px; }
.page-head h2 { font-size: 20px; font-weight: 700; }

/* 卡片 */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; margin-bottom: 16px; }
.card-title { font-size: 15px; font-weight: 600; margin-bottom: 14px; display: flex; align-items: center; justify-content: space-between; }

/* 统计卡片 */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat-card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; display: flex; flex-direction: column; gap: 6px; position: relative; overflow: hidden; }
.stat-card .label { font-size: 13px; color: var(--text2); }
.stat-card .value { font-size: 28px; font-weight: 800; line-height: 1.1; }
.stat-card .sub { font-size: 12px; color: var(--text2); }
.stat-card::after { content: ''; position: absolute; right: -20px; top: -20px; width: 80px; height: 80px; border-radius: 50%; opacity: .12; }
.stat-card.blue::after { background: var(--primary); }
.stat-card.green::after { background: var(--success); }
.stat-card.orange::after { background: var(--warning); }
.stat-card.red::after { background: var(--danger); }
.stat-card.teal::after { background: var(--info); }
.stat-card .value.blue { color: var(--primary); }
.stat-card .value.green { color: var(--success); }
.stat-card .value.orange { color: var(--warning); }
.stat-card .value.red { color: var(--danger); }
.stat-card .value.teal { color: var(--info); }

/* 按钮 */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; border: none; border-radius: 8px; font-size: 14px; font-weight: 500; transition: .2s; background: #eef0f4; color: var(--text); }
.btn:hover { opacity: .88; }
.btn.primary { background: var(--primary); color: #fff; }
.btn.success { background: var(--success); color: #fff; }
.btn.warning { background: var(--warning); color: #fff; }
.btn.danger { background: var(--danger); color: #fff; }
.btn.sm { padding: 5px 10px; font-size: 12px; border-radius: 6px; }
.btn.outline { background: transparent; border: 1px solid var(--border); color: var(--text2); }
.btn.outline:hover { border-color: var(--primary); color: var(--primary); }
.btn.block { width: 100%; justify-content: center; }

/* 表格 */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { padding: 11px 12px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { color: var(--text2); font-weight: 600; background: #fafbfc; font-size: 12.5px; }
tbody tr:hover { background: #f8faff; }
tr.clickable { cursor: pointer; }

/* 标签 */
.tag { display: inline-block; padding: 2px 10px; border-radius: 20px; font-size: 12px; font-weight: 500; }
.tag.gray { background: #f1f5f9; color: #64748b; }
.tag.blue { background: #e0e7ff; color: #4338ca; }
.tag.green { background: #dcfce7; color: #15803d; }
.tag.orange { background: #fef3c7; color: #b45309; }
.tag.red { background: #fee2e2; color: #b91c1c; }
.tag.teal { background: #cffafe; color: #0e7490; }

/* 表单 */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-item { display: flex; flex-direction: column; gap: 6px; }
.form-item.full { grid-column: 1 / -1; }
.form-item label { font-size: 13px; color: var(--text2); font-weight: 500; }
.form-item input, .form-item select, .form-item textarea { padding: 9px 12px; border: 1px solid var(--border); border-radius: 8px; outline: none; transition: .2s; background: #fff; }
.form-item input:focus, .form-item select:focus, .form-item textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79,110,247,.12); }
.form-item textarea { resize: vertical; min-height: 70px; line-height: 1.6; }

/* 弹窗 */
.modal-mask { position: fixed; inset: 0; background: rgba(15,23,42,.5); z-index: 100; display: none; align-items: center; justify-content: center; padding: 16px; }
.modal-mask.show { display: flex; }
.modal { background: #fff; border-radius: 16px; width: 100%; max-width: 620px; max-height: 88vh; overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,.25); animation: slideUp .25s; }
@keyframes slideUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: none; } }
.modal-head { padding: 18px 22px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.modal-head h3 { font-size: 16px; }
.modal-body { padding: 20px 22px; }
.modal-foot { padding: 14px 22px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }

/* 分页/筛选 */
.pager { display: flex; align-items: center; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.pager span { color: var(--text2); font-size: 13px; }
.filter-bar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.filter-bar input, .filter-bar select { padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px; outline: none; background: #fff; }
.filter-bar input:focus, .filter-bar select:focus { border-color: var(--primary); }

/* 对话气泡 */
.dialogue-box { max-height: 380px; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; padding: 4px; }
.msg { max-width: 80%; padding: 9px 14px; border-radius: 12px; font-size: 13.5px; line-height: 1.6; word-break: break-word; }
.msg.user { align-self: flex-start; background: #f1f5f9; border-bottom-left-radius: 4px; }
.msg.ai { align-self: flex-end; background: #e0e7ff; border-bottom-right-radius: 4px; }
.msg .meta { font-size: 11px; color: var(--text2); margin-bottom: 3px; }

/* 进度条 / 图表 */
.progress { height: 8px; background: #eef0f4; border-radius: 10px; overflow: hidden; min-width: 100px; }
.progress i { display: block; height: 100%; background: linear-gradient(90deg, var(--primary), #7c93ff); border-radius: 10px; transition: .3s; }
.chart-bar { display: flex; align-items: flex-end; gap: 8px; height: 160px; padding: 10px 0; }
.chart-bar .col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.chart-bar .col .bar { width: 60%; max-width: 46px; background: linear-gradient(180deg, #7c93ff, var(--primary)); border-radius: 6px 6px 0 0; min-height: 2px; transition: .3s; }
.chart-bar .col span { font-size: 11px; color: var(--text2); }
.intent-list { display: flex; flex-direction: column; gap: 10px; }
.intent-item { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.intent-item .name { width: 70px; color: var(--text2); }
.intent-item .bar { flex: 1; height: 8px; background: #eef0f4; border-radius: 8px; overflow: hidden; }
.intent-item .bar i { display: block; height: 100%; background: var(--info); border-radius: 8px; }
.intent-item .num { width: 40px; text-align: right; font-weight: 600; }

/* 登录页 */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #141b2d 0%, #1e2a4a 50%, #2b3a63 100%); padding: 20px; }
.login-card { background: #fff; border-radius: 18px; padding: 40px 36px; width: 100%; max-width: 380px; box-shadow: 0 25px 60px rgba(0,0,0,.35); }
.login-card .brand { text-align: center; margin-bottom: 26px; }
.login-card .brand .icon { width: 56px; height: 56px; border-radius: 14px; background: linear-gradient(135deg, var(--primary), #8b5cf6); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-size: 26px; margin-bottom: 12px; }
.login-card .brand h1 { font-size: 19px; }
.login-card .brand p { font-size: 13px; color: var(--text2); margin-top: 4px; }

/* Toast */
#toast { position: fixed; top: 20px; left: 50%; transform: translateX(-50%) translateY(-20px); background: #1f2937; color: #fff; padding: 10px 20px; border-radius: 10px; font-size: 14px; opacity: 0; pointer-events: none; transition: .3s; z-index: 200; box-shadow: 0 8px 24px rgba(0,0,0,.25); }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.success { background: var(--success); }
#toast.error { background: var(--danger); }

/* 空状态 */
.empty { text-align: center; padding: 40px 20px; color: var(--text2); }
.empty .icon { font-size: 42px; margin-bottom: 10px; opacity: .5; }

/* 响应式 */
@media (max-width: 820px) {
  .sidebar { display: none; }
  .main { margin-left: 0; padding: 16px 12px 84px; }
  .bottom-nav { position: fixed; bottom: 0; left: 0; right: 0; background: #fff; z-index: 50; display: flex; border-top: 1px solid var(--border); box-shadow: 0 -4px 16px rgba(0,0,0,.06); }
  .bottom-nav a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 9px 0 10px; font-size: 11px; color: var(--text2); }
  .bottom-nav a.active { color: var(--primary); font-weight: 600; }
  .bottom-nav a .mi { font-size: 20px; }
  .form-grid { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .modal { max-width: 100%; }
}
@media (min-width: 821px) { .bottom-nav { display: none; } }

/* 外呼端专属 */
.call-wrap { min-height: 100vh; display: flex; flex-direction: column; max-width: 480px; margin: 0 auto; background: var(--bg); }
.call-header { background: linear-gradient(135deg, var(--primary), #7c93ff); color: #fff; padding: 16px 18px; display: flex; justify-content: space-between; align-items: center; }
.call-header .phone { font-size: 20px; font-weight: 700; letter-spacing: 1px; }
.call-body { flex: 1; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.call-status { text-align: center; color: var(--text2); font-size: 13px; padding: 8px; }
.call-status .state { display: inline-flex; align-items: center; gap: 8px; }
.call-status .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--success); animation: pulse 1.2s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .3; } }
.call-actions { display: flex; gap: 12px; justify-content: center; padding: 8px 0; }
.call-actions .btn { flex: 1; max-width: 160px; padding: 14px; font-size: 15px; border-radius: 12px; justify-content: center; }
.audio-player { width: 100%; }
.rec-hint { font-size: 12px; color: var(--text2); text-align: center; }
