/* ============================================================
   找到 · 管理后台 — 组件样式
   表格 / 表单 / 卡片 / 弹窗 / 分页 / 标签 / 图表容器
   ============================================================ */

/* ---------- 页面容器 ---------- */
.page { animation: pageIn 0.2s ease; }
@keyframes pageIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.page-title { font-size: 18px; font-weight: 700; }

.page-desc { font-size: 13px; color: var(--text-2); }

/* ---------- 卡片 ---------- */
.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 16px;
}

.card-title {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}

/* 统计卡片 */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}

.stat-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  position: relative;
  overflow: hidden;
}

.stat-card .stat-label { font-size: 13px; color: var(--text-2); }
.stat-card .stat-value {
  font-size: 26px;
  font-weight: 700;
  margin-top: 6px;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.stat-card .stat-sub { font-size: 12px; color: var(--text-3); margin-top: 4px; }
.stat-card .stat-icon {
  position: absolute;
  right: 12px;
  top: 12px;
  font-size: 22px;
  opacity: 0.25;
}

/* 图表容器 */
.chart-box {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 16px;
}

.chart-box canvas { width: 100%; height: 280px; display: block; }

.chart-legend { font-size: 13px; color: var(--text-2); margin-top: 8px; }

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; }

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  min-width: 640px;
}

.table th, .table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.table th {
  background: #f9fafb;
  color: var(--text-2);
  font-weight: 600;
  font-size: 12px;
}

.table tbody tr:hover { background: #f8fafc; }

.table .cell-main { color: var(--text); font-weight: 500; }
.table .cell-sub { color: var(--text-3); font-size: 12px; }

/* 移动端表格卡片化 */
@media (max-width: 767px) {
  .table { min-width: 0; }
  .table-card-mode thead { display: none; }
  .table-card-mode tbody tr {
    display: block;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-bottom: 10px;
    padding: 10px 12px;
  }
  .table-card-mode tbody tr:hover { background: var(--card-bg); }
  .table-card-mode td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px dashed var(--border);
    white-space: normal;
    text-align: right;
    gap: 12px;
  }
  .table-card-mode td:last-child { border-bottom: none; }
  .table-card-mode td::before {
    content: attr(data-label);
    font-weight: 600;
    color: var(--text-2);
    text-align: left;
    flex-shrink: 0;
  }
}

/* ---------- 标签 ---------- */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 12px;
  line-height: 1.6;
}

.badge-success { background: var(--success-light); color: var(--success); }
.badge-warning { background: var(--warning-light); color: var(--warning); }
.badge-danger { background: var(--danger-light); color: var(--danger); }
.badge-info { background: var(--info-light); color: var(--info); }
.badge-gray { background: #f1f3f5; color: var(--text-2); }
.badge-primary { background: var(--primary-light); color: var(--primary); }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s ease;
  line-height: 1.4;
  white-space: nowrap;
}

.btn:disabled { opacity: 0.6; cursor: not-allowed; }

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); }

.btn-success { background: var(--success); color: #fff; }
.btn-success:hover:not(:disabled) { background: #128a3d; }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #b91c1c; }

.btn-warning { background: var(--warning); color: #fff; }
.btn-warning:hover:not(:disabled) { background: #d97706; }

.btn-ghost { background: #fff; color: var(--text); border-color: var(--border); }
.btn-ghost:hover:not(:disabled) { background: var(--bg); }

.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-block { width: 100%; }

/* ---------- 表单 ---------- */
.form-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  align-items: end;
}

.form-grid-3 { grid-template-columns: repeat(3, 1fr); }

.form-item { margin-bottom: 12px; }

.form-label {
  display: block;
  font-size: 13px;
  color: var(--text-2);
  margin-bottom: 6px;
  font-weight: 500;
}

.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text);
  background: #fff;
  outline: none;
  transition: border-color 0.15s ease;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(43, 127, 255, 0.12);
}

.form-textarea { resize: vertical; min-height: 90px; }

.form-hint { font-size: 12px; color: var(--text-3); margin-top: 4px; }

/* 筛选区 */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-end;
  margin-bottom: 16px;
}

.filter-bar .filter-item { display: flex; flex-direction: column; gap: 4px; }
.filter-bar .filter-label { font-size: 12px; color: var(--text-2); }
.filter-bar .form-input, .filter-bar .form-select { min-width: 140px; }

/* ---------- 弹窗 ---------- */
.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal {
  background: #fff;
  border-radius: 10px;
  width: 100%;
  max-width: 560px;
  max-height: 86vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  animation: modalIn 0.18s ease;
}

.modal-sm { max-width: 420px; }
.modal-lg { max-width: 760px; }

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.96) translateY(8px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  font-size: 15px;
  font-weight: 600;
}

.modal-close {
  border: none;
  background: transparent;
  font-size: 20px;
  color: var(--text-3);
  cursor: pointer;
  line-height: 1;
  padding: 2px 6px;
  border-radius: 4px;
}

.modal-close:hover { color: var(--text); background: var(--bg); }

.modal-body { padding: 18px; overflow-y: auto; }

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 18px;
  border-top: 1px solid var(--border);
}

/* 详情行 */
.detail-list { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 20px; }
.detail-item { font-size: 13px; }
.detail-item .d-label { color: var(--text-3); margin-right: 6px; }
.detail-item .d-value { color: var(--text); word-break: break-all; }

@media (max-width: 767px) {
  .detail-list { grid-template-columns: 1fr; }
}

/* ---------- 分页 ---------- */
.pagination {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 6px;
  padding: 12px 0 4px;
}

.pagination .page-btn {
  min-width: 30px;
  height: 30px;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--text-2);
  font-size: 13px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.pagination .page-btn:hover:not(:disabled):not(.active) { border-color: var(--primary); color: var(--primary); }
.pagination .page-btn.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.pagination .page-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.pagination .page-info { font-size: 12px; color: var(--text-3); margin-left: 6px; }

/* ---------- 标签页 ---------- */
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
  overflow-x: auto;
}

.tab-item {
  padding: 8px 16px;
  font-size: 14px;
  color: var(--text-2);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
}

.tab-item:hover { color: var(--primary); }

.tab-item.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  font-weight: 600;
}

/* ---------- 空状态 ---------- */
.empty {
  padding: 40px 16px;
  text-align: center;
  color: var(--text-3);
  font-size: 13px;
}

.empty .empty-icon { font-size: 36px; margin-bottom: 8px; opacity: 0.4; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  background: rgba(17, 24, 39, 0.9);
  color: #fff;
  padding: 9px 18px;
  border-radius: 20px;
  font-size: 13px;
  box-shadow: var(--shadow-lg);
  animation: toastIn 0.2s ease;
  max-width: 80vw;
}

.toast.toast-success { background: rgba(22, 163, 74, 0.95); }
.toast.toast-error { background: rgba(220, 38, 38, 0.95); }

@keyframes toastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(-8px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ---------- 图片预览 ---------- */
.img-thumb {
  width: 52px;
  height: 52px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  cursor: pointer;
}

/* ---------- 文本/富文本预览 ---------- */
.pre-text {
  white-space: pre-wrap;
  word-break: break-all;
  font-size: 13px;
  line-height: 1.7;
  background: #f9fafb;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  max-height: 320px;
  overflow-y: auto;
}

/* ---------- 响应式表单网格 ---------- */
@media (max-width: 767px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .form-grid, .form-grid-3 { grid-template-columns: 1fr; }
  .filter-bar .filter-item { flex: 1 1 100%; }
  .filter-bar .form-input, .filter-bar .form-select { min-width: 0; }
  .chart-box canvas { height: 220px; }
  .topbar-right .btn-ghost { padding: 4px 8px; }
}

@media (max-width: 420px) {
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .stat-card .stat-value { font-size: 20px; }
}
