/* =============================================
   图幻赋能平台 · 基础样式 (base.css)
   主色：#6E359E (紫色) · 参考 doc/index.html
   ============================================= */
:root {
  --primary: #6E359E;
  --primary-light: #8B4BBE;
  --primary-dark: #4A1F6E;
  --accent: #9333EA;
  --bg: #ffffff;
  --bg-card: #ffffff;
  --bg-surface: #f8f8f8;
  --border: rgba(110, 53, 158, .15);
  --border-glow: rgba(110, 53, 158, .4);
  --text: #333333;
  --text-muted: #666666;
  --text-dim: #999999;
  --success: #16a34a;
  --warning: #ca8a04;
  --danger: #dc2626;
  --info: #0891b2;
  --glow: 0 4px 20px rgba(110, 53, 158, .15);
  --glow-sm: 0 2px 10px rgba(110, 53, 158, .12);
  --radius: 12px;
  --radius-sm: 8px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: 'PingFang SC', 'Microsoft YaHei', 'Segoe UI', sans-serif;
  background: var(--bg-surface);
  color: var(--text);
  line-height: 1.6;
  font-size: 14px;
}
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--accent); }
img { max-width: 100%; }

/* ── 排版 ── */
h1, h2, h3, h4, h5, h6 { font-weight: 700; line-height: 1.3; color: var(--text); }
h1 { font-size: 1.8rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.2rem; }
h4 { font-size: 1rem; }

/* ── 按钮 ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  padding: 8px 18px; border-radius: var(--radius-sm);
  border: none; cursor: pointer; font-size: 13px; font-weight: 500;
  font-family: inherit; transition: all .2s; white-space: nowrap;
  text-align: center; text-decoration: none;
}
.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff; box-shadow: var(--glow-sm);
}
.btn-primary:hover { opacity: .9; transform: translateY(-1px); box-shadow: var(--glow); }
.btn-secondary { background: var(--bg-surface); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { border-color: var(--primary); color: var(--primary); background: rgba(110,53,158,.05); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { opacity: .9; }
.btn-success { background: var(--success); color: #fff; }
.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn-lg { padding: 12px 28px; font-size: 15px; }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none !important; }

/* ── 表单 ── */
.form-group { margin-bottom: 18px; }
.form-label { display: block; font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.form-label .required { color: var(--danger); margin-left: 2px; }
.form-control {
  width: 100%; padding: 9px 12px; border-radius: var(--radius-sm);
  border: 1px solid #ddd; font-family: inherit; font-size: 14px;
  color: var(--text); background: #fff; transition: border-color .2s;
  outline: none;
}
.form-control:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(110,53,158,.1); }
.form-control.error { border-color: var(--danger); }
.form-hint { font-size: 12px; color: var(--text-dim); margin-top: 4px; }
.form-error { font-size: 12px; color: var(--danger); margin-top: 4px; }
select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 80px; }

/* ── 卡片 ── */
.card {
  background: var(--bg-card); border-radius: var(--radius);
  border: 1px solid var(--border); box-shadow: var(--glow-sm);
  overflow: hidden;
}
.card-header {
  padding: 16px 20px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.card-title { font-size: 1rem; font-weight: 700; }
.card-body { padding: 20px; }

/* ── 表格 ── */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 11px 14px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table th { font-size: 12px; font-weight: 600; color: var(--text-muted); background: var(--bg-surface); white-space: nowrap; }
.table tbody tr:hover { background: rgba(110,53,158,.03); }
.table tbody tr:last-child td { border-bottom: none; }
/* 操作列：单元格本身必须保持 table-cell。
   给 <td> 直接写 display:flex 会让它退出表格布局算法——该列不再与表头
   「操作」对齐，按钮也会被拉伸到整行高度、与同行其它字段错位。
   正确做法是单元格不动，只让内部按钮横向排布（.btn 本身已是 inline-flex）。 */
.table .actions { white-space: nowrap; }
.table .actions > * + * { margin-left: 6px; }

/* ── 标签 ── */
.badge {
  display: inline-block; padding: 2px 8px; border-radius: 4px;
  font-size: 11px; font-weight: 600; white-space: nowrap;
}
.badge-primary { background: rgba(110,53,158,.12); color: var(--primary); }
.badge-success { background: rgba(22,163,74,.12); color: var(--success); }
.badge-danger { background: rgba(220,38,38,.12); color: var(--danger); }
.badge-warning { background: rgba(202,138,4,.12); color: var(--warning); }
.badge-info { background: rgba(8,145,178,.12); color: var(--info); }
.badge-secondary { background: var(--bg-surface); color: var(--text-muted); border: 1px solid var(--border); }

/* ── 分页 ── */
.pagination { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.page-item { display: inline-flex; }
.page-link {
  padding: 6px 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); color: var(--text-muted);
  font-size: 13px; cursor: pointer; transition: all .2s;
}
.page-link:hover { border-color: var(--primary); color: var(--primary); background: rgba(110,53,158,.05); }
.page-item.active .page-link { background: var(--primary); color: #fff; border-color: var(--primary); }
.page-item.disabled .page-link { opacity: .4; cursor: not-allowed; }

/* ── 消息提示 ── */
.alert {
  padding: 12px 16px; border-radius: var(--radius-sm);
  border: 1px solid transparent; font-size: 13px; margin-bottom: 12px;
}
.alert-success { background: rgba(22,163,74,.08); border-color: rgba(22,163,74,.3); color: #15803d; }
.alert-danger { background: rgba(220,38,38,.08); border-color: rgba(220,38,38,.3); color: #b91c1c; }
.alert-warning { background: rgba(202,138,4,.08); border-color: rgba(202,138,4,.3); color: #92400e; }
.alert-info { background: rgba(8,145,178,.08); border-color: rgba(8,145,178,.3); color: #0e7490; }

/* ── 进度条 ── */
.progress { height: 8px; background: var(--bg-surface); border-radius: 4px; overflow: hidden; }
.progress-bar {
  height: 100%; border-radius: 4px;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  transition: width .5s ease;
}

/* ── 搜索框 ── */
.search-box { position: relative; }
.search-box .form-control { padding-left: 34px; }
.search-box .search-icon {
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  color: var(--text-dim); font-size: 14px; pointer-events: none;
}

/* ── 统计卡片 ── */
.stat-card {
  background: var(--bg-card); border-radius: var(--radius);
  padding: 20px 22px; border: 1px solid var(--border); box-shadow: var(--glow-sm);
}
.stat-card .stat-label { font-size: 12px; color: var(--text-muted); margin-bottom: 8px; }
.stat-card .stat-value {
  font-size: 2rem; font-weight: 700; line-height: 1;
  background: linear-gradient(135deg, var(--primary-light), var(--accent));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}
.stat-card .stat-sub { font-size: 12px; color: var(--text-dim); margin-top: 6px; }

/* ── 空状态 ── */
.empty-state { text-align: center; padding: 60px 20px; color: var(--text-dim); }
.empty-state .empty-icon { font-size: 3rem; margin-bottom: 12px; }
.empty-state p { font-size: 14px; }

/* ── Spinner ── */
.spinner {
  width: 20px; height: 20px; border-radius: 50%;
  border: 2px solid rgba(110,53,158,.2); border-top-color: var(--primary);
  animation: spin .6s linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── 模态框 ── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.4);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000; padding: 20px;
}
.modal { background: #fff; border-radius: var(--radius); width: 100%; max-width: 480px; overflow: hidden; }
.modal-header {
  padding: 18px 22px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-header h4 { font-size: 1rem; }
.modal-close { cursor: pointer; color: var(--text-dim); font-size: 1.2rem; padding: 4px; }
.modal-close:hover { color: var(--text); }
.modal-body { padding: 22px; }
.modal-footer { padding: 14px 22px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }

/* ── Toast ── */
#toast-container { position: fixed; top: 20px; right: 20px; z-index: 9999; display: flex; flex-direction: column; gap: 8px; }
.toast {
  padding: 12px 18px; border-radius: var(--radius-sm); background: #fff;
  border: 1px solid var(--border); box-shadow: 0 4px 20px rgba(0,0,0,.1);
  font-size: 13px; min-width: 240px; max-width: 360px;
  animation: slideIn .3s ease;
}
.toast.success { border-left: 3px solid var(--success); }
.toast.error { border-left: 3px solid var(--danger); }
.toast.warning { border-left: 3px solid var(--warning); }
@keyframes slideIn { from { opacity: 0; transform: translateX(30px); } to { opacity: 1; transform: none; } }

/* ── 通用工具类 ── */
.flex { display: flex; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.flex-wrap { flex-wrap: wrap; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }
.text-muted { color: var(--text-muted); }
.text-dim { color: var(--text-dim); }
.text-primary { color: var(--primary); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-sm { font-size: 12px; }
.text-center { text-align: center; }
.fw-600 { font-weight: 600; }
.w-100 { width: 100%; }
.hidden { display: none !important; }
