/* ============================================================
 * 会员系统前端样式（membership.js / usage.js / admin-membership.js 共用）
 * 仅新增样式，不覆盖现有组件
 * ============================================================ */

/* ===================== 会员身份徽章 ===================== */
.mem-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  line-height: 18px;
  white-space: nowrap;
  vertical-align: middle;
}
.mem-badge-free { background: var(--bg4, #e5e7eb); color: var(--muted, #4b5563); }
.mem-badge-pro  { background: var(--accent-light, #DBEAFE); color: var(--accent, #2563EB); }
.mem-badge-max  { background: linear-gradient(135deg, var(--accent-light, #DBEAFE), var(--purple-light, #EDE9FE)); color: var(--purple, #7C3AED); }
.mem-badge .mem-badge-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .8; }

/* ===================== 存储空间进度条（素材库顶部 / 个人中心） ===================== */
.mem-storage-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  background: rgba(99, 102, 241, 0.06);
  border: 1px solid rgba(99, 102, 241, 0.15);
  border-radius: 10px;
  font-size: 13px;
  color: #374151;
  max-width: 520px;
}
.mem-storage-bar .mem-storage-icon { font-size: 16px; flex-shrink: 0; }
.mem-storage-bar .mem-storage-track {
  flex: 1;
  height: 8px;
  background: #e5e7eb;
  border-radius: 999px;
  overflow: hidden;
  min-width: 80px;
}
.mem-storage-bar .mem-storage-fill {
  height: 100%;
  border-radius: 999px;
  transition: width .4s ease;
  background: linear-gradient(90deg, #6366f1, #8b5cf6);
}
.mem-storage-bar .mem-storage-fill.warn { background: linear-gradient(90deg, #f59e0b, #f97316); }
.mem-storage-bar .mem-storage-fill.danger { background: linear-gradient(90deg, #ef4444, #dc2626); }
.mem-storage-bar .mem-storage-text { white-space: nowrap; font-variant-numeric: tabular-nums; }
.mem-storage-bar .mem-storage-text strong { color: #111827; }
.mem-storage-bar .mem-storage-hint { font-size: 11px; color: #ef4444; margin-left: 4px; }

/* ===================== 升级弹窗（自定义，替代 alert） ===================== */
.mem-modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(17, 24, 39, 0.55);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  opacity: 0;
  transition: opacity .2s ease;
}
.mem-modal-mask.show { opacity: 1; }
.mem-modal {
  width: 92%;
  max-width: 420px;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
  overflow: hidden;
  transform: translateY(12px) scale(.98);
  transition: transform .22s cubic-bezier(.2, .8, .2, 1);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}
.mem-modal-mask.show .mem-modal { transform: translateY(0) scale(1); }
.mem-modal-head {
  padding: 24px 24px 12px;
  text-align: center;
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  color: #fff;
}
.mem-modal-head.max { background: linear-gradient(135deg, #f59e0b 0%, #ef4444 100%); }
.mem-modal-icon { font-size: 34px; line-height: 1; }
.mem-modal-title { margin-top: 8px; font-size: 18px; font-weight: 700; }
.mem-modal-body { padding: 18px 24px 8px; }
.mem-modal-msg { font-size: 14px; color: #374151; line-height: 1.6; text-align: center; }
.mem-modal-plans { margin: 14px 0 4px; display: flex; flex-direction: column; gap: 8px; }
.mem-modal-plan {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.mem-modal-plan:hover { border-color: #8b5cf6; background: rgba(139, 92, 246, 0.05); }
.mem-modal-plan-name { font-weight: 600; font-size: 14px; color: #111827; }
.mem-modal-plan-desc { font-size: 12px; color: #6b7280; margin-top: 2px; }
.mem-modal-plan-price { font-size: 13px; color: #6366f1; font-weight: 600; white-space: nowrap; }
.mem-modal-foot { padding: 10px 24px 20px; display: flex; gap: 10px; }
.mem-modal-btn {
  flex: 1;
  padding: 10px 0;
  border-radius: 10px;
  border: none;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.mem-modal-btn-primary { background: #6366f1; color: #fff; }
.mem-modal-btn-primary:hover { background: #4f46e5; }
.mem-modal-btn-ghost { background: #f3f4f6; color: #4b5563; }
.mem-modal-btn-ghost:hover { background: #e5e7eb; }

/* ===================== 用量管理页面（dashboard 用量视图） ===================== */
.mem-usage-section { margin-bottom: 20px; }
.mem-usage-card {
  background: var(--bg);
  border: 1px solid var(--rule);
  border-radius: 14px;
  padding: 20px;
  margin-bottom: 16px;
}
.mem-usage-card-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
  margin: 0 0 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.mem-usage-row { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.mem-usage-metric { flex: 1; min-width: 200px; }
.mem-usage-metric-label { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.mem-usage-metric-value { font-size: 22px; font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; }
.mem-usage-metric-value small { font-size: 13px; color: var(--muted2); font-weight: 500; }
.mem-usage-progress {
  height: 10px;
  background: var(--bg4);
  border-radius: 999px;
  overflow: hidden;
  margin-top: 8px;
}
.mem-usage-progress-fill {
  height: 100%;
  border-radius: 999px;
  transition: width .5s ease;
  background: linear-gradient(90deg, #6366f1, #8b5cf6);
}
.mem-usage-progress-fill.warn { background: linear-gradient(90deg, #f59e0b, #f97316); }
.mem-usage-progress-fill.danger { background: linear-gradient(90deg, #ef4444, #dc2626); }
.mem-usage-meta { font-size: 12px; color: var(--muted2); margin-top: 6px; }
.mem-usage-actions { display: flex; gap: 10px; margin-top: 14px; }
.mem-usage-btn {
  padding: 8px 16px;
  border-radius: 8px;
  border: 1px solid var(--rule);
  background: var(--bg);
  font-size: 13px;
  color: var(--ink);
  cursor: pointer;
  transition: background .15s, border-color .15s;
}
.mem-usage-btn:hover { background: var(--bg3); border-color: var(--rule); }
.mem-usage-btn.primary { background: #6366f1; color: #fff; border-color: #6366f1; }
.mem-usage-btn.primary:hover { background: #4f46e5; }

/* 积分消耗日志表 */
.mem-logs-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.mem-logs-table th {
  text-align: left;
  padding: 8px 10px;
  background: var(--bg4);
  color: var(--muted);
  font-weight: 600;
  border-bottom: 1px solid var(--rule);
  white-space: nowrap;
}
.mem-logs-table td { padding: 9px 10px; border-bottom: 1px solid var(--rule); color: var(--ink); }
.mem-logs-table tr:hover td { background: var(--bg4); }
.mem-log-delta { font-weight: 600; font-variant-numeric: tabular-nums; }
.mem-log-delta.pos { color: var(--green); }
.mem-log-delta.neg { color: var(--red); }
.mem-log-action-tag {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 6px;
  font-size: 11px;
  background: var(--accent-light);
  color: var(--accent);
}
.mem-log-action-tag.grant { background: var(--green-bg); color: var(--green); }
.mem-log-action-tag.adjust { background: var(--orange-bg); color: var(--orange); }
.mem-logs-empty { text-align: center; padding: 32px 0; color: var(--muted2); font-size: 13px; }
.mem-logs-pager { display: flex; align-items: center; justify-content: space-between; margin-top: 12px; font-size: 13px; color: var(--muted); }
.mem-logs-pager button { padding: 6px 14px; border-radius: 8px; border: 1px solid var(--rule); background: var(--bg); cursor: pointer; font-size: 13px; }
.mem-logs-pager button:disabled { opacity: .4; cursor: not-allowed; }

/* 订阅方案页会员状态面板 */
.mem-status-panel {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.08), rgba(139, 92, 246, 0.06));
  border: 1px solid rgba(99, 102, 241, 0.2);
  border-radius: 14px;
  padding: 18px 20px;
  margin-bottom: 16px;
}
.mem-status-panel-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; }
.mem-status-panel-title { font-size: 15px; font-weight: 600; color: var(--ink); }
.mem-status-panel-expire { font-size: 12px; color: var(--muted); }
.mem-status-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin-top: 14px; }
.mem-status-item-label { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.mem-status-item-value { font-size: 16px; font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; }
/* 深色模式：增强面板背景与边框可见度 */
:root[data-theme="dark"] .mem-status-panel {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.14), rgba(139, 92, 246, 0.10));
  border-color: rgba(99, 102, 241, 0.35);
}

/* ===================== 管理后台会员管理面板 ===================== */
.mem-admin-panel { background: #fff; border: 1px solid #e5e7eb; border-radius: 12px; padding: 18px; margin-bottom: 16px; }
.mem-admin-form { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 16px; }
.mem-admin-field { display: flex; flex-direction: column; gap: 4px; }
.mem-admin-field label { font-size: 12px; color: #6b7280; }
.mem-admin-field input, .mem-admin-field select {
  padding: 7px 10px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font-size: 13px;
  min-width: 120px;
}
.mem-admin-btn {
  padding: 8px 16px;
  border-radius: 8px;
  border: none;
  background: #6366f1;
  color: #fff;
  font-size: 13px;
  cursor: pointer;
  font-weight: 600;
}
.mem-admin-btn:hover { background: #4f46e5; }
.mem-admin-btn.ghost { background: #f3f4f6; color: #4b5563; }
.mem-admin-btn.ghost:hover { background: #e5e7eb; }
.mem-admin-state { font-size: 13px; color: #374151; line-height: 1.7; }
.mem-admin-state strong { color: #111827; }

/* 后台会员管理 toast */
.mem-admin-toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 10001;
  padding: 12px 20px;
  border-radius: 10px;
  font-size: 13px;
  color: #fff;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
  max-width: 360px;
}
.mem-admin-toast.info { background: #6366f1; }
.mem-admin-toast.success { background: #059669; }
.mem-admin-toast.error { background: #dc2626; }

/* 自定义确认弹窗（替代原生 confirm） */
.mem-confirm-mask {
  position: fixed; inset: 0; background: rgba(17, 24, 39, 0.5);
  display: flex; align-items: center; justify-content: center; z-index: 10002;
}
.mem-confirm-box {
  width: 90%; max-width: 380px; background: #fff; border-radius: 14px;
  padding: 22px 22px 18px; box-shadow: 0 20px 50px rgba(0, 0, 0, 0.2);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}
.mem-confirm-title { font-size: 16px; font-weight: 600; color: #111827; margin-bottom: 8px; }
.mem-confirm-msg { font-size: 14px; color: #4b5563; line-height: 1.6; margin-bottom: 16px; }
.mem-confirm-actions { display: flex; gap: 10px; justify-content: flex-end; }

@media (max-width: 640px) {
  .mem-storage-bar { max-width: 100%; }
  .mem-modal { max-width: 96%; }
  .mem-status-grid { grid-template-columns: 1fr 1fr; }
}
