/* ========================================
 * components.css - 可复用 UI 组件样式
 * 依赖 theme.css 的 CSS 变量
 * ======================================== */

/* --- 按钮 --- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0.625rem 1.25rem;
  border: none; border-radius: var(--radius);
  font-size: 0.875rem; font-weight: 500;
  cursor: pointer; transition: opacity 0.15s;
  text-decoration: none; line-height: 1.4;
}
.btn:hover { opacity: 0.9; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary { background: var(--primary-action); color: var(--primary-foreground); }
.btn-secondary { background: var(--secondary); color: var(--secondary-foreground); }
.btn-destructive { background: var(--destructive); color: var(--destructive-foreground); }
.btn-danger { background: var(--destructive); color: var(--destructive-foreground); }
.btn-outline {
  background: transparent; color: var(--foreground);
  border: 1px solid var(--border);
}
.btn-ghost { background: transparent; color: var(--foreground); }
.btn-ghost:hover { background: var(--accent); }

.btn-sm { padding: 0.375rem 0.75rem; font-size: 0.8125rem; }
.btn-lg { padding: 0.75rem 1.75rem; font-size: 1rem; }

/* --- 表单字段 --- */
.field { margin-bottom: 1rem; }
.field-label {
  display: block; margin-bottom: 0.375rem;
  font-size: 0.875rem; font-weight: 500;
}
.field-input {
  width: 100%; padding: 0.625rem 0.75rem;
  border: 1px solid var(--input); border-radius: var(--radius);
  background: var(--background); color: var(--foreground);
  font-size: 0.875rem; line-height: 1.4;
  outline: none; transition: border-color 0.15s;
}
.field-input:focus-visible {
  border-color: var(--ring);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--ring) 20%, transparent);
}
.field-error { color: var(--destructive); font-size: 0.8125rem; margin-top: 0.25rem; }

/* --- 表格 --- */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); }
.table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
.table th {
  text-align: left; padding: 0.75rem 1rem;
  font-weight: 600; background: var(--muted);
  border-bottom: 1px solid var(--border);
}
.table td { padding: 0.75rem 1rem; border-bottom: 1px solid var(--border); }
.table tr:last-child td { border-bottom: none; }

/* --- 分页 --- */
.pagination {
  display: flex; align-items: center; justify-content: center;
  gap: 0.25rem; padding: 1rem 0;
}
.pagination a, .pagination span {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 2rem; height: 2rem; padding: 0 0.5rem;
  border-radius: var(--radius); font-size: 0.875rem;
  text-decoration: none;
}
.pagination a { color: var(--foreground); border: 1px solid var(--border); }
.pagination a:hover { background: var(--accent); }
.pagination .active {
  background: var(--active-bg); color: var(--primary);
  border: 1px solid var(--primary);
}
.pagination .disabled { opacity: 0.5; pointer-events: none; }

/* --- 状态横幅 --- */
.status {
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  font-size: 0.875rem;
}
.status.success { background: oklch(0.92 0.08 145); color: oklch(0.3 0.1 145); }
.status.error { background: oklch(0.92 0.08 25); color: oklch(0.35 0.15 25); }
.status.warning { background: oklch(0.93 0.08 85); color: oklch(0.35 0.1 85); }
.status.info { background: oklch(0.92 0.06 240); color: oklch(0.35 0.1 240); }

/* --- 加载 spinner --- */
.loading-spinner {
  display: inline-block; width: 1.25rem; height: 1.25rem;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading-block {
  display: flex; align-items: center; justify-content: center;
  padding: 2rem; color: var(--muted-foreground);
  gap: 0.5rem;
}

/* --- 卡片 --- */
.card {
  background: var(--card); color: var(--card-foreground);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.5rem; box-shadow: var(--shadow-sm);
}

/* --- Header / Footer 通用 --- */
.site-header {
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 0;
  background: var(--background);
}
.site-header .container {
  display: flex; justify-content: space-between; align-items: center;
}
.site-header .logo { font-weight: 700; font-size: 1.25rem; color: var(--foreground); }
/* .header-brand - 营销面词标：衬线 + 蓝划线手势同源于 hero（见 stellar-design-decisions.md S1）*/
.site-header .header-brand {
  font-family: var(--font-serif); font-weight: 700; font-size: 1.125rem;
  letter-spacing: -0.01em; color: var(--foreground); text-decoration: none;
}
.site-header nav { display: flex; align-items: center; gap: 1.25rem; }
.site-header nav a { color: var(--muted-foreground); font-size: 0.875rem; }
.site-header nav a:hover { color: var(--foreground); }
.site-header nav a.btn-primary,
.site-header nav a.btn-primary:hover {
  color: var(--primary-foreground);
  text-decoration: none;
}

@media (max-width: 768px) {
  .site-header .container {
    flex-wrap: wrap;
    gap: 0.75rem;
  }
  .site-header .logo {
    flex: 0 0 auto;
    white-space: nowrap;
  }
  .site-header nav {
    width: 100%;
    flex-wrap: wrap;
    gap: 0.75rem;
    overflow: visible;
    padding-bottom: 0.25rem;
  }
  .site-header nav > * {
    flex: 0 0 auto;
  }
  .site-header nav > a,
  .site-header nav button,
  .site-header nav select {
    min-height: 2.75rem;
  }
  .site-header nav > a {
    display: inline-flex;
    align-items: center;
  }
  .site-header .theme-toggle {
    width: 2.75rem;
    height: 2.75rem;
  }
}

.site-footer {
  border-top: 1px solid var(--border);
  padding: 1.5rem 0; text-align: center;
  color: var(--muted-foreground); font-size: 0.875rem;
}

.site-footer__links { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.5rem 1.25rem; margin-bottom: 0.75rem; }
.site-footer__links a { color: inherit; }
.site-footer p { margin: 0; }

/* --- Locale 切换器 --- */
.locale-switcher {
  position: relative;
  display: inline-flex;
}
.locale-switcher select {
  appearance: none;
  padding: 0.375rem 1.75rem 0.375rem 0.625rem;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--background); color: var(--foreground);
  font-size: 0.8125rem; cursor: pointer;
}
.locale-switcher::after {
  content: "\25BC"; position: absolute; right: 0.5rem; top: 50%;
  transform: translateY(-50%); font-size: 0.625rem; pointer-events: none;
  color: var(--muted-foreground);
}

/* --- 翻译器 - Card + TopBar + Grid + CreditsBar --- */
.translator-card {
  max-width: 56rem; margin: 0 auto;
}

/* TopBar: 语言选择 + 箭头 + 操作按钮 */
.translator-topbar {
  display: flex; align-items: center; gap: 0.75rem;
  padding-bottom: 1.25rem; margin-bottom: 1.25rem;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.translator-topbar .field-input { width: auto; min-width: 8rem; }
.translator-topbar__arrow {
  font-size: 1.125rem; color: var(--muted-foreground);
  flex-shrink: 0;
}
.translator-topbar__spacer { flex: 1; }
.translator-topbar__actions { display: flex; gap: 0.5rem; }

/* 内容区: 左右分栏 */
.translator-grid {
  display: grid; grid-template-columns: 1fr 1fr;
  min-height: 400px; border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
}
.translator-panel {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 1.5rem; position: relative;
}
.translator-panel + .translator-panel {
  border-left: 1px solid var(--border);
}
.translator-panel__label {
  position: absolute; top: 0.75rem; left: 1rem;
  font-size: 0.75rem; font-weight: 600; text-transform: uppercase;
  color: var(--muted-foreground); letter-spacing: 0.05em;
}
.translator-panel__img {
  width: 100%; min-height: 260px; max-height: 500px;
  object-fit: contain; border-radius: var(--radius);
  border: 1px solid var(--border); background: var(--muted);
  padding: 0.5rem;
}

/* PDF 信息面板 */
.translator-panel__pdf {
  display: flex; flex-direction: column; align-items: center;
  gap: 0.75rem; color: var(--muted-foreground);
}
.translator-panel__pdf svg { width: 3rem; height: 3rem; }
.translator-panel__pdf span {
  font-size: 0.875rem; word-break: break-all; text-align: center;
}

/* 占位符 */
.translator-placeholder {
  display: flex; flex-direction: column;
  align-items: center; gap: 0.75rem;
  color: var(--muted-foreground);
}
.translator-placeholder svg { width: 3rem; height: 3rem; opacity: 0.5; }
.translator-placeholder span { font-size: 0.875rem; }

/* 处理中: spinner + 进度条 + step pills */
.translator-processing {
  display: flex; flex-direction: column;
  align-items: center; gap: 1rem; width: 100%;
  padding: 0 1rem;
}
.translator-processing .loading-spinner {
  width: 2.5rem; height: 2.5rem;
}
.translator-step-pills {
  display: flex; gap: 0.5rem; flex-wrap: wrap;
  justify-content: center;
}
.translator-step-pill {
  padding: 0.25rem 0.75rem; border-radius: 9999px;
  font-size: 0.75rem; font-weight: 500;
  background: var(--muted); color: var(--muted-foreground);
  transition: background 0.2s, color 0.2s;
}
.translator-step-pill--active {
  background: var(--active-bg); color: var(--primary);
}
.translator-step-pill--done {
  background: oklch(0.85 0.08 145); color: oklch(0.3 0.1 145);
}

/* 结果区 */
.translator-result { text-align: center; width: 100%; }
.translator-result img {
  max-width: 100%; max-height: 500px;
  object-fit: contain; border-radius: var(--radius);
}
.translator-result .btn { margin-top: 1rem; }

/* Credits Bar: 底栏 */
.translator-credits-bar {
  display: flex; justify-content: space-between; align-items: center;
  padding-top: 1rem; margin-top: 1.25rem;
  border-top: 1px solid var(--border);
  font-size: 0.875rem; color: var(--muted-foreground);
}
.translator-credits-bar__cost { font-weight: 500; color: var(--foreground); }

/* 错误行内 */
.translator-error {
  padding: 0.75rem 1rem; border-radius: var(--radius);
  background: oklch(0.92 0.08 25); color: oklch(0.35 0.15 25);
  font-size: 0.875rem; text-align: center;
  margin-top: 0.75rem;
}

/* --- 进度条 --- */
.progress-bar {
  width: 100%; height: 0.5rem;
  background: var(--muted); border-radius: 9999px;
  overflow: hidden;
}
.progress-bar__fill {
  height: 100%; background: var(--primary);
  border-radius: 9999px;
  transition: width 0.3s ease;
}

/* --- 上传区 --- */
.upload-zone {
  border: 2px dashed var(--border); border-radius: var(--radius);
  padding: 3rem 1.5rem; text-align: center;
  cursor: pointer; transition: border-color 0.15s, background 0.15s;
  min-height: 400px; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
}
.upload-zone:hover, .upload-zone--active {
  border-color: var(--primary);
  background: var(--accent);
}
/* 圆形图标容器 */
.upload-zone__icon {
  width: 5rem; height: 5rem; border-radius: 50%;
  background: var(--accent); display: flex;
  align-items: center; justify-content: center;
  margin-bottom: 1.25rem;
}
.upload-zone__icon svg { width: 2rem; height: 2rem; color: var(--primary); }
.upload-zone__title {
  margin: 0 0 0.25rem; font-size: 1.125rem; font-weight: 600;
  color: var(--foreground);
}
.upload-zone__hint {
  font-size: 0.8125rem; color: var(--muted-foreground);
  margin-bottom: 0.5rem;
}
/* 文件类型 badges */
.upload-zone__badges {
  display: flex; gap: 0.375rem; justify-content: center;
  flex-wrap: wrap; margin-bottom: 1rem;
}
.badge {
  display: inline-flex; padding: 0.125rem 0.5rem;
  border-radius: 9999px; font-size: 0.6875rem; font-weight: 500;
  border: 1px solid var(--border); color: var(--muted-foreground);
  background: var(--background);
}
/* Or 分隔线 */
.upload-zone__separator {
  display: flex; align-items: center; gap: 0.75rem;
  width: 100%; max-width: 16rem; margin-bottom: 1rem;
  font-size: 0.8125rem; color: var(--muted-foreground);
}
.upload-zone__separator::before,
.upload-zone__separator::after {
  content: ""; flex: 1; height: 1px; background: var(--border);
}

/* --- 批量翻译网格 --- */
.batch-grid {
  display: grid; grid-template-columns: repeat(5, 1fr);
  gap: 0.75rem; padding: 1rem 0;
}
.batch-item {
  position: relative; aspect-ratio: 1;
  border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; background: var(--muted);
}
.batch-item__thumb {
  width: 100%; height: 100%; object-fit: cover;
}
.batch-item__name {
  position: absolute; bottom: 0; left: 0; right: 0;
  padding: 0.25rem 0.375rem;
  background: oklch(0.15 0 0 / 0.7); color: white;
  font-size: 0.6875rem; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}
/* overlay 默认: 全屏遮罩（给 processing 用） */
.batch-item__overlay {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 0.375rem;
  background: transparent;
}
/* processing: 全屏半透黑遮罩，聚焦 spinner */
.batch-item--processing .batch-item__overlay {
  background: oklch(0.15 0 0 / 0.5);
}
/* done/error/skipped: 内容级浮层，不遮图 */
.batch-item--done .batch-item__overlay,
.batch-item--error .batch-item__overlay,
.batch-item--skipped .batch-item__overlay {
  inset: auto;
  position: absolute; top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: auto; height: auto;
  background: oklch(0.15 0 0 / 0.6);
  border-radius: var(--radius);
  padding: 0.25rem 0.375rem;
  gap: 0.125rem;
}
/* 状态边框 - 卡片级反馈，缩略图不降 opacity */
.batch-item--done { outline: 2px solid oklch(0.85 0.15 145); outline-offset: -2px; }
.batch-item--error { outline: 2px solid oklch(0.85 0.15 25); outline-offset: -2px; }
.batch-item__skip {
  font-size: 1.5rem; color: oklch(0.7 0 0);
}
.batch-item__check {
  font-size: 1rem; color: oklch(0.85 0.15 145);
}
.batch-item__cross {
  font-size: 1rem; color: oklch(0.85 0.15 25);
}
.batch-item__error {
  font-size: 0.625rem; color: white; text-align: center;
  padding: 0 0.25rem; word-break: break-word;
}
.batch-item--done .btn { font-size: 0.6875rem; padding: 0.25rem 0.5rem; }

/* 批量进度 + 操作 */
.batch-progress {
  display: flex; align-items: center; justify-content: center;
  gap: 0.5rem; padding: 0.75rem 0;
  color: var(--muted-foreground); font-size: 0.875rem;
}
.batch-actions {
  display: flex; justify-content: center;
  gap: 0.5rem; padding: 0.5rem 0;
}

/* --- 移动端断点 --- */
@media (max-width: 768px) {
  .translator-topbar { flex-direction: column; align-items: stretch; }
  .translator-topbar__arrow { text-align: center; }
  .translator-topbar__spacer { display: none; }
  .translator-topbar__actions { width: 100%; }
  .translator-topbar__actions .btn { flex: 1; }
  .translator-grid { grid-template-columns: 1fr; }
  .translator-panel + .translator-panel { border-left: none; border-top: 1px solid var(--border); }
  .translator-credits-bar { flex-direction: column; gap: 0.25rem; text-align: center; }
  .batch-grid { grid-template-columns: repeat(3, 1fr); }
}

/* --- Auth 页面 --- */
.auth-card {
  max-width: 24rem; margin: 3rem auto; padding: 2rem;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--card); color: var(--card-foreground);
}
.auth-title { text-align: center; margin-bottom: 1.5rem; font-size: 1.5rem; }
.auth-oauth-btn { width: 100%; margin-bottom: 1rem; text-align: center; }
.auth-divider {
  display: flex; align-items: center; gap: 1rem;
  margin: 1rem 0; color: var(--muted-foreground); font-size: 0.875rem;
}
.auth-divider::before, .auth-divider::after {
  content: ""; flex: 1; height: 1px; background: var(--border);
}
.auth-submit-btn { width: 100%; margin-top: 0.5rem; }
.auth-error {
  padding: 0.5rem 0.75rem; margin-bottom: 0.75rem;
  border-radius: var(--radius); font-size: 0.875rem;
  background: var(--destructive); color: var(--destructive-foreground);
}
.auth-link { text-align: center; margin-top: 1rem; font-size: 0.875rem; }
.auth-link a { color: var(--link); text-decoration: underline; }

/* ========================================
 * theme-toggle - 日/夜模式切换按钮
 * ======================================== */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
  background: transparent;
  border: 1px solid var(--ghost-border);
  border-radius: var(--radius);
  color: var(--muted-foreground);
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.theme-toggle:hover {
  color: var(--foreground);
  background: var(--accent);
  border-color: var(--border);
}
/* 夜航主态: 显示太阳 (切到白昼的指引), 隐藏月亮 */
.theme-toggle-moon { display: none; }
.theme-toggle-sun  { display: inline-flex; }
/* 白昼航班 (.light): 显示月亮 (切到夜航的指引), 隐藏太阳 */
.light .theme-toggle-moon { display: inline-flex; }
.light .theme-toggle-sun  { display: none; }
