/*
  admin.css —— 管理员图片管理台全部样式（纯静态三件套之一）
  主题：浅色背景 #f5f6fa、CSS 变量主色调 --primary: #2563eb、简洁圆角阴影、系统字体栈
  覆盖：登录卡片 / 顶部工具栏 / 筛选与操作控件 / 三视图卡片（栅格/大图/列表）/
        骨架屏微光动画 / 框选覆盖层 / toast / 模态框 / 删除进度条 / 窄屏适配
  配套：admin.html / admin.js；无第三方库
*/

:root {
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --danger: #dc2626;
  --danger-hover: #b91c1c;
  --bg: #f5f6fa;
  --card-bg: #ffffff;
  --text: #1f2937;
  --text-2: #6b7280;
  --border: #e5e7eb;
  --radius: 8px;
  --radius-sm: 6px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.12);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

/* hidden 属性优先级最高（很多元素默认 display:flex 会覆盖） */
[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

button, input, select { font-family: inherit; }

/* ==================== 顶部加载进度条 ==================== */
.admin-top-progress {
  position: fixed; top: 0; left: 0;
  height: 3px; width: 0%;
  background: var(--primary);
  opacity: 0;
  z-index: 1000;
  transition: width 0.2s ease, opacity 0.3s ease;
}
.admin-top-progress.admin-top-progress-on { opacity: 1; }
.admin-top-progress.admin-top-progress-hide { opacity: 0; }

/* ==================== 登录视图 ==================== */
.admin-login {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
}
.admin-login-card {
  background: var(--card-bg);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  padding: 40px 32px 32px;
  width: 100%; max-width: 380px;
  text-align: center;
}
.admin-login-card h1 { font-size: 22px; margin-bottom: 6px; }
.admin-login-sub { color: var(--text-2); font-size: 13px; margin-bottom: 24px; }
.admin-login-card input {
  width: 100%; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: 14px; outline: none; margin-bottom: 16px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.admin-login-card input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15); }
.admin-login-btn {
  width: 100%; padding: 10px;
  background: var(--primary); color: #fff;
  border: none; border-radius: var(--radius-sm);
  font-size: 15px; cursor: pointer;
  transition: background 0.15s ease;
}
.admin-login-btn:hover { background: var(--primary-hover); }

/* ==================== 主界面布局 ==================== */
.admin-app { min-height: 100vh; }

/* 顶部固定工具栏 */
.admin-toolbar {
  position: sticky; top: 0; z-index: 100;
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
  display: flex; flex-wrap: wrap; align-items: center;
  gap: 10px 16px;
  padding: 10px 16px;
}
.admin-toolbar-section { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.admin-toolbar-stats { color: var(--text-2); font-size: 13px; white-space: nowrap; }
.admin-toolbar-stats b { color: var(--text); font-weight: 600; }

/* 筛选控件 */
.admin-filter-select, .admin-filter-date {
  height: 32px; padding: 0 8px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: #fff; color: var(--text); font-size: 13px; outline: none;
}
.admin-filter-select:focus, .admin-filter-date:focus { border-color: var(--primary); }
.admin-filter-select:disabled, .admin-filter-date:disabled { opacity: 0.5; cursor: not-allowed; }
.admin-date-sep { color: var(--text-2); font-size: 13px; }
.admin-search { position: relative; display: flex; align-items: center; }
.admin-search-input {
  height: 32px; width: 180px; padding: 0 26px 0 8px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: 13px; outline: none; color: var(--text);
}
.admin-search-input:focus { border-color: var(--primary); }
.admin-search-input:disabled { opacity: 0.5; cursor: not-allowed; }
.admin-search-clear {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  width: 20px; height: 20px; line-height: 1;
  border: none; background: none; cursor: pointer;
  color: var(--text-2); font-size: 16px; border-radius: 50%;
}
.admin-search-clear:hover { color: var(--text); background: var(--bg); }
.admin-search-clear:disabled { opacity: 0.5; cursor: not-allowed; }

/* 通用按钮 */
.admin-btn {
  padding: 6px 12px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: #fff; color: var(--text);
  font-size: 13px; cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}
.admin-btn:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); }
.admin-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.admin-btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.admin-btn-danger:hover:not(:disabled) { background: var(--danger-hover); border-color: var(--danger-hover); color: #fff; }

/* 视图模式按钮组 */
.admin-view-btns { display: flex; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.admin-view-btn {
  padding: 6px 10px; border: none; border-right: 1px solid var(--border);
  background: #fff; color: var(--text-2); font-size: 13px; cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.admin-view-btn:last-child { border-right: none; }
.admin-view-btn:hover { color: var(--primary); }
.admin-view-btn.active { background: var(--primary); color: #fff; }

/* 删除进度条（工具栏内） */
.admin-delete-progress { display: flex; align-items: center; gap: 8px; transition: opacity 0.3s ease; }
.admin-delete-progress-track { width: 140px; height: 6px; background: #eef0f4; border-radius: 3px; overflow: hidden; }
.admin-delete-progress-bar { height: 100%; width: 0%; background: var(--danger); border-radius: 3px; transition: width 0.3s ease; }
.admin-delete-progress-text { font-size: 12px; color: var(--text-2); white-space: nowrap; }
.admin-fade-out { opacity: 0; }

/* ==================== 图片区 ==================== */
.admin-main { max-width: 1440px; margin: 0 auto; padding: 16px; }
.admin-image-container { position: relative; }
.admin-view-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
.admin-view-big { display: flex; flex-direction: column; gap: 16px; }
.admin-view-list { display: flex; flex-direction: column; gap: 8px; }

/* 卡片通用 */
.admin-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
}
.admin-card.admin-selected { box-shadow: 0 0 0 2px var(--primary); }

/* 栅格卡片：正方形缩略图 + 底部覆盖层 */
.admin-card-grid { position: relative; aspect-ratio: 1 / 1; }
.admin-card-grid .admin-card-imgwrap { position: absolute; inset: 0; }
.admin-thumb { width: 100%; height: 100%; object-fit: cover; display: block; }
.admin-card-overlay {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: 14px 8px 6px;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.65));
  color: #fff; font-size: 12px;
  display: flex; justify-content: space-between; gap: 8px;
}
.admin-card-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.admin-card-meta { flex-shrink: 0; opacity: 0.85; }

/* 勾选框（栅格/大图右上角圆形，hover 显示，选中蓝底白勾） */
.admin-card-check {
  position: absolute; top: 8px; right: 8px;
  width: 22px; height: 22px; border-radius: 50%;
  background: rgba(255, 255, 255, 0.9);
  border: 2px solid rgba(0, 0, 0, 0.3);
  display: flex; align-items: center; justify-content: center;
  color: transparent; font-size: 13px;
  opacity: 0;
  transition: opacity 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}
.admin-card-grid:hover .admin-card-check,
.admin-card-big:hover .admin-card-check { opacity: 1; }
.admin-card.admin-selected .admin-card-check { opacity: 1; background: var(--primary); border-color: var(--primary); color: #fff; }
.admin-card-check::after { content: "\2713"; }

/* 大图卡片：大缩略图 + 信息行 */
.admin-card-big { display: flex; flex-direction: column; }
.admin-big-imgwrap { position: relative; height: 380px; }
.admin-big-info {
  display: flex; align-items: center; gap: 8px 20px;
  padding: 10px 14px; font-size: 13px; color: var(--text-2);
  border-top: 1px solid var(--border); flex-wrap: wrap;
}
.admin-big-name { color: var(--text); font-weight: 600; max-width: 40%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* 来源标签 */
.admin-source-tag { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 12px; white-space: nowrap; }
.admin-source-tag-gen { background: #dbeafe; color: #1d4ed8; }
.admin-source-tag-upload { background: #dcfce7; color: #15803d; }

/* 文件缺失标记（孤儿图片：DB 有记录但文件丢失） */
.admin-card-missing { box-shadow: 0 0 0 1px var(--danger); }
.admin-card-missing .admin-thumb { opacity: 0.25; filter: grayscale(0.6); }
.admin-missing-tag {
  position: absolute; top: 8px; left: 8px;
  padding: 1px 8px; border-radius: 10px;
  background: var(--danger); color: #fff;
  font-size: 12px; line-height: 1.6; white-space: nowrap;
  z-index: 2;
}
.admin-card-list .admin-missing-tag, .admin-big-info .admin-missing-tag { position: static; flex-shrink: 0; }

/* 列表卡片：表格样式行 */
.admin-card-list { display: flex; align-items: center; gap: 12px; padding: 8px 12px; }
.admin-list-thumb { width: 56px; height: 56px; object-fit: cover; border-radius: var(--radius-sm); flex-shrink: 0; }
.admin-list-name { flex: 1 1 180px; min-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.admin-list-key { flex: 1 1 140px; min-width: 100px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-2); }
.admin-list-dim { width: 80px; color: var(--text-2); flex-shrink: 0; }
.admin-list-size { width: 80px; color: var(--text-2); flex-shrink: 0; }
.admin-list-date { width: 150px; color: var(--text-2); flex-shrink: 0; }
.admin-list-source { width: 90px; flex-shrink: 0; }
.admin-list-check {
  width: 22px; height: 22px; border-radius: 50%; flex-shrink: 0;
  border: 2px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  color: transparent; font-size: 13px;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.admin-card-list.admin-selected .admin-list-check { background: var(--primary); border-color: var(--primary); color: #fff; }
.admin-list-check::after { content: "\2713"; }

/* ==================== 骨架屏（微光动画） ==================== */
.admin-skeleton { cursor: default; pointer-events: none; }
.admin-skeleton-block {
  background: linear-gradient(90deg, #edeff3 25%, #e1e5ec 50%, #edeff3 75%);
  background-size: 200% 100%;
  border-radius: 6px;
  animation: adminShimmer 1.4s ease-in-out infinite;
}
@keyframes adminShimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.admin-skeleton-grid { position: relative; aspect-ratio: 1 / 1; }
.admin-skeleton-grid .admin-skeleton-img { position: absolute; inset: 0; border-radius: 0; }
.admin-skeleton-grid .admin-skeleton-line { display: none; }
.admin-skeleton-big { display: flex; flex-direction: column; }
.admin-skeleton-big .admin-skeleton-img { height: 380px; border-radius: 0; }
.admin-skeleton-big .admin-skeleton-line { height: 12px; width: 40%; margin: 12px 14px; }
.admin-skeleton-list { display: flex; align-items: center; gap: 12px; padding: 8px 12px; }
.admin-skeleton-list .admin-skeleton-img { width: 56px; height: 56px; flex-shrink: 0; }
.admin-skeleton-list .admin-skeleton-line { height: 12px; width: 30%; }

/* ==================== 框选覆盖层 ==================== */
.admin-marquee {
  /* fixed 定位于视口：JS 用鼠标视口坐标(clientX/Y)直接设置位置，与滚动/布局无关 */
  position: fixed; z-index: 1500;
  border: 1px solid var(--primary);
  background: rgba(37, 99, 235, 0.15);
  pointer-events: none;
}

/* 哨兵与加载完成提示 */
.admin-sentinel { height: 1px; }
.admin-load-all-tip { text-align: center; color: var(--text-2); font-size: 13px; padding: 18px 0 6px; }

/* ==================== 空状态 ==================== */
.admin-empty { text-align: center; padding: 80px 16px; color: var(--text-2); }
.admin-empty-icon { color: #c3c8d2; margin-bottom: 12px; }
.admin-empty-title { font-size: 16px; color: var(--text); margin-bottom: 6px; }
.admin-empty-desc { font-size: 13px; }

/* ==================== toast 提示 ==================== */
.admin-toast-container {
  position: fixed; right: 16px; bottom: 16px; z-index: 2000;
  display: flex; flex-direction: column; align-items: flex-end; gap: 8px;
}
.admin-toast {
  background: #374151; color: #fff;
  padding: 10px 16px; border-radius: var(--radius-sm);
  font-size: 13px; box-shadow: var(--shadow-lg);
  max-width: 340px;
  animation: adminToastIn 0.25s ease;
}
.admin-toast-success { background: #16a34a; }
.admin-toast-error { background: var(--danger); }
.admin-toast-out { opacity: 0; transform: translateY(6px); transition: opacity 0.3s ease, transform 0.3s ease; }
@keyframes adminToastIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

/* ==================== 模态框 ==================== */
.admin-modal-mask {
  position: fixed; inset: 0; z-index: 1500;
  background: rgba(15, 23, 42, 0.5);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.admin-modal {
  background: #fff; border-radius: 12px;
  padding: 24px; width: 100%; max-width: 420px;
  box-shadow: var(--shadow-lg);
}
.admin-modal h3 { font-size: 17px; margin-bottom: 10px; }
.admin-modal p { color: var(--text-2); font-size: 14px; line-height: 1.6; margin-bottom: 20px; }
.admin-modal-actions { display: flex; justify-content: flex-end; gap: 10px; }
.admin-danger-text { color: var(--danger); font-weight: 600; }

/* 二次确认（删除该 Key 全部）数字输入框 */
.admin-key-confirm-input {
  width: 100%; padding: 10px 12px; margin-bottom: 20px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: 14px; outline: none; box-sizing: border-box;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.admin-key-confirm-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15); }

/* 预览模态：全屏深色，图片原始尺寸可滚动查看 */
.admin-preview-mask { padding: 0; }
.admin-preview { width: 100%; height: 100%; background: #111827; display: flex; flex-direction: column; }
.admin-preview-img-wrap { flex: 1; overflow: auto; position: relative; display: flex; align-items: flex-start; justify-content: center; padding: 16px; }
.admin-preview-img { display: block; opacity: 0; transition: opacity 0.4s ease; }
.admin-spinner {
  position: absolute; top: 50%; left: 50%;
  width: 40px; height: 40px; margin: -20px 0 0 -20px;
  border: 4px solid rgba(255, 255, 255, 0.2);
  border-top-color: #fff;
  border-radius: 50%;
  animation: adminSpin 0.8s linear infinite;
}
@keyframes adminSpin { to { transform: rotate(360deg); } }
.admin-preview-close {
  position: fixed; top: 12px; right: 16px; z-index: 1600;
  width: 36px; height: 36px; border-radius: 50%;
  border: none; background: rgba(255, 255, 255, 0.15); color: #fff;
  font-size: 20px; line-height: 1; cursor: pointer;
  transition: background 0.15s ease;
}
.admin-preview-close:hover { background: rgba(255, 255, 255, 0.3); }
.admin-preview-info {
  display: flex; flex-wrap: wrap; gap: 6px 24px;
  padding: 12px 20px;
  background: #0b1220; color: #cbd5e1; font-size: 13px;
}
.admin-pi-item { display: flex; align-items: center; gap: 6px; max-width: 280px; }
.admin-pi-item label { color: #64748b; flex-shrink: 0; }
.admin-pi-item b { color: #e2e8f0; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* 模态打开时锁定页面滚动 */
body.admin-modal-open { overflow: hidden; }

/* ==================== 窄屏适配 ==================== */
@media (max-width: 768px) {
  .admin-toolbar { flex-direction: column; align-items: stretch; }
  .admin-toolbar-section { justify-content: flex-start; }
  .admin-view-grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; }
  .admin-big-imgwrap { height: 260px; }
  .admin-search-input { width: 100%; }
  .admin-list-date, .admin-list-key { display: none; }
  .admin-main { padding: 10px; }
}
