/* ============================================
   样片规划系统 — 全局样式
   ============================================ */

:root {
  --primary: #2c3e50;
  --accent: #e8a87c;
  --accent2: #d4a574;
  --bg: #faf8f5;
  --card-bg: #ffffff;
  --text: #333333;
  --text-light: #777777;
  --border: #e8e3dc;
  --shadow: 0 2px 12px rgba(0,0,0,0.06);
  --shadow-hover: 0 6px 24px rgba(0,0,0,0.10);
  --radius: 10px;
  --radius-sm: 6px;
  --success: #27ae60;
  --warning: #f39c12;
  --info: #3498db;
  --draft-color: #bdc3c7;
  --filled-color: #f39c12;
  --completed-color: #27ae60;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Microsoft YaHei", "Helvetica Neue", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

/* ============ 导航栏 ============ */
.navbar {
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  padding: 0 32px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}
.navbar .logo {
  font-size: 20px;
  font-weight: 700;
  color: var(--primary);
  text-decoration: none;
  letter-spacing: 0.5px;
}
.navbar .logo span { color: var(--accent); }
.navbar .nav-stats {
  display: flex;
  gap: 20px;
  font-size: 14px;
  color: var(--text-light);
}
.navbar .nav-stats strong { color: var(--primary); }

/* ============ 容器 ============ */
.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px 32px;
}

/* ============ 页面标题 ============ */
.page-header {
  text-align: center;
  padding: 32px 0 24px;
}
.page-header h1 {
  font-size: 28px;
  color: var(--primary);
  margin-bottom: 8px;
}
.page-header p {
  color: var(--text-light);
  font-size: 14px;
}

/* ============ 产品线区块 ============ */
.product-section {
  margin-bottom: 32px;
}
.product-section__header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--accent);
}
.product-section__header h2 {
  font-size: 18px;
  color: var(--primary);
  white-space: nowrap;
}
.product-section__header .badge {
  background: var(--accent);
  color: #fff;
  font-size: 12px;
  padding: 2px 10px;
  border-radius: 12px;
  white-space: nowrap;
}
.product-section__header .progress {
  margin-left: auto;
  font-size: 13px;
  color: var(--text-light);
}

/* ============ 卡片网格 ============ */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}

/* ============ 主题卡片 ============ */
.theme-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: transform 0.2s, box-shadow 0.2s;
  border: 1px solid transparent;
  position: relative;
  overflow: hidden;
}
.theme-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-hover);
  border-color: var(--accent);
}
.theme-card__inner {
  text-decoration: none;
  color: inherit;
  display: block;
  padding: 20px;
  cursor: pointer;
  height: 100%;
}
.theme-card__status {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
}
.theme-card__status.draft { background: var(--draft-color); }
.theme-card__status.filled { background: var(--filled-color); }
.theme-card__status.completed { background: var(--completed-color); }
.theme-card__series {
  font-size: 13px;
  color: var(--accent);
  margin-bottom: 4px;
  font-weight: 500;
}
.theme-card__style {
  font-size: 16px;
  font-weight: 600;
  color: var(--primary);
  margin-bottom: 8px;
}
.theme-card__meta {
  font-size: 12px;
  color: var(--text-light);
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
}
.theme-card__meta span {
  background: var(--bg);
  padding: 2px 8px;
  border-radius: 4px;
}
.theme-card__meta .category-tag {
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  padding: 2px 10px;
}

/* 序号排序 */
.order-input {
  position: absolute;
  top: 6px;
  right: 8px;
  z-index: 2;
  width: 32px;
  height: 24px;
  text-align: center;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--card-bg);
  color: var(--accent);
  padding: 0;
  outline: none;
}
.order-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(212,163,115,0.2);
}
.sort-hint {
  font-size: 12px;
  color: var(--text-light);
  margin-left: 12px;
  opacity: 0.7;
}

/* ============ 主题详情页布局 ============ */
.theme-detail {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 32px;
  padding: 24px 0;
  min-height: calc(100vh - 60px);
}

/* ============ 面包屑 ============ */
.breadcrumb {
  padding: 16px 32px;
  font-size: 13px;
  color: var(--text-light);
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
}
.breadcrumb a {
  color: var(--accent);
  text-decoration: none;
}
.breadcrumb a:hover { text-decoration: underline; }

/* ============ 表单区（左栏） ============ */
.edit-panel {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: var(--shadow);
  overflow-y: auto;
}
.edit-panel h2 {
  font-size: 20px;
  color: var(--primary);
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.form-group {
  margin-bottom: 16px;
}
.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-light);
  margin-bottom: 6px;
}
.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  transition: border-color 0.2s;
  font-family: inherit;
}
.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(232,168,124,0.1);
}
.form-group textarea {
  min-height: 80px;
  resize: vertical;
}
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

/* ============ 预览区（右栏） ============ */
.preview-panel {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: var(--shadow);
  overflow-y: auto;
  position: sticky;
  top: 84px;
  max-height: calc(100vh - 100px);
}
.preview-panel h2 {
  font-size: 18px;
  color: var(--text-light);
  margin-bottom: 16px;
  text-align: center;
}
.preview-card {
  background: linear-gradient(135deg, #fdfbf7 0%, #faf6f0 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
}
.preview-card__header {
  text-align: center;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
.preview-card__style {
  font-size: 24px;
  font-weight: 700;
  color: var(--primary);
}
.preview-card__series {
  font-size: 14px;
  color: var(--accent);
  margin-top: 4px;
}
.preview-card__tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin: 12px 0;
}
.preview-card__tags span {
  background: var(--accent);
  color: #fff;
  padding: 3px 12px;
  border-radius: 20px;
  font-size: 12px;
}
.preview-card__info {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 20px;
}
.preview-card__info dt {
  font-size: 12px;
  color: var(--text-light);
}
.preview-card__info dd {
  font-size: 14px;
  color: var(--primary);
  font-weight: 500;
}
.preview-card__recommendations {
  font-size: 16px;
  line-height: 1.8;
  color: var(--text);
  white-space: pre-wrap;
  background: #fff;
  border-radius: var(--radius-sm);
  padding: 16px;
  margin-top: 16px;
  border: 1px solid var(--border);
}

/* ============ 参考图片区 ============ */
.image-section {
  margin-top: 24px;
  border: 2px dashed transparent;
  border-radius: var(--radius);
  padding: 12px;
  transition: border-color 0.2s, background 0.2s;
}
.image-section.drag-over {
  border-color: var(--accent);
  background: rgba(212,163,115,0.08);
}
.image-section h3 {
  font-size: 15px;
  color: var(--primary);
  margin-bottom: 12px;
}
.image-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.image-grid img {
  width: 100%;
  aspect-ratio: 4/3;
  object-fit: cover;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg);
}
.image-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 12px;
}
.upload-section {
  background: var(--bg);
  border-radius: var(--radius);
  padding: 20px 24px;
  border: 1px dashed var(--border);
}
.upload-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}
.upload-item {
  display: flex;
  align-items: center;
}
.search-link-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 4/3;
  border-radius: var(--radius-sm);
  border: 2px dashed var(--border);
  background: var(--bg);
  color: var(--text-light);
  font-size: 13px;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.2s;
}
.search-link-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: #fdf8f3;
}

/* ============ 按钮 ============ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}
.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover { background: var(--accent2); }
.btn-secondary {
  background: var(--bg);
  color: var(--primary);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--border); }
.btn-success {
  background: var(--success);
  color: #fff;
}
.btn-success:hover { opacity: 0.9; }
.btn-sm {
  padding: 6px 14px;
  font-size: 12px;
}
.btn-group {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

/* ============ 章节浏览链接 ============ */
.chapter-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--card-bg);
  border: 1px solid var(--border);
  text-decoration: none;
  font-size: 16px;
  transition: all 0.2s;
}
.chapter-link:hover { border-color: var(--accent); background: #fdf8f3; }

/* ============ Toast 提示 ============ */
.toast {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 9999;
  padding: 12px 24px;
  border-radius: var(--radius-sm);
  color: #fff;
  font-size: 14px;
  animation: fadeIn 0.3s ease;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}
.toast.success { background: var(--success); }
.toast.error { background: #e74c3c; }
.toast.info { background: var(--info); }
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ============ 统计条 ============ */
.stats-bar {
  display: flex;
  gap: 16px;
  justify-content: center;
  margin-bottom: 32px;
}
.stat-item {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 16px 32px;
  text-align: center;
  box-shadow: var(--shadow);
  min-width: 100px;
}
.stat-item .num {
  font-size: 28px;
  font-weight: 700;
  color: var(--primary);
}
.stat-item .label {
  font-size: 12px;
  color: var(--text-light);
  margin-top: 4px;
}

/* 可点击筛选的统计卡片 */
.filter-stat {
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
  border: 2px solid transparent;
  user-select: none;
}
.filter-stat:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-hover);
  border-color: var(--border);
}
.filter-stat.active {
  border-color: var(--accent);
  background: #fdf8f3;
}
.filter-stat.active .num { color: var(--accent); }
.filter-stat.active .label { color: var(--accent); }

/* ============ 加载状态 ============ */
.loading {
  text-align: center;
  padding: 60px;
  color: var(--text-light);
}
.loading::after {
  content: '...';
  animation: dots 1.5s infinite;
}
@keyframes dots {
  0%, 20% { content: '.'; }
  40% { content: '..'; }
  60%, 100% { content: '...'; }
}

/* ============ 加载覆盖层 ============ */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.35);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.2s ease;
}
.loading-overlay__box {
  background: #fff;
  border-radius: 12px;
  padding: 32px 48px;
  text-align: center;
  box-shadow: 0 8px 32px rgba(0,0,0,0.18);
  min-width: 260px;
}
.loading-overlay__spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 16px;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
.loading-overlay__text {
  font-size: 14px;
  color: var(--text);
  margin-bottom: 4px;
}
.loading-overlay__hint {
  font-size: 12px;
  color: var(--text-light);
}

/* 进度条 */
.loading-overlay__bar {
  width: 100%;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin-top: 16px;
  overflow: hidden;
}
.loading-overlay__bar::after {
  content: '';
  display: block;
  width: 30%;
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  animation: progressSlide 1.5s ease-in-out infinite;
}
@keyframes progressSlide {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(430%); }
}
@keyframes dots {
  0%, 20% { content: '.'; }
  40% { content: '..'; }
  60%, 100% { content: '...'; }
}

/* ============ 响应式 ============ */
@media (max-width: 1024px) {
  .theme-detail {
    grid-template-columns: 1fr;
  }
  .preview-panel {
    position: static;
    max-height: none;
  }
  .card-grid {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  }
}
@media (max-width: 640px) {
  .container { padding: 16px; }
  .navbar { padding: 0 16px; }
  .form-row { grid-template-columns: 1fr; }
  .image-grid { grid-template-columns: repeat(2, 1fr); }
  .stats-bar { flex-wrap: wrap; }
}

/* 管理员专属——默认隐藏，登录后 auth.js 显示 */
.admin-only { display: none; }
