/* ============================================================
   起司云客服系统 · 设计系统
   配色与圆角取自起司云官网（Material Design 3 令牌）
   —— 主色 金黄 #FFCE00 / 强调 深橙 #9B4700 / 表面 米白 #F7F1E2
   ============================================================ */

:root {
  /* ---------- 品牌主色 ---------- */
  /* 注意：金黄底色上必须用深色文字（#312700），白字对比度不足无法阅读 */
  --brand: #FFCE00;
  --brand-hover: #F0BE00;
  --brand-active: #DDAE00;
  --on-brand: #312700;
  --brand-soft: #F2DC96;        /* 主色浅容器 */
  --brand-tint: #FFF8DC;        /* 更浅的底色，用于选中态 */
  --brand-glow: rgba(255, 206, 0, 0.28);

  /* ---------- 品牌强调色（用于品牌文字、链接、图标） ---------- */
  --accent: #9B4700;
  --accent-hover: #7F3900;
  --accent-soft: #F3D9C6;

  /* ---------- 表面 ---------- */
  --bg: #F7F1E2;
  --bg-elevated: #FFFFFF;
  --bg-sunken: #EFE4CB;
  --surface-variant: #E6DBC2;
  --surface-high: #F0E1B5;

  /* ---------- 文字 ---------- */
  --text: #19160F;
  --text-soft: #5F5129;
  --text-faint: #8A7B6A;
  --text-on-brand: #312700;

  /* ---------- 边框 ---------- */
  --border: #E6DBC2;
  --border-strong: #D5C6A8;
  --outline: #75695C;

  /* ---------- 语义色 ---------- */
  --success: #2F7D4F;
  --success-soft: #E3F3E9;
  --warning: #B26A00;
  --warning-soft: #FFF0D6;
  --danger: #B3261E;
  --danger-soft: #FCE8E6;
  --info: #2C6E9B;
  --info-soft: #E4F0F8;

  /* ---------- 圆角（MD3 大圆角） ---------- */
  --radius-xs: 6px;
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --radius-xl: 26px;
  --radius-pill: 999px;

  /* ---------- 阴影 ---------- */
  --shadow-sm: 0 2px 8px rgba(65, 53, 18, 0.06);
  --shadow: 0 4px 12px rgba(65, 53, 18, 0.08);
  --shadow-lg: 0 10px 28px rgba(65, 53, 18, 0.16);
  --shadow-brand: 0 6px 18px rgba(255, 206, 0, 0.35);

  --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);

  /* 安全区（iPhone 刘海/底部横条） */
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ============================================================
   按钮
   ============================================================ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.4;
  color: var(--text);
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
  font-family: inherit;
  user-select: none;
}
.btn:hover:not(:disabled) { border-color: var(--brand); background: var(--brand-tint); }
.btn:active:not(:disabled) { transform: scale(0.97); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

/* 主按钮：金黄底 + 深棕字 */
.btn-primary {
  background: var(--brand);
  border-color: var(--brand);
  color: var(--on-brand);
  box-shadow: var(--shadow-sm);
}
.btn-primary:hover:not(:disabled) {
  background: var(--brand-hover);
  border-color: var(--brand-hover);
  color: var(--on-brand);
  box-shadow: var(--shadow-brand);
}

/* 强调按钮：深橙，用于第二层级的重要操作 */
.btn-accent {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn-accent:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); color: #fff; }

.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #9A1F19; border-color: #9A1F19; color: #fff; }

.btn-ghost { background: transparent; border-color: transparent; color: var(--text-soft); }
.btn-ghost:hover:not(:disabled) { background: var(--bg-sunken); color: var(--text); border-color: transparent; }

.btn-sm { padding: 5px 12px; font-size: 12.5px; border-radius: var(--radius-sm); }
.btn-xs { padding: 3px 9px; font-size: 11.5px; border-radius: var(--radius-xs); font-weight: 500; }
.btn-lg { padding: 11px 22px; font-size: 15px; border-radius: var(--radius-lg); }
.btn-block { width: 100%; }

/* ============================================================
   表单
   ============================================================ */

.input, .select, .textarea {
  width: 100%;
  padding: 9px 12px;
  font-size: 13px;
  font-family: inherit;
  color: var(--text);
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-glow);
}
.textarea { resize: vertical; min-height: 80px; line-height: 1.6; }
.select { cursor: pointer; }

.form-row { margin-bottom: 14px; }
.form-row label {
  display: block;
  margin-bottom: 6px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-soft);
}
.form-hint { margin-top: 5px; font-size: 11.5px; color: var(--text-faint); line-height: 1.6; }
.form-hint code {
  padding: 1px 5px; background: var(--bg-sunken);
  border-radius: 4px; font-size: 11px; color: var(--accent);
}

.checkbox-label {
  display: flex; align-items: center; gap: 7px;
  font-size: 13px; color: var(--text); cursor: pointer;
}
.checkbox-label input[type="checkbox"] {
  width: 16px; height: 16px; accent-color: var(--brand); cursor: pointer; flex-shrink: 0;
}

/* ============================================================
   徽章
   ============================================================ */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 9px;
  font-size: 11.5px;
  font-weight: 600;
  border-radius: var(--radius-pill);
  background: var(--bg-sunken);
  color: var(--text-soft);
  white-space: nowrap;
}
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-info { background: var(--info-soft); color: var(--info); }
.badge-brand { background: var(--brand-soft); color: var(--on-brand); }
.badge-accent { background: var(--accent-soft); color: var(--accent); }

.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.dot-online { background: var(--success); box-shadow: 0 0 0 2px var(--success-soft); }
.dot-busy { background: var(--danger); box-shadow: 0 0 0 2px var(--danger-soft); }
.dot-away { background: var(--warning); box-shadow: 0 0 0 2px var(--warning-soft); }
.dot-offline { background: #C4B69C; }

/* ============================================================
   卡片
   ============================================================ */

.card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  font-weight: 700;
  font-size: 13.5px;
  color: var(--text);
}
.card-body { padding: 16px; }

/* ============================================================
   表格
   ============================================================ */

.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th {
  text-align: left;
  padding: 11px 12px;
  font-weight: 700;
  font-size: 12px;
  color: var(--text-soft);
  background: var(--bg-sunken);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.table td {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.table tbody tr:hover { background: var(--brand-tint); }
.table tbody tr:last-child td { border-bottom: none; }

/* ============================================================
   布局工具
   ============================================================ */

.flex { display: flex; }
.flex-center { display: flex; align-items: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.flex-col { display: flex; flex-direction: column; }
.gap-4 { gap: 4px; } .gap-6 { gap: 6px; } .gap-8 { gap: 8px; }
.gap-10 { gap: 10px; } .gap-12 { gap: 12px; } .gap-16 { gap: 16px; }
.flex-1 { flex: 1; min-width: 0; }
.mt-8 { margin-top: 8px; } .mt-12 { margin-top: 12px; } .mt-16 { margin-top: 16px; }
.mb-8 { margin-bottom: 8px; } .mb-12 { margin-bottom: 12px; } .mb-16 { margin-bottom: 16px; }
.text-soft { color: var(--text-soft); }
.text-faint { color: var(--text-faint); }
.text-accent { color: var(--accent); }
.text-xs { font-size: 11.5px; }
.text-sm { font-size: 12.5px; }
.text-bold { font-weight: 700; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; }

/* ============================================================
   空态 / 加载
   ============================================================ */

.empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; padding: 48px 20px;
  color: var(--text-faint); font-size: 13px; text-align: center;
}
.empty-icon { font-size: 34px; opacity: 0.4; }

.spinner {
  width: 16px; height: 16px;
  border: 2px solid var(--border-strong);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================
   模态框
   ============================================================ */

.modal-mask {
  position: fixed; inset: 0;
  background: rgba(25, 22, 15, 0.5);
  backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center;
  z-index: 900; padding: 20px;
  animation: mask-in 0.18s ease;
}
@keyframes mask-in { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: var(--bg-elevated);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  width: 100%; max-width: 520px; max-height: 88vh;
  display: flex; flex-direction: column; overflow: hidden;
  animation: modal-in 0.22s cubic-bezier(0.34, 1.3, 0.64, 1);
}
@keyframes modal-in {
  from { opacity: 0; transform: translateY(16px) scale(0.97); }
  to { opacity: 1; transform: none; }
}
.modal-lg { max-width: 780px; }
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
  font-weight: 700; font-size: 15px;
}
.modal-body { padding: 20px; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.modal-foot {
  display: flex; justify-content: flex-end; gap: 10px;
  padding: 14px 20px; border-top: 1px solid var(--border);
  background: var(--bg-sunken);
}
.close-x { font-size: 22px; line-height: 1; color: var(--text-faint); cursor: pointer; padding: 0 4px; }
.close-x:hover { color: var(--text); }

.divider { border: none; border-top: 1px solid var(--border); margin: 16px 0; }

/* ============================================================
   提示条
   ============================================================ */

.toast-wrap {
  position: fixed; top: calc(16px + var(--safe-top)); left: 50%;
  transform: translateX(-50%); z-index: 1200;
  display: flex; flex-direction: column; gap: 8px;
  pointer-events: none; width: max-content; max-width: calc(100vw - 32px);
}
.toast {
  padding: 11px 20px; border-radius: var(--radius-pill);
  background: var(--text); color: #FFF8E7;
  font-size: 13px; font-weight: 500;
  box-shadow: var(--shadow-lg);
  animation: toast-in 0.22s ease;
}
.toast-success { background: var(--success); color: #fff; }
.toast-error { background: var(--danger); color: #fff; }
.toast-warning { background: var(--warning); color: #fff; }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: none; }
}

/* ============================================================
   登录页
   ============================================================ */

.login-page {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  background:
    radial-gradient(circle at 12% 8%, var(--brand-glow), transparent 46%),
    radial-gradient(circle at 88% 92%, rgba(155, 71, 0, 0.18), transparent 42%),
    var(--bg);
}
.login-card {
  width: 100%; max-width: 390px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  padding: 36px 30px 26px;
}
.login-logo {
  width: 56px; height: 56px; border-radius: var(--radius-lg);
  background: linear-gradient(135deg, var(--brand), #FFE066);
  display: flex; align-items: center; justify-content: center;
  font-size: 26px; margin: 0 auto 16px;
  box-shadow: var(--shadow-brand);
}

/* ============================================================
   滚动条
   ============================================================ */

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--outline); }

/* ============================================================
   移动端基础适配
   ============================================================ */

/* 移动端点击反馈：去掉 hover 悬停态带来的粘滞感 */
@media (hover: none) {
  .table tbody tr:hover { background: transparent; }
  .btn:hover:not(:disabled) { border-color: var(--border-strong); background: var(--bg-elevated); }
  .btn-primary:hover:not(:disabled) { background: var(--brand); box-shadow: var(--shadow-sm); }
  .btn-accent:hover:not(:disabled) { background: var(--accent); }
  .btn-danger:hover:not(:disabled) { background: var(--danger); }
}

/* 移动端表单与按钮：加大触摸目标 */
@media (max-width: 768px) {
  .input, .select { padding: 11px 13px; font-size: 15px; }  /* ≥16px 可避免 iOS 自动缩放，这里配合 viewport 已禁用 */
  .btn { padding: 9px 16px; }
  .btn-sm { padding: 7px 13px; font-size: 13px; }
  .btn-xs { padding: 5px 11px; font-size: 12px; }

  .modal-mask { padding: 0; align-items: flex-end; }
  .modal {
    max-width: 100%; max-height: 92vh;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    animation: sheet-in 0.26s cubic-bezier(0.34, 1.2, 0.64, 1);
  }
  @keyframes sheet-in {
    from { transform: translateY(100%); }
    to { transform: none; }
  }
  .modal-body { padding: 16px 18px; }
  .modal-foot {
    padding: 12px 18px calc(12px + var(--safe-bottom));
    display: grid; grid-template-columns: 1fr 1fr;
  }
  .modal-foot .btn { width: 100%; }
  .modal-foot .btn:only-child { grid-column: 1 / -1; }

  .toast-wrap { top: auto; bottom: calc(20px + var(--safe-bottom)); }
  .toast { animation: toast-up 0.22s ease; }
  @keyframes toast-up {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: none; }
  }

  .login-card { padding: 30px 22px 22px; border-radius: var(--radius-lg); }
}
