/* 亦舒智能体 - 深色商务 Dashboard 主题 */

:root {
  --bg: #0b0c15;
  --surface: #151725;
  --surface-2: #1e2030;
  --surface-3: #262a3f;
  --border: rgba(255, 255, 255, 0.08);
  --text: #e8eaf6;
  --text-2: #8b92a8;
  --text-3: #5b627a;
  --primary: #6366f1;
  --primary-2: #a855f7;
  --accent: #22d3ee;
  --success: #34d399;
  --warning: #fbbf24;
  --danger: #f87171;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
  --radius: 16px;
  --radius-sm: 12px;
}

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

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

a { text-decoration: none; color: inherit; }
button { font-family: inherit; }

/* ===== 顶部栏 ===== */
.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 64px;
  background: rgba(11, 12, 21, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
}
.topbar .logo { font-size: 20px; font-weight: 800; letter-spacing: 0.5px; }
.topbar .logo span {
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.topbar .quota {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 6px 16px;
  font-size: 13px;
  color: var(--text-2);
  display: flex;
  align-items: center;
  gap: 6px;
}
.topbar .quota b { color: var(--warning); font-size: 15px; }
.topbar .topbar-right { display: flex; align-items: center; gap: 12px; }
.topbar .topbar-right #admin-entry {
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: #fff;
  border-radius: 20px;
  padding: 6px 16px;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.35);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.topbar .topbar-right #admin-entry:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(99, 102, 241, 0.5);
}

/* ===== 布局 ===== */
.layout {
  display: flex;
  min-height: 100vh;
  padding-top: 64px;
}

/* ===== 侧边栏 ===== */
.sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  position: fixed;
  top: 64px; bottom: 0; left: 0;
  overflow-y: auto;
  padding: 20px 12px;
  z-index: 90;
}
.sidebar nav { display: flex; flex-direction: column; gap: 6px; }
.sidebar nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  color: var(--text-2);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}
.sidebar nav a:hover { background: var(--surface-2); color: var(--text); }
.sidebar nav a.active {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.18), rgba(168, 85, 247, 0.12));
  color: var(--text);
  border: 1px solid rgba(99, 102, 241, 0.25);
}
.sidebar nav a .icon {
  width: 22px; height: 22px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 15px;
}
.sidebar nav a.logout { margin-top: 12px; color: var(--danger); }
.sidebar nav a.logout:hover { background: rgba(248, 113, 113, 0.12); }

/* ===== 主内容区 ===== */
.main {
  flex: 1;
  margin-left: 220px;
  padding: 28px 32px 60px;
  width: calc(100% - 220px);
}

.page { display: none; animation: fadeIn 0.25s ease; }
.page.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.page-title {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 6px;
}
.page-subtitle {
  color: var(--text-2);
  font-size: 14px;
  margin-bottom: 24px;
}

/* ===== 卡片 ===== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}
.card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.12), transparent);
}
.card h2 { font-size: 18px; margin-bottom: 6px; font-weight: 700; }
.card .desc { color: var(--text-2); font-size: 13px; margin-bottom: 20px; }

.card-glow {
  border-color: rgba(99, 102, 241, 0.35);
  box-shadow: 0 8px 32px rgba(99, 102, 241, 0.12), var(--shadow);
}
.card-glow::after {
  content: '';
  position: absolute;
  top: -50%; right: -50%;
  width: 200px; height: 200px;
  background: radial-gradient(circle, rgba(99,102,241,0.15), transparent 70%);
  pointer-events: none;
}

/* ===== Dashboard 矩阵 ===== */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  margin-bottom: 24px;
}
.dashboard-grid .card { margin-bottom: 0; cursor: pointer; transition: transform 0.15s, border-color 0.2s; }
.dashboard-grid .card:hover { transform: translateY(-3px); border-color: rgba(99, 102, 241, 0.45); }
.dashboard-grid .card .icon-box {
  width: 44px; height: 44px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  margin-bottom: 14px;
  background: linear-gradient(135deg, rgba(99,102,241,0.18), rgba(168,85,247,0.12));
  border: 1px solid rgba(99, 102, 241, 0.25);
}
.dashboard-grid .card h3 { font-size: 16px; margin-bottom: 4px; }
.dashboard-grid .card .desc { margin-bottom: 0; }

.dashboard-row {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 20px;
}

.stat-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 18px;
  text-align: center;
}
.stat-card .num {
  font-size: 26px;
  font-weight: 800;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.stat-card .lbl { font-size: 12px; color: var(--text-2); margin-top: 4px; }

/* ===== 表单 ===== */
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; color: var(--text-2); margin-bottom: 6px; font-weight: 500; }
.input, .select, textarea.input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 15px;
  background: var(--surface-2);
  color: var(--text);
  outline: none;
  transition: border 0.2s, box-shadow 0.2s;
}
.input::placeholder, .select::placeholder { color: var(--text-3); }
.input:focus, .select:focus, textarea.input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}
textarea.input { min-height: 90px; resize: vertical; }

select option { background: var(--surface-2); color: var(--text); }

.btn {
  display: inline-block;
  width: 100%;
  border: none;
  border-radius: 10px;
  padding: 13px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  transition: opacity 0.2s, transform 0.1s, box-shadow 0.2s;
}
.btn:active { transform: scale(0.98); }
.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: #fff;
  box-shadow: 0 4px 16px rgba(99, 102, 241, 0.3);
}
.btn-primary:hover { opacity: 0.92; box-shadow: 0 6px 20px rgba(99, 102, 241, 0.4); }
.btn-primary:disabled {
  background: linear-gradient(135deg, #3f4266, #4a3a5e);
  color: var(--text-2);
  cursor: not-allowed;
  box-shadow: none;
}
.btn-ghost {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--surface-3); }
.btn-danger { background: rgba(248, 113, 113, 0.15); color: var(--danger); border: 1px solid rgba(248, 113, 113, 0.25); }
.btn-danger:hover { background: rgba(248, 113, 113, 0.25); }

.btn-row { display: flex; gap: 12px; }
.btn-row .btn { flex: 1; }

/* ===== 结果卡片 ===== */
.result-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  margin-bottom: 18px;
  box-shadow: var(--shadow);
  border-left: 3px solid var(--primary);
}
.result-card .r-title { font-size: 17px; font-weight: 700; margin-bottom: 14px; }
.result-card .r-label {
  font-size: 11px;
  color: var(--accent);
  font-weight: 700;
  margin: 16px 0 6px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
}
.result-card .r-script {
  font-size: 15px;
  line-height: 1.85;
  color: var(--text);
  white-space: pre-wrap;
  background: var(--surface-2);
  border-radius: 10px;
  padding: 14px;
  border: 1px solid var(--border);
}
.result-card .r-tags { color: var(--primary); font-size: 14px; line-height: 1.7; }
.result-card .r-meta { color: var(--text-2); font-size: 13px; line-height: 1.7; }

.empty { text-align: center; color: var(--text-2); padding: 50px 0; font-size: 14px; }

/* ===== 历史列表 ===== */
.history-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  margin-bottom: 12px;
  cursor: pointer;
  transition: background 0.15s;
}
.history-item:hover { background: var(--surface-2); }
.history-item .h-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.history-item .h-title { font-size: 15px; font-weight: 600; }
.history-item .h-industry {
  font-size: 11px;
  background: rgba(99, 102, 241, 0.12);
  color: var(--primary);
  padding: 3px 8px;
  border-radius: 10px;
}
.history-item .h-time { font-size: 12px; color: var(--text-3); }

/* ===== 资产网格 ===== */
.asset-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.avatar-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 14px;
  margin-top: 14px;
}
.avatar-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px;
  text-align: center;
}
.avatar-card img {
  width: 100%;
  border-radius: 8px;
  aspect-ratio: 1;
  object-fit: cover;
  border: 2px solid transparent;
}
.avatar-card.default img { border-color: var(--primary); }
.avatar-card .name { font-size: 12px; font-weight: 600; margin-top: 8px; }
.avatar-card .actions { display: flex; gap: 6px; margin-top: 8px; }
.avatar-card .actions .btn { padding: 4px 6px; font-size: 11px; width: auto; flex: 1; }

.voice-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  margin-bottom: 10px;
}
.voice-card .v-title { font-size: 14px; font-weight: 600; display: flex; align-items: center; gap: 8px; }

/* ===== 视频网格 ===== */
.video-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 18px;
}
.video-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.video-card video { width: 100%; display: block; }
.video-card .info { padding: 12px 14px; }
.video-card .title { font-size: 14px; font-weight: 600; }
.video-card .time { font-size: 12px; color: var(--text-3); margin-top: 4px; }

/* ===== 管理后台 ===== */
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 16px; }
.stat-grid .stat-card { background: var(--surface); border: 1px solid var(--border); }

.table-wrap { overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  font-size: 13px;
}
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); }
th { background: var(--surface-2); font-weight: 600; color: var(--text-2); white-space: nowrap; }
td { color: var(--text); }
.status-badge { font-size: 11px; padding: 3px 8px; border-radius: 10px; }
.status-used { background: rgba(248, 113, 113, 0.12); color: var(--danger); }
.status-unused { background: rgba(52, 211, 153, 0.12); color: var(--success); }

.status-pending { background: rgba(251, 191, 36, 0.12); color: var(--warning); }
.status-processing { background: rgba(34, 211, 238, 0.12); color: var(--accent); }
.status-done { background: rgba(52, 211, 153, 0.12); color: var(--success); }
.status-failed { background: rgba(248, 113, 113, 0.12); color: var(--danger); }

/* ===== 步骤条 ===== */
.steps {
  display: flex;
  justify-content: space-between;
  margin-bottom: 24px;
  position: relative;
}
.steps::before {
  content: '';
  position: absolute;
  top: 14px; left: 10%; right: 10%;
  height: 2px;
  background: var(--surface-3);
  z-index: 0;
}
.step {
  position: relative;
  z-index: 1;
  text-align: center;
  flex: 1;
}
.step .dot {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--surface-3);
  border: 2px solid var(--border);
  color: var(--text-2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
}
.step.active .dot { background: var(--primary); border-color: var(--primary); color: #fff; }
.step.done .dot { background: var(--success); border-color: var(--success); color: #fff; }
.step .label { display: block; margin-top: 6px; font-size: 12px; color: var(--text-2); }
.step.active .label { color: var(--text); }

/* ===== 提示条 ===== */
.toast {
  position: fixed;
  top: 80px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 12px 24px;
  border-radius: 24px;
  font-size: 14px;
  z-index: 999;
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
  max-width: 90%;
  text-align: center;
  box-shadow: var(--shadow);
}
.toast.show { opacity: 1; }
.toast.error { background: rgba(248, 113, 113, 0.15); border-color: rgba(248, 113, 113, 0.4); color: var(--danger); }

/* ===== 加载中 ===== */
.loading { text-align: center; color: var(--text-2); padding: 30px 0; }
.spinner {
  display: inline-block;
  width: 24px; height: 24px;
  border: 3px solid var(--surface-3);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 8px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== 管理后台兼容样式 ===== */
.navbar {
  background: var(--surface);
  color: var(--text);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}
.navbar-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
}
.navbar .logo { font-size: 18px; font-weight: 700; }
.navbar .logo span { color: var(--primary); }
.navbar .quota { font-size: 14px; }
.navbar .quota a { color: var(--text-2); }
.navbar .quota a:hover { color: var(--text); }

.page { max-width: 1200px; margin: 0 auto; padding: 24px; }
.page.admin-page { display: block; }
.tab-content { padding: 0; }

/* ===== 登录页 ===== */
.auth-wrap {
  max-width: 420px;
  margin: 0 auto;
  padding: 80px 24px 40px;
}
.auth-logo { text-align: center; margin-bottom: 40px; }
.auth-logo .name { font-size: 32px; font-weight: 800; letter-spacing: 1px; color: var(--text); }
.auth-logo .name span {
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.auth-logo .sub { color: var(--text-2); font-size: 14px; margin-top: 10px; }

.tabs {
  display: flex;
  margin-bottom: 22px;
  border-bottom: 1px solid var(--border);
}
.tabs button {
  flex: 1;
  background: none;
  border: none;
  padding: 12px 0;
  font-size: 15px;
  color: var(--text-2);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.2s;
}
.tabs button.active { color: var(--primary); font-weight: 600; border-bottom-color: var(--primary); }
.tabs button:hover { color: var(--text); }

/* ===== 响应式 ===== */
@media (max-width: 1024px) {
  .dashboard-grid { grid-template-columns: repeat(2, 1fr); }
  .dashboard-row { grid-template-columns: 1fr; }
  .asset-grid { grid-template-columns: 1fr; }
  .stat-row { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  .topbar { padding: 0 16px; }
  .sidebar { display: none; }
  .main { margin-left: 0; max-width: 100%; padding: 20px 16px 40px; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .stat-row { grid-template-columns: repeat(2, 1fr); }
  .card { padding: 18px; }
  .page-title { font-size: 20px; }
}

/* ===== 视频生成进度条 ===== */
.prog-wrap { width: 100%; max-width: 420px; margin: 0 auto; }
.prog-bar {
  width: 100%;
  height: 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.1);
  overflow: hidden;
}
.prog-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #6366f1, #8b5cf6, #ec4899);
  transition: width 0.6s ease;
}
.prog-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 8px;
  font-size: 12px;
  color: var(--text-2);
}
.prog-meta span:last-child { color: var(--primary); font-weight: 600; }
