/* ============================================================================
   全局样式 —— 简洁浅色风格（无渐变、纯色、左侧菜单布局）
   ========================================================================== */

:root {
  /* 品牌色：单一纯色蓝 */
  --brand: #2563eb;
  --brand-hover: #1d4ed8;
  --brand-soft: #eff6ff;
  --brand-soft-border: #bfdbfe;

  /* 中性色 */
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f1f5f9;
  --border: #e5e7eb;
  --text: #111827;
  --text-2: #374151;
  --text-muted: #6b7280;

  /* 功能色 */
  --success: #16a34a;
  --danger: #dc2626;
  --warning: #d97706;
  --info: #0284c7;

  --radius: 10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow: 0 1px 3px rgba(16, 24, 40, .08), 0 4px 16px rgba(16, 24, 40, .04);
  --shadow-lg: 0 12px 40px rgba(16, 24, 40, .10);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", Roboto, sans-serif;
  font-size: 14.5px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-hover); }

h1, h2, h3, h4, h5, h6 { color: var(--text); font-weight: 600; }

.text-muted { color: var(--text-muted) !important; }

/* 品牌色块（纯色，替代原渐变） */
.brand-bg { background: var(--brand); color: #fff; }
.brand-text { color: var(--brand); }
.brand-soft { background: var(--brand-soft); }

/* 按钮 */
.btn { border-radius: 8px; font-weight: 500; }
.btn-primary {
  background: var(--brand);
  border: 1px solid var(--brand);
  color: #fff;
}
.btn-primary:hover, .btn-primary:focus {
  background: var(--brand-hover);
  border-color: var(--brand-hover);
  color: #fff;
}
.btn-primary:disabled { background: var(--brand); border-color: var(--brand); opacity: .6; }
.btn-outline-secondary { border-color: var(--border); color: var(--text-2); background: #fff; }
.btn-outline-secondary:hover { background: var(--surface-2); color: var(--text); border-color: var(--border); }

/* 卡片 */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
.card-header {
  background: transparent;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  color: var(--text);
}

/* 表单 */
.form-control, .form-select {
  background: #fff;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.form-control:focus, .form-select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}
.form-label { font-weight: 500; color: var(--text-2); }

/* 表格 */
.table { color: var(--text); --bs-table-hover-bg: var(--surface-2); }
.table thead th {
  color: var(--text-muted);
  border-bottom-color: var(--border);
  font-weight: 600;
  font-size: 13px;
  text-transform: none;
}
.table td { border-color: var(--border); vertical-align: middle; }

/* 徽章 */
.badge-soft-primary { background: var(--brand-soft); color: var(--brand); }
.badge-soft-success { background: #ecfdf5; color: var(--success); }
.badge-soft-danger { background: #fef2f2; color: var(--danger); }
.badge-soft-warning { background: #fffbeb; color: var(--warning); }

/* ============================================================================
   应用布局：左侧菜单 + 顶栏 + 内容
   ========================================================================== */
.app-layout { min-height: 100vh; }

.app-sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: 232px;
  background: #fff;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 50;
}
.app-sidebar .brand {
  height: 60px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 20px;
  border-bottom: 1px solid var(--border);
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}
.app-sidebar .brand .logo-mark {
  width: 30px; height: 30px;
  border-radius: 8px;
  background: var(--brand);
  color: #fff;
  display: grid; place-items: center;
  font-size: 15px; font-weight: 700;
}
.app-sidebar .menu { flex: 1; overflow-y: auto; padding: 12px 10px; }
.app-sidebar .menu .menu-group {
  font-size: 11px;
  color: var(--text-muted);
  padding: 14px 12px 6px;
  font-weight: 600;
  letter-spacing: .02em;
}
.app-sidebar .menu a.menu-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 12px;
  border-radius: 8px;
  color: var(--text-2);
  font-size: 14px;
  margin-bottom: 2px;
}
.app-sidebar .menu a.menu-item i { font-size: 16px; width: 18px; text-align: center; color: var(--text-muted); }
.app-sidebar .menu a.menu-item:hover { background: var(--surface-2); color: var(--text); }
.app-sidebar .menu a.menu-item.active { background: var(--brand-soft); color: var(--brand); }
.app-sidebar .menu a.menu-item.active i { color: var(--brand); }

.app-main { margin-left: 232px; display: flex; flex-direction: column; min-height: 100vh; }

.app-topbar {
  height: 60px;
  background: #fff;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 40;
}
.app-topbar .page-title { font-size: 17px; font-weight: 600; margin: 0; }

.app-content { flex: 1; padding: 24px; }

/* 顶栏用户信息 */
.user-chip { display: flex; align-items: center; gap: 10px; }
.user-chip .avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--brand-soft);
  color: var(--brand);
  display: grid; place-items: center;
  font-weight: 600; font-size: 14px;
}
.user-chip .balance { font-size: 13px; color: var(--text-2); }
.user-chip .balance b { color: var(--success); font-weight: 600; }

/* 统计卡片 */
.stat-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
}
.stat-icon {
  width: 46px; height: 46px;
  border-radius: 10px;
  display: grid; place-items: center;
  font-size: 20px;
}
.icon-blue { background: var(--brand-soft); color: var(--brand); }
.icon-green { background: #ecfdf5; color: #059669; }
.icon-amber { background: #fffbeb; color: #d97706; }
.icon-teal { background: #f0fdfa; color: #0d9488; }
.icon-slate { background: #f1f5f9; color: #475569; }

.stat-value { font-size: 22px; font-weight: 700; line-height: 1.2; color: var(--text); }
.stat-label { color: var(--text-muted); font-size: 12.5px; margin-top: 3px; }

/* ============================================================================
   对话页
   ========================================================================== */
.chat-wrap { display: flex; height: calc(100vh - 60px); margin: -24px; }

.chat-sidebar {
  width: 270px;
  border-right: 1px solid var(--border);
  background: #fff;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}
.chat-sidebar-head { padding: 14px 14px 10px; }
.session-list { flex: 1; overflow-y: auto; padding: 6px; }
.session-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px; border-radius: 8px; cursor: pointer;
  color: var(--text-2); margin-bottom: 2px; gap: 8px;
}
.session-item:hover { background: var(--surface-2); }
.session-item.active { background: var(--brand-soft); color: var(--brand); }
.session-item .title { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.session-item .del { opacity: 0; transition: opacity .15s; color: var(--text-muted); }
.session-item:hover .del { opacity: 1; }
.session-item .del:hover { color: var(--danger); }

.chat-main { flex: 1; display: flex; flex-direction: column; min-width: 0; background: var(--bg); }
.chat-messages { flex: 1; overflow-y: auto; padding: 24px 0; }
.chat-msg { display: flex; margin-bottom: 22px; padding: 0 20px; max-width: 840px; margin-left: auto; margin-right: auto; }
.chat-msg.user { justify-content: flex-end; }
.chat-msg .avatar {
  width: 34px; height: 34px; border-radius: 8px;
  display: grid; place-items: center; color: #fff; font-size: 15px; flex-shrink: 0;
  background: var(--brand);
}
.chat-msg.assistant .avatar { background: #fff; color: var(--brand); border: 1px solid var(--border); }
.chat-msg .bubble {
  max-width: 78%;
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 15px;
  line-height: 1.7;
  word-break: break-word;
}
.chat-msg.user .bubble { background: var(--brand); color: #fff; border-bottom-right-radius: 4px; }
.chat-msg.assistant .bubble { background: #fff; border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.chat-msg .meta { font-size: 12px; color: var(--text-muted); margin-top: 6px; }

.chat-input-wrap { border-top: 1px solid var(--border); padding: 14px 20px 18px; background: #fff; }
.chat-input-box { max-width: 840px; margin: 0 auto; }
.chat-input-box textarea {
  border-radius: 12px; resize: none; padding-right: 72px; min-height: 52px; max-height: 200px;
  border: 1px solid var(--border);
}

/* Markdown */
.md-body pre { background: #0f172a; color: #e2e8f0; border-radius: 10px; padding: 14px; overflow-x: auto; }
.md-body code { font-family: "SF Mono", "JetBrains Mono", Consolas, monospace; }
.md-body p { margin-bottom: .6em; }
.md-body p:last-child { margin-bottom: 0; }
.md-body img { max-width: 100%; border-radius: 8px; }
.md-body table { border-collapse: collapse; margin: 8px 0; }
.md-body th, .md-body td { border: 1px solid var(--border); padding: 6px 10px; }

.typing-cursor::after { content: "▍"; animation: blink 1s infinite; color: var(--brand); }
@keyframes blink { 0%, 50% { opacity: 1; } 51%, 100% { opacity: 0; } }

/* ============================================================================
   图片网格
   ========================================================================== */
.image-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.image-card { border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; background: #fff; }
.image-card img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; }
.image-card .body { padding: 10px 12px; }
.image-card .prompt { font-size: 13px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ============================================================================
   会员套餐
   ========================================================================== */
.price-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 26px 24px;
  text-align: center;
  background: #fff;
  position: relative;
  height: 100%;
}
.price-card.featured { border: 2px solid var(--brand); }
.price-card .price { font-size: 34px; font-weight: 700; color: var(--brand); }

/* ============================================================================
   认证页
   ========================================================================== */
.auth-body { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: var(--bg); }
.auth-card { width: 100%; max-width: 420px; }
.auth-brand { text-align: center; margin-bottom: 24px; }
.auth-brand .logo-mark {
  width: 48px; height: 48px; border-radius: 12px;
  background: var(--brand); color: #fff;
  display: grid; place-items: center;
  font-size: 22px; font-weight: 700;
  margin: 0 auto 12px;
}

/* ============================================================================
   首页
   ========================================================================== */
.home-header {
  background: #fff;
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 100;
}
.home-header .inner { max-width: 1120px; margin: 0 auto; padding: 0 24px; height: 64px; display: flex; align-items: center; justify-content: space-between; }
.home-header .logo { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; color: var(--text); }
.home-header .logo .logo-mark { width: 32px; height: 32px; border-radius: 8px; background: var(--brand); color: #fff; display: grid; place-items: center; font-weight: 700; }
.home-header .nav a { color: var(--text-2); margin: 0 14px; font-size: 14px; }
.home-header .nav a:hover { color: var(--brand); }

.home-hero { max-width: 1120px; margin: 0 auto; padding: 80px 24px 64px; text-align: center; }
.home-hero h1 { font-size: 44px; font-weight: 700; letter-spacing: -0.02em; margin-bottom: 16px; }
.home-hero .sub { font-size: 18px; color: var(--text-muted); max-width: 640px; margin: 0 auto 32px; }
.home-hero .badge-pill {
  display: inline-block; padding: 6px 14px; border-radius: 999px;
  background: var(--brand-soft); color: var(--brand);
  font-size: 13px; font-weight: 500; margin-bottom: 24px;
}
.home-cta { display: flex; gap: 12px; justify-content: center; }
.home-cta .btn { padding: 12px 28px; font-size: 15px; border-radius: 10px; }

.home-section { max-width: 1120px; margin: 0 auto; padding: 40px 24px; }
.home-section .section-title { text-align: center; font-size: 28px; font-weight: 700; margin-bottom: 8px; }
.home-section .section-sub { text-align: center; color: var(--text-muted); margin-bottom: 40px; }

.feature-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.feature-card { background: #fff; border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 26px 24px; box-shadow: var(--shadow-sm); }
.feature-card .icon { width: 44px; height: 44px; border-radius: 10px; display: grid; place-items: center; font-size: 20px; margin-bottom: 16px; }
.feature-card h3 { font-size: 17px; font-weight: 600; margin-bottom: 8px; }
.feature-card p { color: var(--text-muted); margin: 0; font-size: 14px; }

.home-footer { border-top: 1px solid var(--border); background: #fff; padding: 28px 24px; text-align: center; color: var(--text-muted); font-size: 13px; }

/* ============================================================================
   其它
   ========================================================================== */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

.pagination { --bs-pagination-color: var(--text-2); --bs-pagination-active-bg: var(--brand); --bs-pagination-active-border-color: var(--brand); }

/* 响应式 */
@media (max-width: 992px) {
  .app-sidebar { transform: translateX(-100%); transition: transform .2s; }
  .app-sidebar.open { transform: translateX(0); }
  .app-main { margin-left: 0; }
  .feature-grid { grid-template-columns: 1fr; }
  .home-hero h1 { font-size: 32px; }
}
@media (max-width: 768px) {
  .chat-sidebar { position: absolute; z-index: 30; height: 100%; transform: translateX(-100%); transition: transform .25s; }
  .chat-sidebar.open { transform: translateX(0); }
  .chat-msg .bubble { max-width: 92%; }
  .app-content { padding: 16px; }
  .chat-wrap { margin: -16px; }
}
