/* ============================================================
   components.css — 通用组件（Apple Cupertino 版）：
   分组白卡、黑白按钮、填充式输入框、iOS 开关、分组列表表格、
   胶囊徽标、Alert 弹窗、横幅 toast、大数字统计卡
   ============================================================ */

/* ========== 分组白卡（iOS inset-grouped 容器） ========== */
.card {
  position: relative;
  background: var(--surface);
  border: .5px solid var(--sep);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  padding: 20px 22px; margin-bottom: 18px;
}
.card-title { font-size: 16px; font-weight: 600; margin-bottom: 14px; color: var(--text-1); }
.card-head-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.card-head-row .card-title { margin-bottom: 0; }

/* ========== 按钮：黑主按钮 / 灰次按钮 / 蓝文字按钮 / 红危险 ========== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 16px; border-radius: var(--radius-ctl);
  border: none;
  background: var(--fill);
  color: var(--text-1); font-size: 14px; font-weight: 500; cursor: pointer;
  font-family: inherit;
  transition: opacity var(--dur-fast) var(--ease-ios), background var(--dur-fast) var(--ease-ios);
}
.btn:hover { background: var(--fill-hover); }
.btn:active { opacity: .6; } /* iOS 高亮反馈：透明度下沉 */
.btn:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.btn-primary { background: var(--btn-primary-bg); color: var(--btn-primary-text); font-weight: 600; }
.btn-primary:hover { background: var(--btn-primary-bg); opacity: .85; }
.btn-primary:active { opacity: .7; }
.btn-danger { background: var(--danger); color: #FFF; font-weight: 600; }
.btn-danger:hover { opacity: .85; }
.btn-ghost { background: transparent; color: var(--accent); }
.btn-ghost:hover { background: var(--accent-soft); }
.btn-sm { padding: 5px 12px; font-size: 13px; border-radius: 8px; }
.btn-block { width: 100%; padding: 12px 16px; font-size: 15px; font-weight: 600; border-radius: 12px; }
.btn:disabled { opacity: .35; cursor: not-allowed; }

/* ========== 表单：iOS 填充式输入（灰底无框，聚焦出蓝环） ========== */
.field { margin-bottom: 16px; }
.field label { display: block; margin-bottom: 6px; color: var(--text-2); font-size: 13px; font-weight: 500; }
.field input, .field select, .field textarea {
  width: 100%; padding: 10px 12px;
  border: none; border-radius: var(--radius-ctl); font-size: 14px; font-family: inherit;
  background: var(--fill);
  color: var(--text-1);
  caret-color: var(--accent);
  transition: box-shadow var(--dur-fast) var(--ease-ios), background var(--dur-fast) var(--ease-ios);
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; background: var(--surface); box-shadow: var(--focus-ring);
}
.field select option { background: var(--surface); color: var(--text-1); }
.field input::placeholder, .field textarea::placeholder { color: var(--text-3); }
.field textarea { resize: vertical; min-height: 90px; }
.hint { margin-top: 4px; font-size: 12px; color: var(--text-2); }
.form-row { display: flex; gap: 14px; }
.form-row .field { flex: 1; min-width: 0; }

/* 所有勾选框统一渲染为 iOS 开关（CupertinoSwitch） */
input[type="checkbox"] {
  -webkit-appearance: none; appearance: none;
  width: 40px; height: 24px; flex: none; margin: 0;
  border-radius: 999px; cursor: pointer;
  background: rgba(120, 120, 128, .28);
  position: relative;
  transition: background var(--dur-med) var(--ease-ios);
}
input[type="checkbox"]::after {
  content: ''; position: absolute; top: 2px; left: 2px;
  width: 20px; height: 20px; border-radius: 50%;
  background: #FFF;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .25), 0 0 0 .5px rgba(0, 0, 0, .04);
  transition: transform var(--dur-med) var(--ease-spring);
}
input[type="checkbox"]:checked { background: var(--btn-primary-bg); }
input[type="checkbox"]:checked::after { transform: translateX(16px); }
input[type="checkbox"]:focus-visible { box-shadow: var(--focus-ring); }

/* ========== 工具栏 ========== */
.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
.toolbar label { color: var(--text-2); font-size: 13px; }
.toolbar select, .toolbar input {
  padding: 7px 12px; border: none; border-radius: var(--radius-ctl);
  background: var(--fill);
  color: var(--text-1);
  font-size: 13px; font-family: inherit;
  caret-color: var(--accent);
  transition: box-shadow var(--dur-fast) var(--ease-ios), background var(--dur-fast) var(--ease-ios);
}
.toolbar select:focus, .toolbar input:focus { outline: none; background: var(--surface); box-shadow: var(--focus-ring); }
.toolbar select option { background: var(--surface); }
.toolbar .spacer { flex: 1; }

/* ========== 表格：iOS 分组列表 —— 小号灰色表头 + 发丝分隔 ========== */
.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left; padding: 6px 12px; color: var(--text-2);
  font-weight: 500; font-size: 12px; letter-spacing: .04em; text-transform: uppercase;
  white-space: nowrap; border: none;
  border-bottom: .5px solid var(--sep-strong);
}
.table td { padding: 11px 12px; vertical-align: middle; border-bottom: .5px solid var(--sep); }
.table tbody tr { transition: background var(--dur-fast) var(--ease-ios); }
.table tbody tr:hover td { background: var(--fill); }
.table tbody tr:last-child td { border-bottom: none; }
.table tr.clickable { cursor: pointer; }
.table code { font-family: var(--mono); font-size: 12.5px; color: var(--text-2); }

/* ========== 徽标：iOS 胶囊标签（浅色底 + 彩色字，黑白灰为默认） ========== */
.badge {
  display: inline-flex; align-items: center;
  padding: 3px 9px; border-radius: 999px;
  font-size: 12px; font-weight: 500; white-space: nowrap;
  background: var(--fill); color: var(--text-2); /* 默认：石墨灰 */
}
/* 蓝：进行中 / 负责人系 */
.badge-in_progress, .badge-extracted, .badge-module,
.badge-role-leader, .badge-role-pm, .badge-leader, .badge-prole-leader {
  background: var(--accent-soft); color: var(--accent);
}
/* 绿：完成 / 通过 / 在用 */
.badge-done, .badge-submitted, .badge-approved, .badge-active, .badge-auto, .badge-prole-fde {
  background: rgba(52, 199, 89, .14); color: #1F8A3D;
}
/* 橙：评审 / 待办 / 停用 / PM */
.badge-review, .badge-pending, .badge-suspended, .badge-role-external, .badge-prole-pm {
  background: rgba(255, 149, 0, .14); color: #C93400;
}
/* 红：驳回 / 撤销 / 过期 / 失败 */
.badge-rejected, .badge-revoked, .badge-expired, .badge-failed {
  background: rgba(255, 59, 48, .12); color: #D70015;
}
@media (prefers-color-scheme: dark) {
  .badge-done, .badge-submitted, .badge-approved, .badge-active, .badge-auto, .badge-prole-fde { color: #30D158; }
  .badge-review, .badge-pending, .badge-suspended, .badge-role-external, .badge-prole-pm { color: #FF9F0A; }
  .badge-rejected, .badge-revoked, .badge-expired, .badge-failed { color: #FF6961; }
}

/* ========== 弹窗：iOS Alert —— 大圆角白卡 + 雾化遮罩 ========== */
.modal-overlay {
  position: fixed; inset: 0; z-index: 100; padding: 24px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0, 0, 0, .32);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  animation: overlay-in var(--dur-med) var(--ease-ios);
}
@keyframes overlay-in { from { opacity: 0; } }
.modal {
  width: 520px; max-width: 100%; max-height: 86vh;
  display: flex; flex-direction: column;
  background: var(--surface);
  border: .5px solid var(--sep);
  border-radius: 20px;
  box-shadow: var(--shadow-raised);
  animation: modal-in .26s var(--ease-spring);
}
@keyframes modal-in { from { opacity: 0; transform: scale(1.05); } }
.modal.wide { width: 760px; }
.modal-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 20px;
  border-bottom: .5px solid var(--sep);
}
.modal-header h3 { font-size: 16px; font-weight: 600; word-break: break-all; color: var(--text-1); }
.modal-close { /* iOS 关闭钮：灰圆底 × */
  background: var(--fill); border: none;
  width: 28px; height: 28px; border-radius: 50%; flex: none;
  font-size: 15px; cursor: pointer; color: var(--text-2); line-height: 1;
  transition: background var(--dur-fast) var(--ease-ios);
}
.modal-close:hover { background: var(--fill-hover); color: var(--text-1); }
.modal-close:active { opacity: .6; }
.modal-body { padding: 20px; overflow-y: auto; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 16px; align-items: center; }

/* ========== toast：iOS 顶部横幅 —— 毛玻璃胶囊 + 状态小圆点 ========== */
#toast-root {
  position: fixed; top: 18px; left: 50%; transform: translateX(-50%); z-index: 200;
  display: flex; flex-direction: column; gap: 8px; align-items: center;
}
.toast {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 18px; border-radius: 999px; max-width: min(480px, 90vw);
  color: var(--text-1); font-size: 14px; font-weight: 500; word-break: break-all;
  background: rgba(255, 255, 255, .85);
  -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
  border: .5px solid var(--sep);
  box-shadow: var(--shadow-raised);
  animation: toast-in .3s var(--ease-spring);
}
.toast::before { content: ''; width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--text-3); }
.toast-info::before { background: var(--accent); }
.toast-success::before { background: var(--success); }
.toast-error::before { background: var(--danger); }
.toast-out { opacity: 0; transform: translateY(-10px); transition: .28s var(--ease-ios); }
@keyframes toast-in { from { opacity: 0; transform: translateY(-14px) scale(.96); } }
@media (prefers-color-scheme: dark) {
  .toast { background: rgba(44, 44, 46, .85); }
}

/* ========== 统计卡：白卡 + 苹果式大数字（SF Display 风格） ========== */
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat-card {
  position: relative;
  background: var(--surface);
  border: .5px solid var(--sep);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  padding: 18px 20px;
}
.stat-num {
  display: block;
  font-size: 30px; font-weight: 700; letter-spacing: -.02em;
  color: var(--text-1); font-variant-numeric: tabular-nums;
}
.stat-num.warn { color: var(--warning); }
.stat-label {
  color: var(--text-2); margin-top: 6px; font-size: 12px;
  letter-spacing: .04em; text-transform: uppercase;
}
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip {
  background: var(--fill);
  color: var(--text-2);
  border-radius: 999px; padding: 3px 10px; font-size: 12px;
}

/* ========== 详情描述网格 / 任务点 ========== */
.desc-grid { display: grid; grid-template-columns: 90px 1fr; row-gap: 10px; column-gap: 12px; margin-bottom: 12px; }
.desc-grid dt { color: var(--text-2); font-size: 13px; }
.desc-grid dd { word-break: break-all; }
.task-desc {
  background: var(--fill); border-radius: var(--radius-ctl);
  padding: 13px; white-space: pre-wrap; word-break: break-all; margin-bottom: 4px;
  color: var(--text-1);
}
.points-list { margin-bottom: 12px; }
.point-item { padding: 11px 0; border-bottom: .5px solid var(--sep); }
.point-item:last-child { border-bottom: none; }
.point-meta { color: var(--text-2); font-size: 12px; margin-bottom: 4px; }
.point-form textarea {
  width: 100%; padding: 10px 12px; border: none; border-radius: var(--radius-ctl);
  font-size: 14px; font-family: inherit; min-height: 70px; resize: vertical; margin-bottom: 8px;
  background: var(--fill);
  color: var(--text-1);
  caret-color: var(--accent);
  transition: box-shadow var(--dur-fast) var(--ease-ios), background var(--dur-fast) var(--ease-ios);
}
.point-form textarea:focus { outline: none; background: var(--surface); box-shadow: var(--focus-ring); }

/* ========== 令牌行：灰底等宽读数 ========== */
.token-row {
  display: flex; gap: 10px; align-items: center;
  background: var(--fill);
  border-radius: var(--radius-ctl); padding: 10px 14px;
}
.token-row code { flex: 1; font-family: var(--mono); font-size: 13px; word-break: break-all; color: var(--text-1); }

/* ========== 空状态 ========== */
.empty { text-align: center; color: var(--text-3); padding: 36px 0; font-size: 14px; }

/* ========== 入场动画：stagger fade-up（由 fx.js 加 .fx-enter 触发） ========== */
.fx-enter { opacity: 0; animation: fx-fade-up .45s var(--ease-ios) forwards; }
@keyframes fx-fade-up { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* Cupertino 无 3D 倾斜：压掉 fx.js 的内联 transform，仅保留阴影反馈 */
[data-tilt] { transform: none !important; will-change: auto; }
