/*
 * Alphasms · 用户端 SPA 主题（基于 tw.js 运行时）
 *
 * 设计目标：不动任何 HTML 结构、不动任何 id/class、不动任何 JS 函数。
 * 全量覆盖：sidebar / cards / tables / buttons / inputs / badges / modals / toasts
 */

:root {
  --brand-50:  #eef2ff;
  --brand-100: #e0e7ff;
  --brand-300: #a5b4fc;
  --brand-500: #6366f1;
  --brand-600: #4f46e5;
  --brand-700: #4338ca;
  --brand-900: #312e81;
  --accent-600: #7c3aed;

  --ink-100: #f1f5f9;
  --ink-200: #e2e8f0;
  --ink-300: #cbd5e1;
  --ink-400: #94a3b8;
  --ink-500: #64748b;
  --ink-700: #334155;
  --ink-800: #1e293b;
  --ink-900: #0f172a;

  --surface-page:   #f5f7fb;
  --surface-card:   #ffffff;
  --surface-soft:   #f8fafc;
  --surface-line:   #e5e7eb;

  --success:  #10b981;
  --warning:  #f59e0b;
  --danger:   #ef4444;

  --shadow-sm: 0 1px 2px 0 rgba(15, 23, 42, 0.04);
  --shadow:    0 1px 3px 0 rgba(15, 23, 42, 0.08), 0 1px 2px -1px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 4px 12px -2px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 12px 32px -8px rgba(15, 23, 42, 0.12);
  --shadow-xl: 0 24px 48px -12px rgba(15, 23, 42, 0.18);

  --radius-sm: 6px;
  --radius:    10px;
  --radius-md: 12px;
  --radius-xl: 24px;

  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
               "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
}

/* ─── 基础 ─── */
html, body { font-family: var(--font-sans); -webkit-font-smoothing: antialiased; }
body.bg-gray-50 { background-color: var(--surface-page) !important; color: var(--ink-800); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--ink-300); border-radius: 5px; border: 2px solid var(--surface-page); }
::-webkit-scrollbar-thumb:hover { background: var(--ink-400); }

/* ─── 登录页 ─── */
#login-page {
  background-color: #0b1020;
  background-image:
    radial-gradient(ellipse 80% 60% at 20% 10%, rgba(99, 102, 241, 0.30) 0%, rgba(99, 102, 241, 0) 60%),
    radial-gradient(ellipse 70% 60% at 90% 90%, rgba(139, 92, 246, 0.28) 0%, rgba(139, 92, 246, 0) 60%),
    linear-gradient(180deg, #0b1020 0%, #0f172a 50%, #0b1020 100%);
  background-size: cover;
  background-position: center;
  position: relative;
  overflow: hidden;
}
#login-page::before,
#login-page::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  pointer-events: none;
  z-index: 0;
}
#login-page::before { width: 480px; height: 480px; background: rgba(99, 102, 241, 0.35); top: -120px; left: -120px; animation: float 18s ease-in-out infinite; }
#login-page::after  { width: 560px; height: 560px; background: rgba(139, 92, 246, 0.30); bottom: -160px; right: -160px; animation: float 22s ease-in-out infinite reverse; }
@keyframes float { 0%, 100% { transform: translate(0, 0) scale(1); } 50% { transform: translate(40px, -30px) scale(1.05); } }

#login-page > div {
  position: relative;
  z-index: 1;
  background: rgba(255, 255, 255, 0.98) !important;
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-radius: var(--radius-xl) !important;
  box-shadow: var(--shadow-xl), 0 0 0 1px rgba(255, 255, 255, 0.4) !important;
  padding: 40px 36px !important;
  max-width: 30rem !important;
}
#login-page h1 {
  font-size: 1.75rem !important;
  font-weight: 800 !important;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, var(--brand-600), var(--accent-600));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  margin: 0 0 0.25rem !important;
}
#login-page > div > p {
  color: var(--ink-500) !important;
  font-size: 0.8125rem !important;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin: 0 0 1.75rem !important;
}
#login-form label { color: var(--ink-700); font-weight: 500; font-size: 13px; }
#login-form input {
  background: var(--surface-soft);
  border: 1px solid var(--ink-200) !important;
  border-radius: var(--radius) !important;
  padding: 11px 14px !important;
  font-size: 14px !important;
  transition: all 0.18s ease;
}
#login-form input:hover { border-color: var(--ink-300); }
#login-form input:focus {
  border-color: var(--brand-500) !important;
  background: #fff;
  box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.12) !important;
  outline: none;
}
#login-error { font-size: 13px !important; }

/* ─── 主应用布局：sticky sidebar 让 sidebar 始终跟着滚动 ─── */
/* 用 sticky 替代 fixed：fullPage 截图时 sidebar 会自然铺到与 main 等高，
   解决「sidebar 只占顶部一小段，下面 main 露出来」的视觉破绽 */
body.bg-gray-50 {
  min-height: 100vh;
}
#app {
  display: flex;
  align-items: stretch;
  min-height: 100vh;
}

/* ─── Sidebar：浅色系，柔和不晃眼 ─── */
.sidebar {
  position: sticky !important;       /* 替代原 fixed：滚动时钉在视口顶端 */
  left: 0 !important;
  top: 0 !important;
  align-self: flex-start;            /* sticky 必须 */
  width: 232px !important;
  height: 100vh;                     /* 撑满视口高度 */
  background: #ffffff !important;
  color: var(--ink-700) !important;
  box-shadow: 1px 0 0 #e5e7eb;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  border-right: 1px solid #e5e7eb;
}
.sidebar .logo {
  padding: 22px 24px !important;
  font-size: 17px !important;
  font-weight: 700;
  color: #1e3a8a !important;
  letter-spacing: -0.01em;
  border-bottom: 1px solid #e5e7eb !important;
  background: #fff;
  flex-shrink: 0;
}
.sidebar nav {
  padding: 16px 10px;
  flex: 1;                          /* nav 占满中间可用空间 */
  overflow-y: auto;                  /* 链接多时只让 nav 内部滚动 */
}
.sidebar a {
  display: flex !important;
  align-items: center;
  padding: 10px 14px !important;
  margin-bottom: 2px;
  color: #475569 !important;
  text-decoration: none !important;
  font-size: 13.5px !important;
  font-weight: 500;
  border-radius: 8px;
  transition: all 0.15s ease;
  position: relative;
  cursor: pointer;
}
.sidebar a:hover { background: #f1f5f9 !important; color: #1e3a8a !important; }
.sidebar a.active {
  background: #eef2ff !important;
  color: #1e3a8a !important;
  font-weight: 600;
  box-shadow: inset 3px 0 0 #3b82f6;
}
.sidebar .absolute.bottom-0 {
  border-top: 1px solid #e5e7eb !important;
  background: #fafafa;
  padding: 16px 16px !important;
}
#user-info { color: #475569 !important; line-height: 1.5; font-size: 12px !important; }
#user-info .text-slate-300 { color: #1e3a8a !important; font-weight: 600; font-size: 13px; }

/* ─── Main ─── */
.main {
  margin-left: 0 !important;        /* grid 布局不需要这个 */
  padding: 28px 32px !important;
  min-height: 100vh;
  background: var(--surface-page) !important;
  min-width: 0;                     /* 防止内容溢出 grid 单元 */
}
.main > .page > h2 {
  font-size: 22px !important;
  font-weight: 700 !important;
  letter-spacing: -0.015em;
  color: var(--ink-900);
  margin-bottom: 20px !important;
}

/* ─── Card ─── */
.card {
  background: var(--surface-card) !important;
  border-radius: var(--radius-md) !important;
  padding: 22px !important;
  box-shadow: var(--shadow-sm) !important;
  border: 1px solid rgba(15, 23, 42, 0.04);
  width: 100%;                      /* 强制撑满 main 区域，不再有 max-width 限制 */
  margin-bottom: 18px;
  box-sizing: border-box;
}
.card .font-bold { font-weight: 600 !important; font-size: 15px; color: var(--ink-900); }

/* dashboard 上面的 stat-card 网格（4 张）仍保留并排 */
#stats-cards {
  width: 100%;
}

/* ─── Stat cards ─── */
.stat-card {
  background: var(--surface-card) !important;
  border-radius: var(--radius-md) !important;
  padding: 22px !important;
  box-shadow: var(--shadow-sm) !important;
  border: 1px solid rgba(15, 23, 42, 0.04);
  transition: all 0.2s ease;
}
.stat-card:hover { box-shadow: var(--shadow-md) !important; transform: translateY(-1px); }
.stat-card .text-sm.text-gray-500 { color: var(--ink-500) !important; font-weight: 500; font-size: 13px; }
.stat-card .text-2xl.font-bold { color: var(--ink-900) !important; font-weight: 700 !important; letter-spacing: -0.02em; }
.stat-card .text-xs.text-gray-400 { color: var(--ink-400) !important; }
.stat-card[title*="剩余"] { border-left: 3px solid var(--brand-500); }
.stat-card[title*="剩余"] .text-blue-600 { color: var(--brand-600) !important; }

/* ─── Tables ─── */
table { color: var(--ink-700); width: 100%; border-collapse: separate; border-spacing: 0; }
.main > .page { width: 100%; display: none; }
.main > .page.active { display: block; }
.main { display: block; width: 100%; }
th {
  background: var(--surface-soft) !important;
  font-weight: 600 !important;
  color: var(--ink-700) !important;
  font-size: 12px !important;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 12px 14px !important;
  border-bottom: 1px solid var(--ink-200) !important;
}
td {
  padding: 12px 14px !important;
  border-bottom: 1px solid var(--ink-100) !important;
  font-size: 13px !important;
  color: var(--ink-700);
}
tr:last-child td { border-bottom: none !important; }
tbody tr { transition: background 0.15s ease; }
tbody tr:hover { background: var(--surface-soft); }
tbody tr[style*="cursor:pointer"]:hover { background: rgba(99, 102, 241, 0.04); }

/* ─── Buttons ─── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px !important;
  border-radius: var(--radius-sm) !important;
  font-size: 13px !important;
  font-weight: 500 !important;
  cursor: pointer;
  border: 1px solid transparent !important;
  transition: all 0.15s ease;
  user-select: none;
  line-height: 1.4;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--brand-600) !important; color: #fff !important; box-shadow: 0 1px 2px rgba(67, 56, 202, 0.20); }
.btn-primary:hover:not(:disabled) { background: var(--brand-700) !important; box-shadow: 0 4px 10px rgba(67, 56, 202, 0.30); }
.btn-secondary { background: #fff !important; color: var(--ink-700) !important; border-color: var(--ink-200) !important; }
.btn-secondary:hover:not(:disabled) { background: var(--surface-soft) !important; border-color: var(--ink-300) !important; color: var(--ink-900) !important; }
.btn-success { background: var(--success) !important; color: #fff !important; }
.btn-success:hover:not(:disabled) { background: #059669 !important; }
.btn-danger  { background: var(--danger) !important; color: #fff !important; }
.btn-danger:hover:not(:disabled)  { background: #dc2626 !important; }
.btn-sm { padding: 5px 12px !important; font-size: 12px !important; border-radius: var(--radius-sm) !important; }
.btn.py-2.px-6 { padding: 10px 24px !important; font-size: 14px !important; font-weight: 600 !important; }

/* ─── Inputs ─── */
input, select, textarea {
  border: 1px solid var(--ink-200) !important;
  border-radius: var(--radius-sm) !important;
  padding: 9px 12px !important;
  font-size: 13px !important;
  background: #fff;
  color: var(--ink-800);
  transition: all 0.15s ease;
  outline: none;
  width: 100%;
}
input:hover, select:hover, textarea:hover { border-color: var(--ink-300); }
input:focus, select:focus, textarea:focus {
  border-color: var(--brand-500) !important;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.12) !important;
}
input[type="checkbox"], input[type="file"] { width: auto; }
label { font-size: 13px !important; font-weight: 500 !important; color: var(--ink-700) !important; margin-bottom: 6px !important; display: block; }
select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='%2364748b'%3E%3Cpath fill-rule='evenodd' d='M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z' clip-rule='evenodd'/%3E%3C/svg%3E") !important;
  background-repeat: no-repeat !important;
  background-position: right 8px center !important;
  background-size: 16px !important;
  padding-right: 32px !important;
  appearance: none;
  -webkit-appearance: none;
}

/* ─── Badge ─── */
.badge {
  display: inline-flex !important;
  align-items: center;
  padding: 3px 10px !important;
  border-radius: 999px !important;
  font-size: 11.5px !important;
  font-weight: 600 !important;
  letter-spacing: 0.01em;
  line-height: 1.4;
}
.badge-green  { background: #d1fae5 !important; color: #047857 !important; }
.badge-red    { background: #fee2e2 !important; color: #b91c1c !important; }
.badge-yellow { background: #fef3c7 !important; color: #92400e !important; }
.badge-blue   { background: #dbeafe !important; color: #1e40af !important; }
.badge-gray   { background: var(--ink-100) !important; color: var(--ink-700) !important; }

/* ─── Toast ─── */
.toast {
  position: fixed;
  top: 20px !important;
  right: 20px !important;
  z-index: 9999;
  padding: 12px 20px !important;
  border-radius: var(--radius) !important;
  color: #fff !important;
  font-size: 13.5px !important;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  animation: slideIn 0.28s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.toast.success { background: linear-gradient(135deg, #10b981, #059669) !important; }
.toast.error   { background: linear-gradient(135deg, #ef4444, #dc2626) !important; }
.toast.info    { background: linear-gradient(135deg, var(--brand-600), var(--brand-700)) !important; }
@keyframes slideIn { from { transform: translateX(20px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ─── Modal ─── */
.modal-overlay {
  position: fixed !important;
  inset: 0 !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  z-index: 9999 !important;
  background: rgba(15, 23, 42, 0.55) !important;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  animation: fadeIn 0.18s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: var(--surface-card) !important;
  border-radius: var(--radius-md) !important;
  padding: 28px !important;
  max-width: 500px;
  width: 90%;
  max-height: 88vh;
  overflow-y: auto;
  box-shadow: var(--shadow-xl) !important;
  animation: popIn 0.22s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes popIn { from { transform: scale(0.96) translateY(8px); opacity: 0; } to { transform: scale(1) translateY(0); opacity: 1; } }
.modal h3 { font-size: 17px !important; font-weight: 700 !important; color: var(--ink-900); }

/* ─── Empty state ─── */
.empty-state {
  text-align: center;
  padding: 48px 20px !important;
  color: var(--ink-400) !important;
  font-size: 13.5px;
}

/* ─── Quota box (子账号) ─── */
#quota-box {
  background: linear-gradient(135deg, var(--brand-50), #fff);
  border: 1px solid var(--brand-100);
}

/* ─── Misc color utilities ─── */
.text-gray-500 { color: var(--ink-500) !important; }
.text-gray-400 { color: var(--ink-400) !important; }
.text-gray-600 { color: var(--ink-600) !important; }
.text-blue-500, .text-blue-600 { color: var(--brand-600) !important; }
.text-green-600 { color: var(--success) !important; }
.text-red-600   { color: var(--danger) !important; }
.text-yellow-600 { color: var(--warning) !important; }
.bg-blue-50 { background: var(--brand-50) !important; }
.bg-amber-50 { background: #fffbeb !important; border: 1px solid #fde68a; }
.bg-gray-50 { background: var(--surface-soft) !important; }

/* ─── 响应式 ─── */
@media (max-width: 768px) {
  .sidebar { width: 200px !important; }
  .main { margin-left: 200px !important; padding: 16px !important; }
}

/* ─── 暗色模式（跟随系统）─── */
@media (prefers-color-scheme: dark) {
  :root {
    --surface-page:  #0b1020;
    --surface-card:  #1e293b;
    --surface-soft:  #0f172a;
    --surface-line:  #334155;
  }
  body.bg-gray-50 { background-color: var(--surface-page) !important; color: var(--ink-200); }
  .main { background: var(--surface-page) !important; }
  .card, .stat-card { background: var(--surface-card) !important; border-color: rgba(255, 255, 255, 0.05); }
  .card .font-bold, .main > .page > h2 { color: #f1f5f9; }
  th { background: rgba(15, 23, 42, 0.5) !important; color: var(--ink-300) !important; border-bottom-color: var(--ink-700) !important; }
  td { color: var(--ink-200); border-bottom-color: rgba(51, 65, 85, 0.5) !important; }
  tbody tr:hover { background: rgba(99, 102, 241, 0.06); }
  input, select, textarea { background: var(--ink-800); border-color: var(--ink-700) !important; color: #e2e8f0; }
  label { color: var(--ink-300) !important; }
  .btn-secondary { background: var(--ink-800) !important; color: var(--ink-200) !important; border-color: var(--ink-700) !important; }
  .btn-secondary:hover:not(:disabled) { background: var(--ink-700) !important; }
  .empty-state { color: var(--ink-500) !important; }
  #login-page > div { background: rgba(15, 23, 42, 0.95) !important; color: var(--ink-200); }
  #login-page > div > p { color: var(--ink-400) !important; }
  #login-form input { background: var(--ink-800); border-color: var(--ink-700); color: #e2e8f0; }
}
