/* ============================================================
   components.css — 质感组件库（双主题）
   按钮 / 芯片选择 / 卡片 / 表单 / 分段控件 / 弹窗 / 进度等
   ============================================================ */

/* ================= 按钮 ================= */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  height: 40px; padding: 0 20px;
  font-size: var(--fs-body); font-weight: 600; line-height: 1;
  border: none; border-radius: var(--r-sm);
  cursor: pointer; user-select: none; white-space: nowrap;
  transition: transform var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) ease,
              background var(--dur-fast) ease, border-color var(--dur-fast) ease, opacity var(--dur-fast) ease;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn svg { width: 16px; height: 16px; flex: none; }

/* 主按钮：品牌渐变 + 辉光 */
.btn-primary {
  color: #fff;
  background: var(--brand-grad);
  box-shadow: 0 2px 12px rgba(99, 102, 241, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.22);
}
.btn-primary:hover { background: var(--brand-grad-hi); box-shadow: 0 4px 20px rgba(99, 102, 241, 0.5), inset 0 1px 0 rgba(255,255,255,0.25); transform: translateY(-1px); }

/* 次按钮：表面色 + 描边 */
.btn-secondary {
  color: var(--text-primary);
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-sm);
}
.btn-secondary:hover { border-color: var(--brand-500); color: var(--brand-500); transform: translateY(-1px); }

/* 幽灵按钮 */
.btn-ghost { color: var(--text-secondary); background: transparent; }
.btn-ghost:hover { color: var(--text-primary); background: var(--bg-hover); }

/* 危险按钮 */
.btn-danger { color: #fff; background: var(--error); box-shadow: 0 2px 10px var(--error-soft); }
.btn-danger:hover { filter: brightness(1.08); }

/* 尺寸 */
.btn-lg { height: 48px; padding: 0 28px; font-size: 15px; border-radius: 10px; }
.btn-sm { height: 32px; padding: 0 14px; font-size: var(--fs-sm); }
.btn-block { width: 100%; }

/* 渐变描边按钮（官网 CTA 用） */
.btn-outline-grad {
  color: var(--text-primary);
  background:
    linear-gradient(var(--bg-page), var(--bg-page)) padding-box,
    var(--brand-grad) border-box;
  border: 1.5px solid transparent;
}
.btn-outline-grad:hover { color: var(--brand-500); transform: translateY(-1px); box-shadow: var(--glow-brand); }

/* 图标按钮 */
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border: none; border-radius: var(--r-sm);
  color: var(--text-secondary); background: transparent; cursor: pointer;
  transition: background var(--dur-fast) ease, color var(--dur-fast) ease;
}
.icon-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.icon-btn svg { width: 18px; height: 18px; }

/* ================= 芯片选择（有质感的选项） ================= */
.chip {
  position: relative;
  display: inline-flex; align-items: center; gap: 6px;
  height: 34px; padding: 0 14px;
  font-size: var(--fs-sm); font-weight: 500;
  color: var(--text-secondary);
  background: var(--bg-inset);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  cursor: pointer; user-select: none; white-space: nowrap;
  transition: all var(--dur-fast) var(--ease-out);
}
.chip:hover { color: var(--text-primary); border-color: var(--border-strong); transform: translateY(-1px); }

/* 选中态：品牌渐变底 + 白字（保证对比度） */
.chip.is-active {
  color: #fff;
  background: var(--brand-grad);
  border-color: transparent;
  box-shadow: 0 2px 10px rgba(99, 102, 241, 0.28);
}
.chip.is-active::after {
  content: ""; position: absolute; top: -1px; right: -1px;
  width: 0; height: 0;
  border: 7px solid transparent; border-top-color: #fff; border-right-color: #fff;
  border-top-right-radius: 3px;
}
.chip .chip-check { display: none; }
.chip.is-active .chip-check { display: inline-flex; }
.chip svg { width: 14px; height: 14px; }

/* 大号可选卡（模型/分辨率选择） */
.option-card {
  position: relative;
  padding: var(--sp-4);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease-out);
}
.option-card:hover { border-color: var(--border-strong); transform: translateY(-2px); box-shadow: var(--shadow-sm); }
.option-card.is-active {
  border-color: transparent;
  background-image:
    linear-gradient(var(--bg-surface), var(--bg-surface)),
    var(--brand-grad);
  background-origin: border-box;
  background-clip: padding-box, border-box;
  box-shadow: var(--glow-brand);
}

/* ================= 卡片 ================= */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--ring-edge), var(--shadow-sm);
}
.card-elevated {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--ring-edge), var(--shadow-md);
}

/* ================= 表单 ================= */
.field { display: flex; flex-direction: column; gap: var(--sp-2); }
.field-label { font-size: var(--fs-sm); font-weight: 600; color: var(--text-secondary); }
.field-label .req { color: var(--error); margin-left: 2px; }

.input, .textarea, .select {
  width: 100%; height: 40px; padding: 0 12px;
}
.textarea { height: auto; min-height: 96px; padding: 10px 12px; resize: vertical; line-height: 1.6; }
.select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238B94A8' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
  cursor: pointer;
}

/* ================= 分段控件 ================= */
.segmented {
  display: inline-flex; gap: 2px; padding: 3px;
  background: var(--bg-inset);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.segmented button {
  height: 30px; padding: 0 16px;
  font-size: var(--fs-sm); font-weight: 550; color: var(--text-secondary);
  background: transparent; border: none; border-radius: 8px; cursor: pointer;
  transition: all var(--dur-fast) var(--ease-out);
}
.segmented button:hover { color: var(--text-primary); }
.segmented button.is-active {
  color: var(--text-primary);
  background: var(--bg-elevated);
  box-shadow: var(--shadow-sm), var(--ring-edge);
}

/* ================= 开关 ================= */
.switch {
  position: relative; flex: none;
  width: 40px; height: 22px;
  border: none; border-radius: var(--r-full);
  background: var(--bg-active);
  cursor: pointer;
  transition: background var(--dur-base) var(--ease-out);
}
.switch::after {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 18px; height: 18px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
  transition: transform var(--dur-base) var(--ease-spring);
}
.switch.is-on { background: var(--brand-500); }
.switch.is-on::after { transform: translateX(18px); }

/* ================= 徽章 ================= */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  height: 22px; padding: 0 8px;
  font-size: var(--fs-caption); font-weight: 600;
  border-radius: var(--r-full);
}
.badge-brand { color: var(--brand-500); background: var(--brand-soft); }
.badge-success { color: var(--success); background: var(--success-soft); }
.badge-warning { color: var(--warning); background: var(--warning-soft); }
.badge-error { color: var(--error); background: var(--error-soft); }
.badge-neutral { color: var(--text-secondary); background: var(--bg-active); }

/* ================= 弹窗 ================= */
.modal-mask {
  position: fixed; inset: 0; z-index: var(--z-modal);
  display: flex; align-items: center; justify-content: center; padding: var(--sp-5);
  background: rgba(5, 8, 14, 0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  opacity: 0; pointer-events: none;
  transition: opacity var(--dur-base) var(--ease-out);
}
.modal-mask.is-open { opacity: 1; pointer-events: auto; }
.modal {
  width: 100%; max-width: 440px; max-height: 90vh; overflow: auto;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  transform: translateY(16px) scale(0.98);
  transition: transform var(--dur-base) var(--ease-spring);
}
.modal-mask.is-open .modal { transform: none; }

/* ================= 进度条 ================= */
.progress { height: 6px; background: var(--bg-active); border-radius: var(--r-full); overflow: hidden; }
.progress > i {
  display: block; height: 100%; width: 0;
  background: var(--brand-grad);
  border-radius: inherit;
  transition: width var(--dur-base) var(--ease-out);
}

/* ================= 骨架屏 ================= */
.skeleton {
  background: linear-gradient(90deg, var(--bg-active) 25%, var(--bg-hover) 50%, var(--bg-active) 75%);
  background-size: 200% 100%;
  animation: sk 1.4s ease infinite;
  border-radius: var(--r-sm);
}
@keyframes sk { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* ================= 空状态 ================= */
.empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: var(--sp-3); padding: var(--sp-8) var(--sp-5);
  color: var(--text-tertiary); font-size: var(--fs-sm); text-align: center;
}
.empty svg { width: 44px; height: 44px; opacity: 0.5; }

/* ================= 提示气泡 ================= */
.popover {
  position: absolute; z-index: var(--z-pop);
  min-width: 200px; padding: var(--sp-3);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-lg);
  opacity: 0; pointer-events: none; transform: translateY(6px);
  transition: all var(--dur-fast) var(--ease-out);
}
.popover.is-open { opacity: 1; pointer-events: auto; transform: none; }

/* ================= 弹窗关闭钮 / 加载圈（兼容层） ================= */
.modal-close {
  display: flex; align-items: center; justify-content: center;
  width: 32px; height: 32px;
  border: none; border-radius: 50%;
  background: transparent; color: var(--text-secondary);
  font-size: 16px; cursor: pointer; line-height: 1;
  transition: all var(--dur-fast) ease;
}
.modal-close:hover { background: var(--bg-hover); color: var(--text-primary); }

.spinner {
  display: inline-block; flex: none;
  width: 16px; height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ================= 全局轻提示（toast.js 渲染到 #app-toast） ================= */
.toast-wrap { position: fixed; top: 24px; right: 24px; z-index: var(--z-toast); display: flex; flex-direction: column; gap: 10px; }
.toast {
  min-width: 240px; max-width: 360px; padding: 12px 16px;
  border-radius: var(--r-md); font-size: var(--fs-sm);
  background: var(--bg-elevated); border: 1px solid var(--border-strong);
  color: var(--text-primary); line-height: 1.6; font-weight: 500;
  box-shadow: var(--shadow-lg);
  display: flex; align-items: center; gap: 10px;
  animation: toast-in 0.25s var(--ease-out);
}
.toast::before { content: ''; width: 8px; height: 8px; border-radius: 50%; flex: none; }
.toast.success::before { background: var(--success); }
.toast.error::before { background: var(--error); }
.toast.info::before { background: var(--accent-cyan); }
@keyframes toast-in { from { opacity: 0; transform: translateX(20px); } }
