/* 售后产品图库 - 桌面优先样式 */
:root {
  --bg: #f4f5f7;
  --panel: #ffffff;
  --border: #e2e5ea;
  --text: #1f2733;
  --muted: #6b7280;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --danger: #dc2626;
  --danger-bg: #fee2e2;
  --shadow: 0 1px 3px rgba(16, 24, 40, .08), 0 4px 16px rgba(16, 24, 40, .06);
  --shadow-lg: 0 8px 32px rgba(16, 24, 40, .18);
  --radius: 10px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, "Segoe UI", "Microsoft YaHei", "PingFang SC", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

/* ── 顶部栏 ─────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 20px;
  padding: 12px 24px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.brand { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.brand-icon { font-size: 30px; }
.brand-text h1 { margin: 0; font-size: 18px; line-height: 1.2; }
.brand-text p { margin: 2px 0 0; font-size: 12px; color: var(--muted); }

.search-box {
  flex: 1; max-width: 560px;
  position: relative; display: flex; align-items: center;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0 14px;
}
.search-box:focus-within { border-color: var(--primary); background: #fff; }
.search-icon { color: var(--muted); font-size: 14px; }
.search-box input {
  flex: 1; border: 0; outline: 0; background: transparent;
  padding: 10px 8px; font-size: 14px;
}
.search-clear {
  border: 0; background: #e5e7eb; color: #555; cursor: pointer;
  width: 20px; height: 20px; border-radius: 50%; font-size: 11px;
  display: none; line-height: 20px; text-align: center; padding: 0;
}
.search-clear.show { display: block; }

.btn {
  border: 0; border-radius: 8px; cursor: pointer;
  padding: 10px 16px; font-size: 14px; font-weight: 600;
  transition: background .15s, opacity .15s;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-outline { background: #fff; color: var(--text); border: 1px solid var(--border); }
.btn-outline:hover { background: var(--bg); }
.btn-danger { background: #fff; color: var(--danger); border: 1px solid #fecaca; }
.btn-danger:hover { background: var(--danger-bg); }

/* ── 分类 chips ─────────────────────────── */
.chips {
  display: flex; flex-wrap: wrap; gap: 8px;
  padding: 16px 24px 0;
}
.chip {
  padding: 6px 14px; border-radius: 999px; cursor: pointer;
  background: #fff; border: 1px solid var(--border); color: var(--muted);
  font-size: 13px; user-select: none;
}
.chip:hover { border-color: var(--primary); color: var(--primary); }
.chip.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.image-chips { padding-top: 4px; }
.card-badge.badge-nopic { background: rgba(217, 83, 79, .9); }

.stat-line { padding: 6px 24px 0; color: var(--muted); font-size: 12px; }

/* ── 网格 ───────────────────────────────── */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
  padding: 16px 24px 24px;
}
.card {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden; cursor: pointer;
  box-shadow: var(--shadow); transition: box-shadow .15s, transform .15s;
  display: flex; flex-direction: column;
}
.card:hover { box-shadow: var(--shadow-lg); transform: translateY(-2px); }
.card-cover {
  aspect-ratio: 4/3; background: #eef0f3;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden; position: relative;
}
.card-cover img { width: 100%; height: 100%; object-fit: cover; }
.card-cover .placeholder { font-size: 34px; color: #c3c9d1; }
.card-badge {
  position: absolute; right: 8px; bottom: 8px;
  background: rgba(0,0,0,.55); color: #fff; font-size: 11px;
  padding: 2px 8px; border-radius: 999px;
}
.card-body { padding: 12px; flex: 1; display: flex; flex-direction: column; gap: 4px; }
.card-name {
  font-weight: 600; font-size: 14px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.card-meta { display: flex; gap: 8px; flex-wrap: wrap; }
.card-meta span {
  font-size: 11px; color: var(--muted); background: var(--bg);
  padding: 2px 8px; border-radius: 6px;
}

/* ── 空状态 / 分页 ──────────────────────── */
.empty { text-align: center; padding: 80px 20px; color: var(--muted); }
.empty-icon { font-size: 56px; margin-bottom: 12px; }
.empty p { margin: 4px 0; font-size: 15px; }
.empty-sub { font-size: 13px; color: #9aa1ab; }

.pagination { display: flex; gap: 8px; justify-content: center; padding: 0 0 32px; align-items: center; }
.page-btn {
  min-width: 34px; height: 34px; padding: 0 10px;
  border: 1px solid var(--border); background: #fff; border-radius: 8px;
  cursor: pointer; color: var(--text); font-size: 13px;
}
.page-btn:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); }
.page-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.page-btn:disabled { opacity: .4; cursor: default; }

/* ── 弹窗 ───────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .5);
  z-index: 100; display: flex; align-items: center; justify-content: center;
  padding: 24px; animation: fadeIn .15s;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.detail {
  position: relative; background: #fff; border-radius: 14px;
  width: min(1080px, 100%); max-height: 92vh;
  display: grid; grid-template-columns: 1fr 380px; overflow: hidden;
  box-shadow: var(--shadow-lg); animation: pop .18s;
}
.edit {
  position: relative; background: #fff; border-radius: 14px;
  width: min(720px, 100%); max-height: 92vh; overflow-y: auto;
  box-shadow: var(--shadow-lg); animation: pop .18s; padding: 24px 28px;
}
@keyframes pop { from { transform: scale(.97); opacity: .5; } to { transform: scale(1); opacity: 1; } }

.modal-close {
  position: absolute; top: 12px; right: 12px; z-index: 10;
  width: 30px; height: 30px; border-radius: 50%; border: 0;
  background: rgba(0,0,0,.5); color: #fff; cursor: pointer; font-size: 14px;
}
.modal-close:hover { background: rgba(0,0,0,.7); }

/* 详情左侧图 */
.detail-gallery {
  background: #111418; display: flex; flex-direction: column;
  min-height: 460px;
}
.detail-main {
  flex: 1; display: flex; align-items: center; justify-content: center;
  position: relative; overflow: hidden; min-height: 340px; cursor: zoom-in;
}
.detail-main img { max-width: 100%; max-height: 100%; object-fit: contain; }
.detail-main .placeholder { font-size: 64px; color: #4a515a; }
.main-zoom-hint {
  position: absolute; right: 12px; bottom: 12px; color: rgba(255,255,255,.7);
  background: rgba(0,0,0,.4); padding: 3px 10px; border-radius: 999px; font-size: 11px;
}
.detail-thumbs {
  display: flex; gap: 8px; padding: 12px; overflow-x: auto;
  background: #1b1f24; min-height: 72px;
}
.thumb {
  width: 58px; height: 58px; flex-shrink: 0; border-radius: 8px; overflow: hidden;
  border: 2px solid transparent; cursor: pointer; background: #000;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb.active { border-color: var(--primary); }

/* 详情右侧信息 */
.detail-info { padding: 22px 24px; overflow-y: auto; }
.detail-info h2 { margin: 0 0 16px; font-size: 20px; padding-right: 24px; }
.meta-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 16px; margin-bottom: 14px; }
.meta label, .block label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 2px; }
.meta span { font-size: 14px; font-weight: 500; word-break: break-all; }
.block { margin-bottom: 14px; }
.block pre {
  margin: 0; white-space: pre-wrap; word-break: break-word;
  font-family: inherit; font-size: 14px; background: var(--bg);
  padding: 10px 12px; border-radius: 8px;
}
.detail-actions { display: flex; gap: 10px; margin-top: 18px; }

/* 新增/编辑表单 */
.edit h2 { margin: 0 0 18px; font-size: 18px; padding-right: 24px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; }
.field label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 6px; }
.field .req { color: var(--danger); }
.field input, .field textarea {
  width: 100%; border: 1px solid var(--border); border-radius: 8px;
  padding: 9px 12px; font-size: 14px; font-family: inherit; outline: 0;
  background: #fff; resize: vertical;
}
.field input:focus, .field textarea:focus { border-color: var(--primary); }
.span-2 { grid-column: span 2; }

.drop-zone {
  border: 2px dashed var(--border); border-radius: 10px;
  padding: 26px 16px; text-align: center; cursor: pointer;
  color: var(--muted); transition: border-color .15s, background .15s;
}
.drop-zone:hover, .drop-zone.drag { border-color: var(--primary); background: #eff6ff; }
.drop-hint { font-size: 14px; }
.drop-hint span { font-size: 12px; color: #9aa1ab; }

.image-previews { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }
.img-preview {
  position: relative; width: 88px; height: 88px; border-radius: 8px; overflow: hidden;
  border: 1px solid var(--border); background: #000;
}
.img-preview img { width: 100%; height: 100%; object-fit: cover; }
.img-preview .rm {
  position: absolute; top: 3px; right: 3px; width: 20px; height: 20px;
  border: 0; border-radius: 50%; background: rgba(220,38,38,.9); color: #fff;
  cursor: pointer; font-size: 12px; line-height: 20px; padding: 0;
}
.img-preview .tag {
  position: absolute; left: 0; right: 0; bottom: 0; text-align: center;
  background: rgba(0,0,0,.55); color: #fff; font-size: 10px; padding: 1px 0;
}
.edit-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

.login {
  position: relative; background: #fff; border-radius: 14px;
  width: min(380px, 100%); padding: 26px 28px;
  box-shadow: var(--shadow-lg); animation: pop .18s;
}
.login h2 { margin: 0 0 6px; font-size: 18px; padding-right: 24px; }
.login-sub { margin: 0 0 16px; color: var(--muted); font-size: 13px; }
.login .field { margin-bottom: 4px; }

/* ── 灯箱 ───────────────────────────────── */
.lightbox {
  position: fixed; inset: 0; background: rgba(8, 10, 14, .94);
  z-index: 200; display: flex; flex-direction: column;
}
.lb-top {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px; color: #fff;
}
.lb-counter { font-size: 14px; opacity: .85; }
.lb-tools { display: flex; gap: 6px; }
.lb-btn {
  border: 1px solid rgba(255,255,255,.25); background: rgba(255,255,255,.06);
  color: #fff; border-radius: 7px; padding: 6px 12px; cursor: pointer; font-size: 14px;
}
.lb-btn:hover { background: rgba(255,255,255,.16); }
.lb-stage {
  flex: 1; display: flex; position: relative; overflow: hidden;
}
.lb-pane { flex: 1; position: relative; overflow: hidden; display: flex; align-items: center; justify-content: center; }
.lb-pane img {
  max-width: none; cursor: grab; user-select: none;
  transition: transform .08s;
}
.lb-divider { width: 2px; background: var(--primary); cursor: col-resize; flex-shrink: 0; }
.lb-arrow {
  position: absolute; top: 50%; transform: translateY(-50%);
  background: rgba(0,0,0,.45); color: #fff; border: 0;
  width: 48px; height: 72px; font-size: 30px; cursor: pointer; z-index: 10;
}
.lb-arrow:hover { background: rgba(0,0,0,.65); }
.lb-prev { left: 0; border-radius: 0 10px 10px 0; }
.lb-next { right: 0; border-radius: 10px 0 0 10px; }
.lb-hint {
  position: absolute; bottom: 14px; left: 50%; transform: translateX(-50%);
  color: rgba(255,255,255,.6); font-size: 12px; background: rgba(0,0,0,.4);
  padding: 4px 14px; border-radius: 999px; pointer-events: none;
}

/* ── Toast ──────────────────────────────── */
.toast {
  position: fixed; top: 76px; left: 50%; transform: translateX(-50%) translateY(-16px);
  background: rgba(17,24,39,.92); color: #fff; padding: 10px 20px;
  border-radius: 8px; font-size: 14px; z-index: 300; opacity: 0;
  transition: opacity .2s, transform .2s; pointer-events: none; max-width: 80vw;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { background: rgba(220,38,38,.95); }

/* ── 响应式收窄 ─────────────────────────── */
@media (max-width: 860px) {
  .detail { grid-template-columns: 1fr; }
  .topbar { flex-wrap: wrap; }
  .search-box { order: 3; flex-basis: 100%; max-width: none; }
}
