/* patelee 管理后台样式 */
:root {
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-light: #e0e7ff;
  --bg: #f8fafc;
  --card-bg: #ffffff;
  --text: #1e293b;
  --text-light: #64748b;
  --border: #e2e8f0;
  --danger: #ef4444;
  --danger-light: #fef2f2;
  --success: #22c55e;
  --warning: #f59e0b;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08);
}

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

body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Microsoft YaHei", sans-serif; background: var(--bg); color: var(--text); }

.hidden { display: none !important; }

/* ========== 登录页 ========== */
.login-page {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
}
.login-card {
  background: white; padding: 40px; border-radius: 16px; width: 380px;
  text-align: center; box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}
.login-logo { font-size: 48px; margin-bottom: 8px; }
.login-card h2 { font-size: 22px; margin-bottom: 4px; }
.login-sub { color: var(--text-light); font-size: 13px; margin-bottom: 28px; }
.login-card form { display: flex; flex-direction: column; gap: 12px; }
.login-card input {
  padding: 12px 16px; border: 1px solid var(--border); border-radius: var(--radius);
  font-size: 14px; outline: none; transition: border-color 0.2s;
}
.login-card input:focus { border-color: var(--primary); }
.login-card .btn-primary { margin-top: 8px; }
.login-hint { margin-top: 20px; font-size: 12px; color: var(--text-light); }

/* ========== 按钮 ========== */
.btn-primary {
  background: var(--primary); color: white; border: none; padding: 10px 20px;
  border-radius: var(--radius); font-size: 14px; cursor: pointer; transition: background 0.2s;
}
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary {
  background: white; color: var(--text); border: 1px solid var(--border); padding: 10px 20px;
  border-radius: var(--radius); font-size: 14px; cursor: pointer; transition: all 0.2s;
}
.btn-secondary:hover { border-color: var(--primary); color: var(--primary); }
.btn-text { background: none; border: none; color: var(--text-light); cursor: pointer; font-size: 13px; }
.btn-text:hover { color: var(--danger); }
.btn-danger { background: var(--danger-light); color: var(--danger); border: 1px solid #fecaca; padding: 4px 10px; border-radius: 4px; font-size: 12px; cursor: pointer; }
.btn-sm { padding: 4px 10px; font-size: 12px; border-radius: 4px; }

/* ========== 主布局 ========== */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 220px; background: #1e293b; color: white; display: flex; flex-direction: column;
  position: fixed; height: 100vh; z-index: 10;
}
.sidebar-header { padding: 20px 16px 16px 16px; font-size: 18px; font-weight: 700; display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center; }
.logo-icon { font-size: 22px; }
.logo-subtitle { font-size: 12px; font-weight: 400; color: #94a3b8; margin-top: 4px; }
.logo-subtitle-2 { font-size: 11px; font-weight: 400; color: #64748b; }
#sidebarLogo { display: none; max-width: 120px; max-height: 60px; margin-bottom: 4px; }
.nav { flex: 1; padding: 8px; }
.nav-item {
  display: block; padding: 10px 16px; color: #94a3b8; text-decoration: none;
  border-radius: var(--radius); margin-bottom: 2px; font-size: 14px; cursor: pointer; transition: all 0.2s;
}
.nav-item:hover { background: rgba(255,255,255,0.1); color: white; }
.nav-item.active { background: var(--primary); color: white; }
.sidebar-footer { padding: 16px; border-top: 1px solid rgba(255,255,255,0.1); }

.content { flex: 1; margin-left: 220px; padding: 28px 32px; }

/* ========== 视图 ========== */
.view { display: none; }
.view.active { display: block; }
.view h1 { font-size: 24px; margin-bottom: 20px; }
.view-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }

/* ========== 统计卡片 ========== */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card {
  background: var(--card-bg); padding: 20px; border-radius: var(--radius); box-shadow: var(--shadow);
  border: 1px solid var(--border);
}
.stat-card .label { font-size: 13px; color: var(--text-light); margin-bottom: 4px; }
.stat-card .value { font-size: 28px; font-weight: 700; }
.stat-card .value.purple { color: var(--primary); }
.stat-card .value.green { color: var(--success); }
.stat-card .value.orange { color: var(--warning); }
.stats-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.card { background: var(--card-bg); padding: 20px; border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--border); }
.card h3 { font-size: 16px; margin-bottom: 16px; }

/* ========== 表格 ========== */
.data-table { width: 100%; border-collapse: collapse; background: white; border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.data-table th { background: #f1f5f9; padding: 12px 16px; text-align: left; font-size: 13px; color: var(--text-light); font-weight: 600; border-bottom: 1px solid var(--border); }
.data-table td { padding: 12px 16px; border-bottom: 1px solid var(--border); font-size: 14px; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover { background: #f8fafc; }
.table-thumb { width: 48px; height: 48px; object-fit: contain; border-radius: 4px; background: #1e1e1e; border: 1px solid var(--border); vertical-align: middle; }
.thumb-hover-wrap { display: inline-block; cursor: zoom-in; }
.thumb-hover-wrap:hover .table-thumb { border-color: #3B82F6; }
.tag-blue { background: #0EA5E9; color: #fff; padding: 1px 6px; border-radius: 4px; font-weight: bold; font-size: 11px; }
.tag { display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 12px; font-weight: 500; }
.tag-green { background: #dcfce7; color: #16a34a; }
.tag-orange { background: #fef3c7; color: #d97706; }
.tag-red { background: #fee2e2; color: #dc2626; }
.tag-gray { background: #f1f5f9; color: #64748b; }
.tag-purple { background: var(--primary-light); color: var(--primary); }

/* ========== 筛选栏 ========== */
.filter-bar { display: flex; gap: 12px; margin-bottom: 16px; }
.filter-bar select, .filter-bar input {
  padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--radius);
  font-size: 14px; outline: none;
}
.filter-bar input { flex: 1; max-width: 300px; }

/* ========== 弹窗 ========== */
.modal {
  position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 100;
  display: flex; align-items: center; justify-content: center;
}
.modal-card {
  background: white; border-radius: 12px; padding: 28px; width: 600px; max-width: 90vw;
  max-height: 85vh; overflow-y: auto;
}
.modal-card h2 { font-size: 20px; margin-bottom: 20px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 12px; margin-top: 20px; }

/* ========== 表单 ========== */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 13px; color: var(--text-light); margin-bottom: 4px; }
.form-group input, .form-group select {
  width: 100%; padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--radius);
  font-size: 14px; outline: none;
}
.form-group input:focus, .form-group select:focus { border-color: var(--primary); }
.checkbox-group { display: flex; gap: 20px; align-items: center; padding-top: 28px; }
.checkbox-group label { display: flex; align-items: center; gap: 6px; font-size: 14px; color: var(--text); }
.file-path { font-size: 12px; color: var(--text-light); margin-top: 2px; flex: 1; }
.file-input-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.file-input-row input[type="file"] { flex: 0 1 auto; }
.file-input-row .file-path { flex: 1; min-width: 100px; word-break: break-all; }
.trial-only { display: none; }
.trial-only.visible { display: block; }

/* ========== Toast ========== */
.toast {
  position: fixed; bottom: 24px; right: 24px; background: #1e293b; color: white;
  padding: 12px 24px; border-radius: var(--radius); font-size: 14px; z-index: 200;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2); transition: opacity 0.3s;
}
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }

/* ========== 图表区域 ========== */
.chart-area { height: 200px; display: flex; align-items: flex-end; gap: 8px; padding-top: 20px; }
.chart-bar { flex: 1; background: var(--primary); border-radius: 4px 4px 0 0; min-height: 4px; position: relative; }
.chart-bar:hover { background: var(--primary-hover); }
.chart-bar .bar-label { position: absolute; bottom: -20px; left: 50%; transform: translateX(-50%); font-size: 11px; color: var(--text-light); }
.chart-bar .bar-value { position: absolute; top: -18px; left: 50%; transform: translateX(-50%); font-size: 11px; color: var(--text); }

.top-blocks { font-size: 14px; }
.top-block-item { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--border); }
.top-block-item:last-child { border-bottom: none; }

.license-code-display { font-family: monospace; font-size: 16px; color: var(--primary); margin-bottom: 16px; }

/* ========== 缩略图自动生成 ========== */
.thumb-gen-section {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-top: 8px;
  background: #fafbfc;
}
.accore-badge {
  display: inline-block;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 500;
  vertical-align: middle;
}
.accore-badge.ok { background: #dcfce7; color: #15803d; }
.accore-badge.fail { background: #fef2f2; color: #dc2626; }
.thumb-gen-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 8px;
}
.thumb-gen-bar .btn-primary { padding: 6px 16px; font-size: 13px; white-space: nowrap; }
.thumb-gen-bar .btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
.thumb-gen-status { font-size: 13px; color: var(--text-light); }
.thumb-gen-status.active { color: var(--warning); }
.thumb-gen-status.done { color: var(--success); font-weight: 500; }
.thumb-gen-status.error { color: var(--danger); }
.thumb-preview-area { margin-top: 12px; }
.thumb-group { margin-bottom: 16px; }
.thumb-group > label {
  display: block; font-size: 12px; font-weight: 600; color: var(--text-light);
  margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.5px;
}
.thumb-grid {
  display: flex; flex-wrap: wrap; gap: 8px;
}
.thumb-item {
  position: relative; width: 80px; height: 80px;
  border: 1px solid var(--border); border-radius: 6px;
  overflow: hidden; background: #fff;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.thumb-item.small { width: 50px; height: 50px; }
.thumb-item img {
  max-width: 100%; max-height: 72px; object-fit: contain;
}
.thumb-item.small img { max-height: 42px; }
.thumb-item span {
  font-size: 10px; color: var(--text-light); margin-top: 2px;
}
.thumb-item.missing {
  background: #f8fafc; border-style: dashed; border-color: #cbd5e1;
}
.thumb-item.missing img { display: none; }
.thumb-item.missing::after {
  content: '缺失'; font-size: 10px; color: #cbd5e1;
}
.thumb-frames {
  display: flex; flex-wrap: wrap; gap: 4px;
}

/* ========== 响应式 ========== */
@media (max-width: 768px) {
  .sidebar { width: 60px; }
  .sidebar-header .logo-text, .nav-item { display: none; }
  .content { margin-left: 60px; }
  .stats-row { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
}

.settings-form .field { margin-bottom: 14px; }
.settings-form .field label { display: block; margin-bottom: 4px; font-weight: 600; }
.settings-form .field input[type=text] { width: 100%%; max-width: 400px; padding: 8px; border-radius: 6px; border: 1px solid #ccc; }

/* 主题编辑器：预览面板样式 */
.palette-preview-html {
  user-select: none;
  box-shadow: 0 4px 24px rgba(0,0,0,0.4);
}
.hint { color: #64748B; font-size: 13px; }

/* 2D 缩略图 tab 切换 */
.thumb-tabs {
  display: flex; gap: 0; margin-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.thumb-tab {
  padding: 6px 14px; background: transparent;
  border: 0; border-bottom: 2px solid transparent;
  color: #94a3b8; cursor: pointer; font-size: 13px;
  transition: all 0.15s;
}
.thumb-tab:hover { color: #3B82F6; }
.thumb-tab.active {
  color: #3B82F6;
  border-bottom-color: #3B82F6;
  font-weight: 600;
}
.thumb-tab-panel { display: none; padding-top: 4px; }
.thumb-tab-panel.active { display: block; }

/* 精确上传：6 个视图格子 */
.thumb-views-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}
.thumb-view-cell {
  display: flex; flex-direction: column;
  background: #1e2530;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px;
  gap: 4px;
}
.thumb-view-cell label {
  font-size: 12px; color: #E2E8F0;
  font-weight: 600;
  text-align: center;
}
.thumb-view-cell input[type=file] {
  font-size: 11px;
  color: #94a3b8;
}

/* 缩略图删除按钮（悬浮右上角 X） */
.thumb-item { position: relative; }
.thumb-del-btn {
  position: absolute; top: 2px; right: 2px;
  width: 18px; height: 18px;
  background: rgba(239, 68, 68, 0.9); color: #fff;
  border: 0; border-radius: 50%;
  font-size: 12px; font-weight: bold;
  cursor: pointer; line-height: 1;
  display: none; padding: 0;
}
.thumb-item:hover .thumb-del-btn { display: block; }
.thumb-del-btn:hover { background: #DC2626; transform: scale(1.1); }
