/* ======== 全局重置与基础 ======== */
* { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Helvetica Neue', Arial, sans-serif;
  background: #f5f5f5;
  color: #333;
  min-height: 100vh;
  -webkit-text-size-adjust: 100%;
}
a { text-decoration: none; color: inherit; }
button { border: none; outline: none; cursor: pointer; }
input, textarea { outline: none; border: none; background: none; font-family: inherit; }

/* ======== 登录页 ======== */
.login-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  padding: 20px;
}
.login-box {
  width: 100%;
  max-width: 360px;
  background: #fff;
  border-radius: 16px;
  padding: 36px 28px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.15);
}
.login-logo {
  text-align: center;
  margin-bottom: 28px;
}
.login-logo .logo-icon {
  width: 64px; height: 64px;
  background: linear-gradient(135deg, #667eea, #764ba2);
  border-radius: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  margin-bottom: 12px;
}
.login-logo h2 { font-size: 20px; color: #333; font-weight: 600; }
.login-logo p { font-size: 13px; color: #999; margin-top: 4px; }
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 13px; color: #666; margin-bottom: 6px; font-weight: 500; }
.form-group input {
  width: 100%;
  height: 44px;
  border: 1.5px solid #e5e5e5;
  border-radius: 10px;
  padding: 0 14px;
  font-size: 15px;
  transition: border-color 0.2s;
  background: #fafafa;
}
.form-group input:focus { border-color: #667eea; background: #fff; }
.btn-primary {
  width: 100%;
  height: 46px;
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: #fff;
  border-radius: 10px;
  font-size: 16px;
  font-weight: 600;
  margin-top: 8px;
  transition: opacity 0.2s;
}
.btn-primary:active { opacity: 0.85; }
.error-msg { color: #e74c3c; font-size: 13px; text-align: center; margin-top: 12px; min-height: 18px; }

/* ======== 通用头部 ======== */
.page-header {
  height: 52px;
  background: linear-gradient(135deg, #667eea, #764ba2);
  display: flex;
  align-items: center;
  padding: 0 16px;
  color: #fff;
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(102,126,234,0.4);
}
.page-header .header-title { font-size: 17px; font-weight: 600; flex: 1; text-align: center; }
.page-header .header-back, .page-header .header-action {
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 8px;
  font-size: 20px;
  cursor: pointer;
}
.page-body { padding-top: 52px; }

/* ======== 聊天页面 ======== */
.chat-page { display: flex; flex-direction: column; height: 100vh; background: #f0f0f0; }
.chat-header {
  height: 56px;
  background: linear-gradient(135deg, #667eea, #764ba2);
  display: flex; align-items: center;
  padding: 0 16px;
  color: #fff;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(102,126,234,0.3);
}
.chat-header .agent-info { flex: 1; display: flex; align-items: center; gap: 10px; }
.chat-header .agent-avatar {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: rgba(255,255,255,0.3);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; overflow: hidden;
}
.chat-header .agent-avatar img { width: 100%; height: 100%; object-fit: cover; }
.chat-header .agent-name { font-size: 16px; font-weight: 600; }
.chat-header .agent-status { font-size: 12px; opacity: 0.85; margin-top: 1px; display: flex; align-items: center; gap: 4px; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.status-dot.online { background: #2ecc71; }
.status-dot.offline { background: #ccc; }
.chat-header .header-icons { display: flex; gap: 8px; }
.chat-header .header-icon {
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 8px; font-size: 20px; cursor: pointer;
  background: rgba(255,255,255,0.15);
}

/* 消息列表 */
.msg-list {
  flex: 1;
  overflow-y: auto;
  padding: 12px 12px 8px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.msg-item { display: flex; align-items: flex-end; gap: 8px; max-width: 85%; }
.msg-item.user { flex-direction: row-reverse; align-self: flex-end; }
.msg-item.agent { align-self: flex-start; }
.msg-avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: #ddd;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; overflow: hidden;
}
.msg-avatar img { width: 100%; height: 100%; object-fit: cover; }
.msg-bubble {
  padding: 10px 14px;
  border-radius: 18px;
  font-size: 15px;
  line-height: 1.5;
  word-break: break-all;
  max-width: 100%;
  white-space: pre-wrap;
}
.msg-item.user .msg-bubble {
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.msg-item.user .msg-bubble a {
  color: #d4e4ff;
  text-decoration: underline;
}
.msg-item.agent .msg-bubble {
  background: #fff;
  color: #333;
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}
.msg-item.agent .msg-bubble a {
  color: #5b6ef5;
  text-decoration: underline;
}
.msg-item.system { align-self: center; }
.msg-item.system .msg-bubble {
  background: transparent;
  color: #999;
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 4px;
  background: rgba(0,0,0,0.04);
}
.msg-time { font-size: 11px; color: #bbb; text-align: center; margin: 4px 0; }

/* 快捷菜单 */
.quick-menu-bar {
  background: #fff;
  border-top: 1px solid #eee;
  padding: 8px 12px;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  flex-shrink: 0;
  scrollbar-width: none;
}
.quick-menu-bar::-webkit-scrollbar { display: none; }
.quick-btn {
  flex-shrink: 0;
  height: 32px;
  padding: 0 14px;
  background: #f0f2ff;
  color: #667eea;
  border-radius: 16px;
  font-size: 13px;
  white-space: nowrap;
  border: 1px solid #d8deff;
  transition: all 0.15s;
}
.quick-btn:active { background: #667eea; color: #fff; }

/* 输入区 */
.chat-input-area {
  background: #fff;
  padding: 8px 12px;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  border-top: 1px solid #eee;
  flex-shrink: 0;
  padding-bottom: calc(8px + env(safe-area-inset-bottom));
}
.input-box {
  flex: 1;
  min-height: 38px;
  max-height: 100px;
  border: 1.5px solid #e5e5e5;
  border-radius: 19px;
  padding: 8px 14px;
  font-size: 15px;
  resize: none;
  line-height: 1.4;
  overflow-y: auto;
  background: #fafafa;
  transition: border-color 0.2s;
}
.input-box:focus { border-color: #667eea; background: #fff; }
.send-btn {
  width: 38px; height: 38px;
  background: linear-gradient(135deg, #667eea, #764ba2);
  border-radius: 50%;
  color: #fff;
  font-size: 18px;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  transition: opacity 0.15s;
}
.send-btn:active { opacity: 0.8; }

/* ======== 客服端 ======== */
.agent-page { display: flex; flex-direction: column; height: 100vh; }
.session-list { flex: 1; overflow-y: auto; background: #fff; }
.session-item {
  display: flex; align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid #f5f5f5;
  gap: 12px;
  cursor: pointer;
  transition: background 0.15s;
  position: relative;
}
.session-item:active, .session-item.active { background: #f0f2ff; }
.session-item .s-avatar {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; flex-shrink: 0;
}
.session-item .s-info { flex: 1; overflow: hidden; }
.session-item .s-name { font-size: 15px; font-weight: 500; margin-bottom: 3px; }
.session-item .s-last { font-size: 13px; color: #999; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.session-item .s-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.session-item .s-time { font-size: 11px; color: #bbb; }
.badge {
  background: #e74c3c;
  color: #fff;
  border-radius: 10px;
  font-size: 11px;
  padding: 1px 6px;
  min-width: 18px;
  text-align: center;
}
.agent-chat-wrap { display: flex; flex-direction: column; height: 100vh; }

/* ======== 管理端 ======== */
.admin-page { min-height: 100vh; background: #f5f5f5; }
.tab-nav {
  display: flex;
  background: #fff;
  border-bottom: 1px solid #eee;
  position: sticky;
  top: 52px;
  z-index: 10;
}
.tab-item {
  flex: 1;
  height: 44px;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px;
  color: #999;
  border-bottom: 2px solid transparent;
  transition: all 0.2s;
}
.tab-item.active { color: #667eea; border-bottom-color: #667eea; font-weight: 500; }
.tab-panel { display: none; padding: 16px; }
.tab-panel.active { display: block; }
.card {
  background: #fff;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
  margin-bottom: 12px;
}
.card-header {
  padding: 14px 16px;
  border-bottom: 1px solid #f5f5f5;
  font-size: 15px;
  font-weight: 600;
  display: flex; align-items: center; justify-content: space-between;
}
.card-body { padding: 16px; }
.form-item { margin-bottom: 14px; }
.form-item label { display: block; font-size: 13px; color: #666; margin-bottom: 6px; }
.form-item input, .form-item textarea, .form-item select {
  width: 100%;
  border: 1.5px solid #e5e5e5;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 14px;
  background: #fafafa;
  transition: border-color 0.2s;
  font-family: inherit;
}
.form-item input:focus, .form-item textarea:focus, .form-item select:focus {
  border-color: #667eea; background: #fff;
}
.form-item textarea { resize: vertical; min-height: 70px; }
.btn-add {
  height: 38px;
  padding: 0 16px;
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: #fff;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
}
.btn-sm {
  height: 30px;
  padding: 0 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
}
.btn-danger { background: #fee2e2; color: #e74c3c; }
.btn-success { background: #d1fae5; color: #059669; }
.btn-warning { background: #fef3c7; color: #d97706; }
.list-item {
  padding: 12px 16px;
  border-bottom: 1px solid #f5f5f5;
  display: flex; align-items: center; gap: 12px;
}
.list-item:last-child { border-bottom: none; }
.list-item .item-info { flex: 1; overflow: hidden; }
.list-item .item-title { font-size: 14px; font-weight: 500; margin-bottom: 2px; }
.list-item .item-desc { font-size: 12px; color: #999; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-item .item-actions { display: flex; gap: 6px; flex-shrink: 0; }
.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 500;
}
.tag-green { background: #d1fae5; color: #059669; }
.tag-red { background: #fee2e2; color: #e74c3c; }
.tag-blue { background: #dbeafe; color: #2563eb; }
.tag-gray { background: #f3f4f6; color: #6b7280; }

/* ======== 签到页面 ======== */
.checkin-page { min-height: 100vh; background: #f5f5f5; }
.checkin-banner {
  background: linear-gradient(135deg, #667eea, #764ba2);
  padding: 30px 20px;
  color: #fff;
  text-align: center;
}
.checkin-banner .days { font-size: 48px; font-weight: 700; line-height: 1; }
.checkin-banner .days-label { font-size: 14px; opacity: 0.8; margin-top: 6px; }
.checkin-btn-wrap { padding: 24px 20px; text-align: center; }
.checkin-btn {
  width: 140px; height: 140px;
  border-radius: 50%;
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: #fff;
  font-size: 18px;
  font-weight: 600;
  display: inline-flex; align-items: center; justify-content: center;
  flex-direction: column;
  gap: 4px;
  box-shadow: 0 8px 24px rgba(102,126,234,0.4);
  transition: all 0.2s;
}
.checkin-btn:active { transform: scale(0.96); }
.checkin-btn.done { background: #e5e7eb; color: #9ca3af; box-shadow: none; }
.checkin-btn .btn-icon { font-size: 36px; }
.checkin-calendar { padding: 0 16px 20px; }
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  margin-top: 12px;
}
.calendar-day {
  aspect-ratio: 1;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px;
  color: #999;
  background: #f5f5f5;
}
.calendar-day.checked { background: linear-gradient(135deg, #667eea, #764ba2); color: #fff; }
.calendar-day.today { border: 2px solid #667eea; color: #667eea; font-weight: 600; }
.calendar-day.today.checked { border: none; color: #fff; }

/* ======== 弹窗 ======== */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 1000;
  display: flex; align-items: flex-end;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
}
.modal-overlay.show { opacity: 1; pointer-events: all; }
.modal-box {
  width: 100%;
  background: #fff;
  border-radius: 20px 20px 0 0;
  padding: 20px;
  transform: translateY(100%);
  transition: transform 0.3s;
}
.modal-overlay.show .modal-box { transform: translateY(0); }
.modal-title { font-size: 17px; font-weight: 600; margin-bottom: 16px; text-align: center; }
.modal-close {
  position: absolute;
  right: 20px;
  top: 20px;
  font-size: 22px;
  color: #999;
  cursor: pointer;
}

/* ======== 工具 ======== */
.toast {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.9);
  background: rgba(0,0,0,0.75);
  color: #fff;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 14px;
  z-index: 9999;
  opacity: 0;
  pointer-events: none;
  transition: all 0.25s;
}
.toast.show { opacity: 1; transform: translate(-50%,-50%) scale(1); }
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: #bbb;
}
.empty-state .empty-icon { font-size: 48px; margin-bottom: 12px; }
.empty-state p { font-size: 14px; }
.loading { text-align: center; padding: 20px; color: #bbb; font-size: 14px; }
