@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:ital,wght@0,400;0,600;1,400&family=Noto+Sans+SC:wght@300;400;500;600&display=swap');

:root {
  --bg-deep: #f5f6f8;
  --bg-panel: #ffffff;
  --bg-elevated: #fafbfc;
  --bg-input: #ffffff;
  --border-subtle: rgba(0, 0, 0, 0.08);
  --border-gold: rgba(138, 115, 64, 0.35);
  --gold: #a8893a;
  --gold-light: #8a7340;
  --gold-dim: #c9a962;
  --text-primary: #1a1a1f;
  --text-secondary: rgba(26, 26, 31, 0.72);
  --text-muted: rgba(26, 26, 31, 0.45);
  --accent-glow: rgba(168, 137, 58, 0.12);
  --success: #3d8b5a;
  --error: #c0392b;
  --warning: #a8893a;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.08);
  --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --sidebar-w: 260px;
  --font-display: 'Cormorant Garamond', 'Noto Serif SC', serif;
  --font-body: 'Noto Sans SC', -apple-system, sans-serif;
}

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

html { font-size: 15px; }

body {
  font-family: var(--font-body);
  background: var(--bg-deep);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ── 背景纹理 ── */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 60% at 50% -10%, rgba(201, 169, 98, 0.04) 0%, transparent 60%),
    radial-gradient(ellipse 50% 40% at 100% 100%, rgba(0, 0, 0, 0.02) 0%, transparent 50%),
    linear-gradient(180deg, #ffffff 0%, #f5f6f8 50%, #ffffff 100%);
  pointer-events: none;
  z-index: 0;
}

/* ── 登录页 ── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  position: relative;
  z-index: 1;
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg-panel);
  border: 1px solid var(--border-subtle);
  border-radius: 20px;
  padding: 48px 40px;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}

.login-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold-dim), transparent);
}

.login-brand {
  text-align: center;
  margin-bottom: 40px;
}

.login-brand .mark {
  width: 56px;
  height: 56px;
  margin: 0 auto 20px;
  border: 1px solid var(--border-gold);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 1.6rem;
  color: var(--gold);
  letter-spacing: 0.05em;
}

.login-brand h1 {
  font-family: var(--font-display);
  font-size: 1.85rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.login-brand p {
  font-size: 0.82rem;
  color: var(--text-muted);
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

/* ── 表单 ── */
.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 8px;
}

input[type="text"],
input[type="password"],
input[type="number"],
textarea,
select {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 0.92rem;
  padding: 12px 16px;
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}

input:focus, textarea:focus, select:focus {
  border-color: var(--border-gold);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

textarea { resize: vertical; min-height: 120px; line-height: 1.7; }

/* ── 按钮 ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 24px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}

.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.btn-primary {
  background: linear-gradient(135deg, var(--gold-dim) 0%, var(--gold) 50%, var(--gold-dim) 100%);
  color: #ffffff;
  font-weight: 600;
}

.btn-primary:hover:not(:disabled) {
  box-shadow: 0 4px 16px rgba(168, 137, 58, 0.25);
  transform: translateY(-1px);
}

.btn-ghost {
  background: transparent;
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
}

.btn-ghost:hover:not(:disabled) {
  border-color: var(--border-gold);
  color: var(--gold);
  background: rgba(168, 137, 58, 0.06);
}

.btn-danger {
  background: transparent;
  border: 1px solid rgba(196, 112, 112, 0.35);
  color: var(--error);
}

.btn-danger:hover:not(:disabled) {
  background: rgba(196, 112, 112, 0.1);
}

.btn-sm { padding: 7px 14px; font-size: 0.78rem; }
.btn-block { width: 100%; }

/* ── 提示 ── */
.alert {
  display: none;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  margin-bottom: 20px;
}

.alert.show { display: block; }
.alert-error {
  background: rgba(196, 112, 112, 0.12);
  border: 1px solid rgba(196, 112, 112, 0.3);
  color: var(--error);
}
.alert-success {
  background: rgba(107, 158, 120, 0.12);
  border: 1px solid rgba(107, 158, 120, 0.3);
  color: var(--success);
}

/* ── 加载 ── */
.spinner {
  display: inline-block;
  width: 16px; height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-top-color: #ffffff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.spinner-light {
  border-color: rgba(201, 169, 98, 0.2);
  border-top-color: var(--gold);
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── 主布局 ── */
.app-shell {
  display: flex;
  min-height: 100vh;
  position: relative;
  z-index: 1;
}

.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-panel);
  border-right: 1px solid var(--border-subtle);
  box-shadow: 2px 0 12px rgba(0, 0, 0, 0.04);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
}

.sidebar-brand {
  padding: 32px 24px 28px;
  border-bottom: 1px solid var(--border-subtle);
}

.sidebar-brand .logo-text {
  font-family: var(--font-display);
  font-size: 1.35rem;
  letter-spacing: 0.15em;
  color: var(--gold);
}

.sidebar-brand .logo-sub {
  font-size: 0.68rem;
  color: var(--text-muted);
  letter-spacing: 0.25em;
  text-transform: uppercase;
  margin-top: 4px;
}

.sidebar-nav {
  flex: 1;
  padding: 16px 12px;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
  font-size: 0.88rem;
  letter-spacing: 0.04em;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}

.nav-item:hover {
  background: rgba(168, 137, 58, 0.06);
  color: var(--text-primary);
}

.nav-item.active {
  background: rgba(168, 137, 58, 0.1);
  color: var(--gold);
  border: 1px solid var(--border-subtle);
}

.nav-item .icon { font-size: 1.1rem; opacity: 0.7; width: 22px; text-align: center; }

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border-subtle);
}

.user-badge {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.user-avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--gold-dim), var(--gold));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 600;
  color: #ffffff;
}

.user-info .name { font-size: 0.85rem; color: var(--text-primary); }
.user-info .role {
  font-size: 0.68rem;
  color: var(--text-muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.main-content {
  flex: 1;
  margin-left: var(--sidebar-w);
  padding: 32px 40px;
  min-height: 100vh;
}

.page-section { display: none; animation: fadeIn 0.35s ease; }
.page-section.active { display: block; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.page-header {
  margin-bottom: 32px;
}

.page-header h2 {
  font-family: var(--font-display);
  font-size: 1.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--text-primary);
}

.page-header p {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-top: 6px;
  letter-spacing: 0.05em;
}

/* ── 卡片 ── */
.card {
  background: var(--bg-panel);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
}

.card-title {
  font-size: 0.72rem;
  color: var(--text-muted);
  letter-spacing: 0.15em;
  text-transform: uppercase;
  margin-bottom: 16px;
}

/* ── 统计 ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  padding: 20px 24px;
  position: relative;
  overflow: hidden;
}

.stat-card::after {
  content: '';
  position: absolute;
  bottom: 0; left: 24px; right: 24px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold-dim), transparent);
}

.stat-value {
  font-family: var(--font-display);
  font-size: 2rem;
  color: var(--gold);
  line-height: 1.2;
}

.stat-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-top: 4px;
}

/* ── 状态指示 ── */
.status-dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  margin-right: 8px;
}

.status-dot.online { background: var(--success); box-shadow: 0 0 8px rgba(107, 158, 120, 0.5); }
.status-dot.offline { background: var(--error); }

.service-status {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 20px;
  background: var(--bg-elevated);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  font-size: 0.88rem;
}

/* ── 生成页 ── */
.generate-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

@media (max-width: 1100px) {
  .generate-layout { grid-template-columns: 1fr; }
}

.param-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.param-row-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 12px;
}

.preset-btns {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.preset-btn {
  padding: 6px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: 20px;
  color: var(--text-secondary);
  font-size: 0.78rem;
  cursor: pointer;
  transition: all var(--transition);
}

.preset-btn:hover, .preset-btn.active {
  border-color: var(--border-gold);
  color: var(--gold);
  background: rgba(168, 137, 58, 0.08);
}

.preview-area {
  aspect-ratio: 1;
  background: #f0f1f3;
  border: 1px dashed var(--border-subtle);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
}

.preview-area img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.preview-placeholder {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
  letter-spacing: 0.1em;
}

.preview-placeholder .icon { font-size: 2.5rem; opacity: 0.3; margin-bottom: 12px; }

.preview-meta {
  margin-top: 16px;
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.8;
}

.preview-actions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}

/* ── 图库 ── */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}

.gallery-item {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color var(--transition), transform var(--transition);
  cursor: pointer;
}

.gallery-item:hover {
  border-color: var(--border-gold);
  transform: translateY(-2px);
}

.gallery-thumb {
  aspect-ratio: 1;
  background: var(--bg-input);
  overflow: hidden;
}

.gallery-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.gallery-info {
  padding: 12px 14px;
}

.gallery-prompt {
  font-size: 0.78rem;
  color: var(--text-secondary);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.5;
}

.gallery-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 8px;
  font-size: 0.68rem;
  color: var(--text-muted);
}

.gallery-actions {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}

/* ── 批量 ── */
.batch-progress {
  margin-top: 20px;
}

.progress-bar {
  height: 3px;
  background: var(--bg-input);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 12px;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--gold-dim), var(--gold));
  transition: width 0.4s ease;
  width: 0%;
}

.batch-results {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.batch-result-item {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.batch-result-item img { width: 100%; aspect-ratio: 1; object-fit: cover; }
.batch-result-item .label {
  padding: 8px;
  font-size: 0.68rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── 管理 ── */
.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

th {
  text-align: left;
  padding: 12px 16px;
  font-size: 0.68rem;
  color: var(--text-muted);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--border-subtle);
}

td {
  padding: 12px 16px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
  color: var(--text-secondary);
}

tr:hover td { background: rgba(0, 0, 0, 0.02); }

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.68rem;
  letter-spacing: 0.06em;
}

.badge-admin { background: rgba(168, 137, 58, 0.12); color: var(--gold); }
.badge-user { background: rgba(0, 0, 0, 0.05); color: var(--text-muted); }
.badge-active { color: var(--success); }
.badge-inactive { color: var(--error); }

.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.modal-overlay.show { display: flex; }

.modal {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  padding: 28px;
  max-width: 480px;
  width: 100%;
  box-shadow: var(--shadow);
}

.modal h3 {
  font-family: var(--font-display);
  font-size: 1.3rem;
  margin-bottom: 20px;
  letter-spacing: 0.06em;
}

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 24px;
}

.lightbox {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.92);
  z-index: 2000;
  align-items: center;
  justify-content: center;
  padding: 40px;
}

.lightbox.show { display: flex; }

.lightbox img {
  max-width: 90vw;
  max-height: 85vh;
  object-fit: contain;
  border-radius: var(--radius-sm);
}

.lightbox-close {
  position: absolute;
  top: 24px; right: 32px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 2rem;
  cursor: pointer;
  transition: color var(--transition);
}

.lightbox-close:hover { color: var(--gold); }

.empty-state {
  text-align: center;
  padding: 60px 24px;
  color: var(--text-muted);
}

.empty-state .icon { font-size: 2.5rem; opacity: 0.25; margin-bottom: 16px; }

.loading-overlay {
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.85);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  z-index: 10;
}

.loading-overlay .text {
  font-size: 0.82rem;
  color: var(--text-muted);
  letter-spacing: 0.1em;
}

.hidden { display: none !important; }

@media (max-width: 768px) {
  .sidebar { width: 100%; position: relative; }
  .main-content { margin-left: 0; padding: 20px 16px; }
  .app-shell { flex-direction: column; }
  .param-row, .param-row-3 { grid-template-columns: 1fr; }
}
