

/* ===== 全局变量 ===== */
:root {
  --bg-primary: #0a0a0f;
  --bg-secondary: #111118;
  --bg-card: #16161f;
  --bg-hover: #1e1e2a;
  --border: #2a2a3a;
  --border-light: #333345;
  --accent: #7c3aed;
  --accent-hover: #6d28d9;
  --accent-light: rgba(124,58,237,0.15);
  --accent2: #06b6d4;
  --accent2-light: rgba(6,182,212,0.12);
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --text-primary: #f1f1f5;
  --text-secondary: #a0a0b8;
  --text-muted: #5a5a72;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 24px rgba(0,0,0,0.4);
  --shadow-lg: 0 8px 48px rgba(0,0,0,0.6);
  --transition: 0.2s ease;
}

/* ===== 重置 ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; scroll-behavior: smooth; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
}
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
button { cursor: pointer; font-family: inherit; }
input, select, textarea { font-family: inherit; }


/* ===== 滚动条 ===== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-secondary); }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ===== 布局 ===== */
.app-layout { display: flex; min-height: 100vh; }

/* ===== 侧边栏 ===== */
.sidebar {
  width: 240px; flex-shrink: 0;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  position: fixed; top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: transform var(--transition);
}
.sidebar-logo {
  padding: 24px 20px 20px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px;
}
.sidebar-logo .logo-icon {
  width: 36px; height: 36px; border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; flex-shrink: 0;
}
.sidebar-logo .logo-text { font-size: 16px; font-weight: 700; letter-spacing: -0.3px; }
.sidebar-logo .logo-text span { color: var(--accent2); }

.sidebar-nav { flex: 1; padding: 12px 10px; overflow-y: auto; }
.nav-section { margin-bottom: 20px; }
.nav-section-title {
  font-size: 10px; font-weight: 600; letter-spacing: 1px;
  color: var(--text-muted); text-transform: uppercase;
  padding: 0 10px; margin-bottom: 6px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: var(--radius-sm);
  color: var(--text-secondary); font-size: 14px;
  transition: all var(--transition); cursor: pointer;
  border: none; background: none; width: 100%; text-align: left;
}
.nav-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.nav-item.active {
  background: var(--accent-light);
  color: var(--accent);
  font-weight: 500;
}
.nav-item .nav-icon { font-size: 16px; width: 20px; text-align: center; flex-shrink: 0; }
.nav-item .nav-badge {
  margin-left: auto; background: var(--accent);
  color: #fff; font-size: 10px; font-weight: 600;
  padding: 1px 6px; border-radius: 10px;
}

.sidebar-footer {
  padding: 12px 10px;
  border-top: 1px solid var(--border);
}
.user-info {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: var(--radius-sm);
  cursor: pointer; transition: background var(--transition);
}
.user-info:hover { background: var(--bg-hover); }
.user-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; flex-shrink: 0;
}
.user-name { font-size: 13px; font-weight: 500; }
.user-email { font-size: 11px; color: var(--text-muted); }


/* ===== 主内容区 ===== */
.main-content {
  margin-left: 240px; flex: 1;
  display: flex; flex-direction: column;
  min-height: 100vh;
}
.page-header {
  padding: 28px 32px 0;
  display: flex; align-items: flex-start; justify-content: space-between;
}
.page-title { font-size: 24px; font-weight: 700; letter-spacing: -0.5px; }
.page-subtitle { font-size: 14px; color: var(--text-secondary); margin-top: 4px; }
.page-body { padding: 24px 32px 40px; flex: 1; }

/* ===== 卡片 ===== */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}
.card-sm { padding: 16px; }
.card-title { font-size: 15px; font-weight: 600; margin-bottom: 16px; }

/* ===== 按钮 ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 18px; border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 500; border: none;
  transition: all var(--transition); cursor: pointer; white-space: nowrap;
}
.btn-primary {
  background: var(--accent); color: #fff;
}
.btn-primary:hover { background: var(--accent-hover); transform: translateY(-1px); box-shadow: 0 4px 16px rgba(124,58,237,0.4); }
.btn-secondary {
  background: var(--bg-hover); color: var(--text-primary);
  border: 1px solid var(--border-light);
}
.btn-secondary:hover { background: var(--border); }
.btn-danger { background: rgba(239,68,68,0.15); color: var(--danger); border: 1px solid rgba(239,68,68,0.3); }
.btn-danger:hover { background: rgba(239,68,68,0.25); }
.btn-lg { padding: 12px 28px; font-size: 15px; border-radius: var(--radius); }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none !important; }
.btn-loading { position: relative; color: transparent !important; }
.btn-loading::after {
  content: ''; position: absolute;
  width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== 表单 ===== */
.form-group { margin-bottom: 18px; }
.form-label { display: block; font-size: 13px; font-weight: 500; color: var(--text-secondary); margin-bottom: 7px; }
.form-control {
  width: 100%; padding: 10px 14px;
  background: var(--bg-secondary); color: var(--text-primary);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: 14px; transition: border-color var(--transition);
  outline: none;
}
.form-control:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-light); }
.form-control::placeholder { color: var(--text-muted); }
select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 100px; }
.form-hint { font-size: 12px; color: var(--text-muted); margin-top: 5px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }


/* ===== 状态徽章 ===== */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px; border-radius: 20px;
  font-size: 12px; font-weight: 500;
}
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-running { color: var(--warning); background: rgba(245,158,11,0.12); }
.badge-success { color: var(--success); background: rgba(16,185,129,0.12); }
.badge-failed  { color: var(--danger);  background: rgba(239,68,68,0.12); }
.badge-pending { color: var(--text-muted); background: var(--bg-hover); }
.badge-running::before { animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:0.3} }

/* ===== 进度条 ===== */
.progress-wrap { background: var(--bg-hover); border-radius: 4px; height: 6px; overflow: hidden; }
.progress-bar {
  height: 100%; border-radius: 4px;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  transition: width 0.4s ease;
}

/* ===== 任务卡片网格 ===== */
.task-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.task-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
  transition: all var(--transition); cursor: pointer;
}
.task-card:hover { border-color: var(--border-light); transform: translateY(-2px); box-shadow: var(--shadow); }
.task-card-thumb {
  width: 100%; aspect-ratio: 16/9;
  background: var(--bg-hover);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden; position: relative;
}
.task-card-thumb img, .task-card-thumb video {
  width: 100%; height: 100%; object-fit: cover;
}
.task-card-thumb .thumb-placeholder { font-size: 32px; color: var(--text-muted); }
.task-card-body { padding: 14px; }
.task-card-model { font-size: 11px; color: var(--accent2); font-weight: 600; margin-bottom: 4px; }
.task-card-prompt {
  font-size: 13px; color: var(--text-secondary);
  overflow: hidden; text-overflow: ellipsis;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  margin-bottom: 10px;
}
.task-card-footer { display: flex; align-items: center; justify-content: space-between; }
.task-card-time { font-size: 11px; color: var(--text-muted); }

/* ===== 上传区域 ===== */
.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 32px; text-align: center;
  cursor: pointer; transition: all var(--transition);
  background: var(--bg-secondary);
}
.upload-zone:hover, .upload-zone.drag-over {
  border-color: var(--accent); background: var(--accent-light);
}
.upload-zone .upload-icon { font-size: 36px; margin-bottom: 10px; }
.upload-zone .upload-text { font-size: 14px; color: var(--text-secondary); }
.upload-zone .upload-hint { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.upload-preview {
  display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px;
}
.upload-preview-item {
  position: relative; width: 80px; height: 80px;
  border-radius: var(--radius-sm); overflow: hidden;
  border: 1px solid var(--border);
}
.upload-preview-item img { width: 100%; height: 100%; object-fit: cover; }
.upload-preview-item .remove-btn {
  position: absolute; top: 3px; right: 3px;
  width: 18px; height: 18px; border-radius: 50%;
  background: rgba(0,0,0,0.7); color: #fff;
  border: none; font-size: 10px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}

/* ===== 模型选择卡片 ===== */
.model-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }
.model-card {
  padding: 14px; border-radius: var(--radius-sm);
  border: 2px solid var(--border); background: var(--bg-secondary);
  cursor: pointer; transition: all var(--transition); text-align: center;
}
.model-card:hover { border-color: var(--border-light); background: var(--bg-hover); }
.model-card.selected { border-color: var(--accent); background: var(--accent-light); }
.model-card .model-icon { font-size: 24px; margin-bottom: 6px; }
.model-card .model-name { font-size: 13px; font-weight: 600; }
.model-card .model-desc { font-size: 11px; color: var(--text-muted); margin-top: 3px; }

/* ===== Toast 通知 ===== */
.toast-container {
  position: fixed; top: 20px; right: 20px;
  z-index: 9999; display: flex; flex-direction: column; gap: 8px;
}
.toast {
  padding: 12px 18px; border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 500;
  box-shadow: var(--shadow-lg); min-width: 240px;
  animation: slideIn 0.3s ease;
  display: flex; align-items: center; gap: 8px;
}
.toast-success { background: #064e3b; border: 1px solid var(--success); color: #6ee7b7; }
.toast-error   { background: #450a0a; border: 1px solid var(--danger);  color: #fca5a5; }
.toast-info    { background: #1e1b4b; border: 1px solid var(--accent);  color: #c4b5fd; }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ===== 空状态 ===== */
.empty-state { text-align: center; padding: 60px 20px; color: var(--text-muted); }
.empty-state .empty-icon { font-size: 48px; margin-bottom: 16px; }
.empty-state .empty-title { font-size: 16px; font-weight: 600; color: var(--text-secondary); margin-bottom: 8px; }
.empty-state .empty-desc { font-size: 14px; }

/* ===== 响应式 ===== */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .page-header, .page-body { padding-left: 16px; padding-right: 16px; }
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
}

/* ===== 登录/注册页 ===== */
.auth-page {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: var(--bg-primary);
  background-image: radial-gradient(ellipse at 20% 50%, rgba(124,58,237,0.08) 0%, transparent 60%),
                    radial-gradient(ellipse at 80% 20%, rgba(6,182,212,0.06) 0%, transparent 50%);
}
.auth-card {
  width: 100%; max-width: 420px;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 16px; padding: 40px;
  box-shadow: var(--shadow-lg);
}
.auth-logo { text-align: center; margin-bottom: 32px; }
.auth-logo .logo-icon {
  width: 56px; height: 56px; border-radius: 16px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  display: flex; align-items: center; justify-content: center;
  font-size: 28px; margin: 0 auto 12px;
}
.auth-logo h1 { font-size: 22px; font-weight: 700; }
.auth-logo p { font-size: 14px; color: var(--text-muted); margin-top: 4px; }
.auth-divider { text-align: center; color: var(--text-muted); font-size: 13px; margin: 20px 0; position: relative; }
.auth-divider::before, .auth-divider::after {
  content: ''; position: absolute; top: 50%; width: 40%; height: 1px; background: var(--border);
}
.auth-divider::before { left: 0; }
.auth-divider::after { right: 0; }
.auth-footer { text-align: center; margin-top: 20px; font-size: 13px; color: var(--text-muted); }
.auth-footer a { color: var(--accent); }
.auth-footer a:hover { text-decoration: underline; }

/* ===== 统计卡片 ===== */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; margin-bottom: 28px; }
.stat-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px;
  display: flex; align-items: center; gap: 16px;
}
.stat-icon {
  width: 48px; height: 48px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center; font-size: 22px; flex-shrink: 0;
}
.stat-icon-purple { background: var(--accent-light); }
.stat-icon-cyan   { background: var(--accent2-light); }
.stat-icon-green  { background: rgba(16,185,129,0.12); }
.stat-icon-yellow { background: rgba(245,158,11,0.12); }
.stat-value { font-size: 28px; font-weight: 700; line-height: 1; }
.stat-label { font-size: 13px; color: var(--text-muted); margin-top: 4px; }

/* ===== 生成面板 ===== */
.gen-layout { display: grid; grid-template-columns: 380px 1fr; gap: 24px; align-items: start; }
.gen-panel { position: sticky; top: 24px; }
.gen-result { min-height: 400px; }
.gen-result-img {
  width: 100%; border-radius: var(--radius);
  border: 1px solid var(--border); overflow: hidden;
  background: var(--bg-secondary);
  display: flex; align-items: center; justify-content: center;
  min-height: 300px;
}
.gen-result-img img { width: 100%; height: auto; display: block; }
.gen-result-video { width: 100%; border-radius: var(--radius); overflow: hidden; }
.gen-result-video video { width: 100%; display: block; }
.gen-status {
  margin-top: 16px; padding: 14px 18px;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; gap: 12px;
}
.gen-status-text { font-size: 14px; color: var(--text-secondary); flex: 1; }

@media (max-width: 1024px) {
  .gen-layout { grid-template-columns: 1fr; }
  .gen-panel { position: static; }
}


/* ========================================
   移动端适配 - 底部导航 + 响应式布局
   ======================================== */

/* 底部导航栏（仅移动端显示） */
.bottom-nav {
  display: none;
  position: fixed; bottom: 0; left: 0; right: 0;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
  z-index: 200;
  padding-bottom: env(safe-area-inset-bottom);
}
.bottom-nav-inner {
  display: flex; align-items: stretch;
  height: 56px;
}
.bottom-nav-item {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 3px; border: none; background: none;
  color: var(--text-muted); font-size: 10px;
  cursor: pointer; transition: color var(--transition);
  padding: 6px 4px;
}
.bottom-nav-item .bnav-icon { font-size: 20px; line-height: 1; }
.bottom-nav-item.active { color: var(--accent); }
.bottom-nav-item:active { background: var(--bg-hover); }

/* 移动端顶部栏 */
.mobile-header {
  display: none;
  position: fixed; top: 0; left: 0; right: 0;
  height: 52px; z-index: 150;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  align-items: center; justify-content: space-between;
  padding: 0 16px;
}
.mobile-header-title { font-size: 16px; font-weight: 700; }
.mobile-header-logo {
  display: flex; align-items: center; gap: 8px;
  font-size: 15px; font-weight: 700;
}
.mobile-header-logo .logo-icon {
  width: 28px; height: 28px; border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  display: flex; align-items: center; justify-content: center;
  font-size: 14px;
}

@media (max-width: 768px) {
  /* 显示移动端组件 */
  .bottom-nav { display: block; }
  .mobile-header { display: flex; }

  /* 隐藏桌面侧边栏 */
  .sidebar { display: none !important; }

  /* 主内容区适配 */
  .main-content {
    margin-left: 0 !important;
    padding-top: 52px;
    padding-bottom: 72px;
  }

  /* 页面内边距缩小 */
  .page-header { padding: 16px 16px 0; }
  .page-body { padding: 16px 16px 24px; }
  .page-title { font-size: 18px; }
  .page-subtitle { font-size: 13px; }

  /* 卡片内边距 */
  .card { padding: 16px; }

  /* 生成布局：单列 */
  .gen-layout {
    grid-template-columns: 1fr !important;
    gap: 16px;
  }
  .gen-panel { position: static !important; }

  /* 统计卡片：2列 */
  .stats-grid {
    grid-template-columns: 1fr 1fr !important;
    gap: 10px;
  }
  .stat-card { padding: 14px; gap: 10px; }
  .stat-icon { width: 38px; height: 38px; font-size: 18px; }
  .stat-value { font-size: 22px; }

  /* 任务网格：2列 */
  .task-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 10px;
  }

  /* 模型选择：2列 */
  .model-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 8px;
  }
  .model-card { padding: 10px 8px; }
  .model-card .model-icon { font-size: 20px; }
  .model-card .model-name { font-size: 12px; }
  .model-card .model-desc { font-size: 10px; }

  /* 表单行：单列 */
  .form-row, .form-row-3 { grid-template-columns: 1fr !important; gap: 0; }

  /* 按钮 */
  .btn-lg { padding: 11px 20px; font-size: 14px; }

  /* 首页 hero */
  .hero h1 { font-size: 32px; letter-spacing: -1px; }
  .hero p { font-size: 15px; }
  .hero-features { grid-template-columns: 1fr 1fr !important; gap: 10px; margin-top: 48px; }
  .feature-card { padding: 16px; }
  .navbar { padding: 12px 16px; }

  /* 认证页 */
  .auth-card { padding: 28px 20px; margin: 16px; }

  /* 任务表格：隐藏部分列 */
  .tasks-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

  /* 上传区域 */
  .upload-zone { padding: 20px 16px; }
  .upload-zone .upload-icon { font-size: 28px; }

  /* Toast */
  .toast-container { top: 60px; right: 10px; left: 10px; }
  .toast { min-width: unset; width: 100%; }

  /* dashboard 最近作品：单列 */
  #recentImages, #recentVideos {
    grid-template-columns: repeat(2, 1fr) !important;
  }
}

@media (max-width: 400px) {
  .stats-grid { grid-template-columns: 1fr 1fr !important; }
  .task-grid { grid-template-columns: 1fr 1fr !important; }
  .hero-features { grid-template-columns: 1fr !important; }
}


/* 底部导航图标用 emoji 字体渲染 */
.bnav-icon {
  font-size: 22px; line-height: 1;
  font-family: "Apple Color Emoji","Segoe UI Emoji","Noto Color Emoji",sans-serif;
}
/* 移动端 logo icon 文字居中 */
.mobile-header .logo-icon {
  width: 28px; height: 28px; border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 14px; margin-right: 8px; flex-shrink: 0;
}
/* 防止 iOS 双击缩放 */
button, a { touch-action: manipulation; }
/* 移动端输入框字体不缩放 */
@media (max-width: 768px) {
  input, select, textarea { font-size: 16px !important; }
}


/* ===== Lucide 图标样式 ===== */
.lucide-icon, i[data-lucide] {
  display: inline-block;
  vertical-align: middle;
  flex-shrink: 0;
  stroke-width: 1.75;
}
/* 侧边栏导航图标 */
.nav-icon i[data-lucide],
.nav-icon .lucide-icon {
  width: 18px !important;
  height: 18px !important;
}
/* 底部导航图标 */
.bnav-icon i[data-lucide],
.bnav-icon .lucide-icon {
  width: 22px !important;
  height: 22px !important;
}
/* 统计卡片图标 */
.stat-icon i[data-lucide] {
  width: 24px !important;
  height: 24px !important;
}
/* 按钮内图标 */
.btn i[data-lucide] {
  width: 15px !important;
  height: 15px !important;
}
/* 模型卡片图标 */
.model-icon i[data-lucide] {
  width: 26px !important;
  height: 26px !important;
}
/* 空状态图标 */
.empty-icon i[data-lucide] {
  width: 48px !important;
  height: 48px !important;
  opacity: 0.4;
}
/* feature 卡片图标 */
.feature-icon i[data-lucide] {
  width: 30px !important;
  height: 30px !important;
}
/* logo 图标 */
.logo-icon i[data-lucide] {
  width: 20px !important;
  height: 20px !important;
  color: #fff;
}
