/* ===== 蓝夹缬图库页 ===== */
/* 靛蓝展陈：布面底纹 + 雕版框口 + 木色印章 */

.container {
  width: calc(100% - 60px);
  background: transparent;
  border-radius: 24px;
  padding: 28px;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 40px);
  gap: 18px;
  position: relative;
  overflow: hidden;
}

/* 内收白底 + 布面编织纹理 */
.container.blue-jiaxie-pattern::before {
  content: "";
  position: absolute;
  inset: 18px;
  border-radius: 22px;
  background:
    radial-gradient(circle at 20px 14px, rgba(31, 67, 116, 0.06) 0 1px, transparent 1px),
    radial-gradient(circle at 20px 14px, rgba(119, 64, 26, 0.04) 0 2px, transparent 2px),
    linear-gradient(180deg, #ffffff 0%, #f7fbff 100%);
  background-size: 26px 20px, 40px 30px, auto;
  box-shadow: inset 0 0 0 1px rgba(31, 67, 116, 0.10);
  pointer-events: none;
  z-index: 0;
}

.container.blue-jiaxie-pattern > * { position: relative; z-index: 1; }

/* ===== 页头 ===== */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 20px;
  margin-bottom: 24px;
  padding-bottom: 18px;
  border-bottom: 2px dashed rgba(31, 67, 116, 0.10);
  position: relative;
}

/* 靛蓝装饰底条 */
.page-header::after {
  content: "";
  position: absolute;
  bottom: -1px;
  left: 0;
  width: 80px;
  height: 3px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--ink-3), var(--ink-4));
  opacity: 0.6;
}

.repo-tabs, .toolbar, .summary-grid { flex: 0 0 auto; }
.state-card, .gallery { flex: 1 1 auto; }
.state-card { display: grid; place-items: center; min-height: 260px; }

.eyebrow {
  font-size: 12px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.page-header h1 {
  font-size: 32px;
  color: var(--ink-2);
  margin-bottom: 6px;
}

.subtitle {
  color: var(--text-soft);
  max-width: 760px;
  line-height: 1.6;
}

.header-actions { display: flex; gap: 12px; flex-wrap: wrap; }

/* ===== 仓库选项卡（雕版感） ===== */
.repo-tabs {
  display: inline-flex;
  gap: 10px;
  padding: 6px;
  margin-bottom: 20px;
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(235, 241, 248, 0.96), rgba(244, 247, 251, 0.94));
  border: 1px solid var(--panel-border);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

.repo-tab {
  border: none;
  border-radius: 14px;
  padding: 10px 18px;
  background: transparent;
  color: var(--text-soft);
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
}

.repo-tab.is-active {
  background: linear-gradient(135deg, var(--ink-3), var(--ink-2));
  color: #fff;
  box-shadow: 0 8px 18px rgba(15, 44, 90, 0.22);
}

.repo-tab:not(.is-active):hover {
  background: rgba(255, 255, 255, 0.74);
  color: var(--ink-2);
}

/* ===== 靛蓝按钮 ===== */
.btn {
  border: none;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--ink-3), var(--ink-2));
  color: white;
  padding: 12px 18px;
  cursor: pointer;
  font-weight: 700;
  transition: transform 0.2s ease, opacity 0.2s ease;
  box-shadow: 0 8px 18px rgba(15, 44, 90, 0.14);
}

.btn:hover { transform: translateY(-1px); }
.btn:disabled { opacity: 0.68; cursor: not-allowed; transform: none; }

.btn-secondary {
  background: linear-gradient(135deg, #6f3f19, #8f5930);
  box-shadow: 0 8px 18px rgba(119, 64, 26, 0.16);
}

.btn-danger { background: linear-gradient(135deg, #b6414a, #de5f67); }

/* ===== 工具栏 ===== */
.toolbar {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) 180px 180px 160px;
  gap: 16px;
  margin-bottom: 20px;
  align-items: end;
}

/* ===== 概览统计（靛蓝展陈卡片） ===== */
.summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.summary-card, .field, .stat-card {
  background: linear-gradient(180deg, rgba(248, 250, 255, 0.96), rgba(241, 245, 251, 0.94));
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  padding: 14px 16px;
  position: relative;
  overflow: hidden;
}

/* 布面编织点 */
.summary-card::before, .stat-card::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 22px 16px, rgba(31, 67, 116, 0.06) 0 1px, transparent 1px);
  background-size: 28px 22px;
  opacity: 0.8;
}

.summary-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 92px;
  justify-content: center;
}

.summary-card strong { color: var(--ink-2); font-size: 20px; line-height: 1.4; }

/* 木质点缀卡片 */
.summary-card:nth-child(3) {
  border-color: rgba(119, 64, 26, 0.2);
  background: linear-gradient(180deg, rgba(255, 248, 242, 0.96), rgba(250, 241, 233, 0.86));
}

.summary-card-wide strong { font-size: 15px; color: var(--ink-2); }

.summary-label, .field span {
  display: block;
  font-size: 13px;
  color: var(--text-soft);
  margin-bottom: 8px;
}

.field input, .field select {
  width: 100%;
  border: 1px solid #c7d2e2;
  border-radius: 10px;
  padding: 10px 12px;
  background: white;
}

.stat-card {
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: var(--ink-2);
}

.state-card {
  background: #f4f7fb;
  border: 1px dashed #bfd0e5;
  border-radius: 18px;
  padding: 28px;
  text-align: center;
  color: var(--text-soft);
}

.hidden { display: none !important; }

/* ===== 图库网格（雕版框口卡片） ===== */
.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 18px;
}

.gallery-card {
  background: rgba(252,251,249,0.98);
  border: 1px solid #d9e2ee;
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 8px 18px rgba(23, 54, 95, 0.08);
  position: relative;
  transition: transform 0.25s var(--ease-out), box-shadow 0.25s ease, border-color 0.25s ease;
}

/* 雕版框口虚线 + 角花 */
.gallery-card::before {
  content: "";
  position: absolute;
  inset: 8px;
  border-radius: 12px;
  border: 1px dashed rgba(31, 67, 116, 0.10);
  pointer-events: none;
  z-index: 1;
  opacity: 0.7;
  transition: opacity 0.25s ease;
}

.gallery-card:hover {
  transform: translateY(-3px);
  border-color: rgba(31, 67, 116, 0.20);
  box-shadow: 0 16px 32px rgba(23, 54, 95, 0.13);
}

.gallery-card:hover::before { opacity: 1; }

.gallery-card.is-highlighted {
  border-color: var(--ink-4);
  box-shadow: 0 0 0 3px rgba(47, 105, 173, 0.14), 0 12px 24px rgba(23, 54, 95, 0.14);
}

.gallery-card.model-card { display: flex; flex-direction: column; }

.gallery-preview-button {
  display: block;
  width: 100%;
  border: none;
  background: none;
  padding: 0;
  cursor: pointer;
}

.gallery-image {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  display: block;
  background: linear-gradient(135deg, #dbe6f3, #eef4fb);
}

.model-preview {
  width: 100%;
  aspect-ratio: 1 / 1;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #dbe6f3, #eef4fb);
  color: var(--ink-2);
  font-size: 48px;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.gallery-meta { padding: 12px 14px 16px; }

.gallery-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--ink-2);
  word-break: break-all;
  margin-bottom: 8px;
}

.gallery-info {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: #667892;
  margin-bottom: 12px;
}

.gallery-info.stack { flex-direction: column; align-items: flex-start; gap: 8px; }
.badge-row { display: flex; flex-wrap: wrap; gap: 8px; }

.model-badge {
  display: inline-flex;
  align-items: center;
  padding: 5px 10px;
  border-radius: 999px;
  background: #edf3fa;
  color: var(--ink-2);
  font-size: 12px;
  font-weight: 700;
}

.model-badge.is-generated { background: #e4f0ff; color: var(--ink-3); }
.gallery-actions { display: flex; gap: 10px; }

/* 操作按钮带靛蓝感 */
.mini-btn {
  flex: 1;
  border: none;
  border-radius: 10px;
  padding: 10px 12px;
  background: linear-gradient(180deg, rgba(237, 243, 250, 0.96), rgba(230, 237, 247, 0.94));
  color: var(--ink-2);
  cursor: pointer;
  font-weight: 700;
  transition: transform 0.15s ease, background 0.2s ease;
}

.mini-btn:hover { background: linear-gradient(180deg, var(--ink-3), var(--ink-2)); color: #fff; }
.mini-btn-danger { background: #fdecee; color: #9f3541; }

/* ===== 弹窗 ===== */
.modal { position: fixed; inset: 0; z-index: 1200; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(5, 15, 32, 0.72); backdrop-filter: blur(6px); }

.modal-panel {
  position: relative;
  z-index: 1;
  width: min(94vw, 1180px);
  max-height: 90vh;
  margin: 4vh auto;
  background: rgba(248, 250, 255, 0.98);
  border-radius: 24px;
  padding: 24px;
  overflow: auto;
  box-shadow: 0 28px 64px rgba(2, 6, 23, 0.24);
}

.modal-panel-model { width: min(96vw, 1320px); }

.modal-close {
  position: absolute;
  top: 14px;
  right: 18px;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  background: rgba(31, 67, 116, 0.08);
  color: var(--ink-2);
  cursor: pointer;
  font-size: 24px;
  line-height: 1;
  transition: background 0.2s ease;
}

.modal-close:hover { background: rgba(31, 67, 116, 0.16); }

.modal-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(320px, 0.8fr);
  gap: 24px;
}

.modal-layout-model { grid-template-columns: minmax(0, 1.7fr) minmax(320px, 0.7fr); }

.modal-preview {
  background: linear-gradient(180deg, #eef4fb 0%, #e3edf9 100%);
  border-radius: 18px;
  padding: 16px;
  border: 1px solid rgba(31, 67, 116, 0.08);
}

.modal-preview-model { position: relative; min-height: 560px; overflow: hidden; }

.modal-image {
  width: 100%;
  max-height: 72vh;
  object-fit: contain;
  border-radius: 14px;
  background: #ebf1f8;
}

.model-preview-canvas {
  width: 100%;
  height: 100%;
  min-height: 528px;
  display: block;
  border-radius: 14px;
  background: radial-gradient(circle at top, #f7fbff 0%, #dfe8f6 100%);
}

.model-viewer-overlay {
  position: absolute;
  inset: 16px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: rgba(239, 244, 251, 0.72);
  color: var(--ink-2);
  font-weight: 700;
  pointer-events: none;
}

.modal-sidebar { display: flex; flex-direction: column; gap: 20px; }

.modal-meta, .modal-form {
  background: linear-gradient(180deg, rgba(246, 249, 253, 0.96), rgba(241, 245, 251, 0.94));
  border: 1px solid #dbe5f2;
  border-radius: 18px;
  padding: 18px;
}

.modal-meta h2 { color: var(--ink-2); margin-bottom: 10px; word-break: break-all; }
.modal-meta p { color: var(--text-soft); line-height: 1.7; }

.modal-form { display: flex; flex-direction: column; gap: 16px; }
.replace-block { display: flex; flex-direction: column; gap: 10px; }
.replace-file-name { font-size: 13px; color: var(--text-soft); word-break: break-all; }

.modal-actions { display: flex; gap: 12px; flex-wrap: wrap; }
.modal-actions .btn { flex: 1; min-width: 140px; }

@media (max-width: 1100px) {
  .toolbar, .summary-grid, .modal-layout { grid-template-columns: 1fr; }
  .container { padding: 20px; }
}

@media (max-width: 720px) {
  body { padding: 12px 12px 12px 64px; }
  .page-header { flex-direction: column; align-items: stretch; }
  .header-actions, .modal-actions, .gallery-actions { flex-direction: column; }
}
