/* ============================================================
   盟娱后台 · 统一组件范式 v1（依赖 tokens.css，在 admin.css 之后引入）
   第一批范围（安全 / 可回滚，不动仪表盘深色大屏）：
     1) 状态标签语义统一：同一状态在订单/财务/营销全端同色同形。
        通过给既有 .os-* / .tag-* 赋同一语义变量实现，不改 JS class 名。
     2) 统计卡片范式令牌化：财务 stat-card 对齐设计令牌。
   后续批次：仪表盘深浅统一（dash-screen 大屏模式与浅色日常模式切换）。
   ============================================================ */

/* ---------- 1. 状态标签统一基底（胶囊形 / 统一字号内边距） ---------- */
.tag, [class^="os-"], [class*=" os-"] {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: var(--fs-xs);
  font-weight: 500;
  line-height: 1.4;
  white-space: nowrap;
}

/* 语义映射 · 成功（已完成 / 已使用 / 已核销 / 到账 / 上架 / 通过） */
.os-finished, .os-used,
.tag-finished, .tag-used, .tag-gain, .tag-up, .tag-accepted {
  color: var(--success) !important; background: var(--success-bg) !important;
}
/* 警告（待发货 / 待审核 / 进行中 / 退款处理中 / 满） */
.os-paid, .os-refunding,
.tag-pending, .tag-full {
  color: var(--warning) !important; background: var(--warning-bg) !important;
}
/* 危险（已退款 / 已取消 / 支出 / 驳回） */
.os-refund, .os-cancel,
.tag-cancelled, .tag-cost {
  color: var(--danger) !important; background: var(--danger-bg) !important;
}
/* 信息（待使用 / 已支付 / 配送中 / 现金） */
.os-unused, .os-shipped,
.tag-unused, .tag-paid, .tag-shipped, .tag-cash {
  color: var(--info) !important; background: var(--info-bg) !important;
}
/* 中性（待付款 / 已结束 / 已驳回 / 停用） */
.os-unpaid, .os-rejected,
.tag-unpaid, .tag-ended {
  color: var(--neutral) !important; background: var(--neutral-bg) !important;
}

/* ---------- 2. 统计卡片范式（浅色 · 令牌化） ---------- */
.stat-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-left: 3px solid var(--brand);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-md);
  padding: var(--sp-4) var(--sp-5);
}

/* ---------- 3. 通用卡片描边令牌化（dash-card 等浅色卡片统一圆角/阴影/描边） ---------- */
.dash-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-md);
}

/* ---------- 4. 可访问性 · 键盘聚焦环（WCAG 2.1-AA 基础） ---------- */
button:focus-visible, a:focus-visible, input:focus-visible,
select:focus-visible, textarea:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

/* ---------- 5. 空状态统一范式（图标 + 主说明 + 业务引导） ---------- */
.empty {
  padding: 52px 16px;
  color: var(--neutral);
  font-size: 13px;
  line-height: 1.9;
  background: transparent;
}
.empty::before {
  content: '';
  display: block;
  width: 46px; height: 46px;
  margin: 0 auto 12px;
  border-radius: 50%;
  background: var(--neutral-bg) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236b7787' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 7.5 12 3l9 4.5v9L12 21l-9-4.5z'/%3E%3Cpath d='M3 7.5 12 12l9-4.5'/%3E%3Cpath d='M12 12v9'/%3E%3C/svg%3E") center/22px 22px no-repeat;
}

/* ---------- 6. 小屏办公分辨率（≤1440px）· 宽表横向滚动降级 ---------- */
@media (max-width: 1440px) {
  .panel.active { overflow-x: auto; }
  .panel.active table th, .panel.active table td { white-space: nowrap; }
}

/* ---------- 7. 表单必填标记统一（在 label 上加 .req 类） ---------- */
label.req::after, .form-label.req::after {
  content: '*';
  color: var(--danger);
  margin-left: 3px;
  font-weight: 600;
}

/* ---------- 8. Toast（替代原生 alert 的非阻塞提示） ---------- */
.ui-toast-wrap {
  position: fixed; top: 20px; right: 20px; z-index: 99999;
  display: flex; flex-direction: column; gap: 10px; pointer-events: none;
}
.ui-toast {
  max-width: 380px; padding: 11px 16px;
  border-radius: var(--r-md, 10px); background: #fff; color: #333;
  font-size: 13.5px; line-height: 1.6;
  box-shadow: 0 8px 28px rgba(15, 23, 42, .16);
  border-left: 3px solid var(--info);
  opacity: 0; transform: translateY(-8px);
  transition: opacity .22s ease, transform .22s ease;
  pointer-events: auto; word-break: break-word;
}
.ui-toast.show { opacity: 1; transform: none; }
.ui-toast.error { border-left-color: var(--danger); }
.ui-toast.success { border-left-color: var(--success); }
.ui-toast.warn { border-left-color: var(--warning); }

/* ---------- 9. Dialog（统一确认框，支持危险操作红色确认钮） ---------- */
.ui-dialog-mask {
  position: fixed; inset: 0; z-index: 100000;
  background: rgba(15, 23, 42, .45);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.ui-dialog {
  width: 440px; max-width: 100%; background: #fff;
  border-radius: var(--r-lg, 14px);
  box-shadow: 0 24px 64px rgba(15, 23, 42, .28);
  padding: 22px 24px 18px;
  animation: uiDialogIn .18s ease;
}
@keyframes uiDialogIn {
  from { opacity: 0; transform: translateY(8px) scale(.98); }
  to { opacity: 1; transform: none; }
}
.ui-dialog-title { font-size: 16px; font-weight: 600; color: #1f2937; margin-bottom: 10px; }
.ui-dialog-body { font-size: 13.5px; color: #4b5563; line-height: 1.8; }
.ui-dialog-hint {
  margin-top: 10px; padding: 9px 12px;
  background: var(--warning-bg); color: var(--warning);
  font-size: 12.5px; border-radius: 8px; line-height: 1.7;
}
.ui-dialog-foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.ui-btn-danger { background: var(--danger) !important; border-color: var(--danger) !important; color: #fff !important; }

/* ---------- 10. 骨架屏 ---------- */
.ui-skeleton-line {
  height: 14px; border-radius: 6px; margin: 10px 0;
  background: linear-gradient(90deg, #f0f1f3 25%, #e7e9ec 37%, #f0f1f3 63%);
  background-size: 400% 100%;
  animation: uiSkeleton 1.2s ease infinite;
}
@keyframes uiSkeleton {
  from { background-position: 100% 50%; }
  to { background-position: 0 50%; }
}

/* ---------- 11. 字段级校验反馈 ---------- */
.ui-dialog-input {
  width: 100%; margin-top: 12px; padding: 9px 12px;
  border: 1px solid var(--line); border-radius: 8px; font-size: 13.5px;
  box-sizing: border-box; outline: none;
}
.ui-dialog-input:focus { border-color: var(--brand); box-shadow: 0 0 0 2px rgba(255, 59, 84, .12); }
.ui-dialog-tip { color: var(--danger); font-size: 12px; line-height: 1.6; margin-top: 6px; }
.ui-invalid {
  border-color: var(--danger) !important;
  box-shadow: 0 0 0 2px var(--danger-bg) !important;
}
.ui-field-tip {
  color: var(--danger);
  font-size: 12px;
  line-height: 1.6;
  margin-top: 4px;
}
