/* ============================================
   COMPONENTS — 所有页面共享的 UI 组件
   全部引用 design-system.css 中的 HSL tokens
   ============================================ */

/* ---- 顶部装饰条 ---- */
.top-bar {
  height: 4px;
  background: linear-gradient(90deg, hsl(238.7 83.5% 66.7%), hsl(199 89% 48%), hsl(263 70% 50.4%), hsl(330 81% 60%));
  background-size: 300% 100%;
  animation: gradientFlow 8s ease infinite;
}

/* ---- 控件组 (Card) ---- */
.group {
  margin-bottom: 1.25rem;
  background: hsl(var(--card));
  padding: 1rem;
  border-radius: var(--radius);
  border: 1px solid hsl(var(--border));
  box-shadow: var(--shadow-sm);
  transition: border-color var(--transition);
}

.group:hover {
  border-color: hsl(var(--input));
}

.group-label {
  font-size: 0.6875rem;
  font-weight: 700;
  color: hsl(var(--muted-foreground));
  text-transform: uppercase;
  margin-bottom: 0.875rem;
  display: block;
  letter-spacing: 0.8px;
}

/* ---- 控件行 ---- */
.ctrl-row {
  margin-bottom: 0.875rem;
}

.ctrl-row:last-child {
  margin-bottom: 0;
}

.ctrl-row label {
  display: flex;
  justify-content: space-between;
  font-size: 0.8125rem;
  margin-bottom: 0.5rem;
  font-weight: 500;
  color: hsl(var(--muted-foreground));
}

.ctrl-row label span {
  color: hsl(var(--primary));
  font-family: 'SF Mono', 'Fira Code', ui-monospace, monospace;
  font-size: 0.75rem;
}

/* ---- 表单控件 ---- */
textarea, select, input[type="text"] {
  width: 100%;
  padding: 0.625rem 0.75rem;
  border: 1px solid hsl(var(--input));
  border-radius: calc(var(--radius) - 2px);
  font-size: 0.875rem;
  outline: none;
  background: hsl(var(--background));
  color: hsl(var(--foreground));
  transition: all var(--transition);
  font-family: inherit;
}

textarea:focus, select:focus, input[type="text"]:focus {
  border-color: hsl(var(--ring));
  box-shadow: 0 0 0 3px hsl(var(--ring) / 0.1);
}

/* ---- Range Slider ---- */
input[type="range"] {
  width: 100%;
  height: 4px;
  background: hsl(var(--border));
  border-radius: 9999px;
  -webkit-appearance: none;
  cursor: pointer;
  transition: background var(--transition);
}

input[type="range"]:hover {
  background: hsl(var(--input));
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  background: hsl(var(--primary));
  border-radius: 50%;
  border: 2.5px solid hsl(var(--background));
  box-shadow: 0 0 0 2px hsl(var(--ring) / 0.15);
  transition: box-shadow var(--transition);
  cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb:hover {
  box-shadow: 0 0 0 4px hsl(var(--ring) / 0.2);
}

/* ---- Buttons ---- */

/* Primary — 生成/主操作 */
.btn-gen {
  background: hsl(var(--foreground));
  color: hsl(var(--background));
  border: none;
  width: 100%;
  padding: 0.625rem 0.75rem;
  border-radius: calc(var(--radius) - 2px);
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  transition: all var(--transition);
  font-size: 0.875rem;
  font-family: inherit;
}

.btn-gen:hover {
  opacity: 0.88;
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.btn-gen:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* Secondary — 辅助操作 */
.btn-sub {
  background: hsl(var(--muted));
  color: hsl(var(--muted-foreground));
  border: 1px solid hsl(var(--border));
  width: 100%;
  padding: 0.5rem 0.625rem;
  border-radius: calc(var(--radius) - 2px);
  font-weight: 600;
  cursor: pointer;
  font-size: 0.75rem;
  margin-top: 0.5rem;
  transition: all var(--transition);
  font-family: inherit;
}

.btn-sub:hover {
  background: hsl(var(--border));
}

/* Danger */
.btn-danger {
  background: hsl(0 84.2% 60.2% / 0.08);
  color: hsl(0 84.2% 60.2%);
  border: 1px solid hsl(0 84.2% 60.2% / 0.2);
}

.btn-danger:hover {
  background: hsl(0 84.2% 60.2% / 0.15);
  border-color: hsl(0 84.2% 60.2% / 0.3);
}

/* ---- Loading ---- */
.loader {
  width: 2.5rem;
  height: 2.5rem;
  border: 3px solid hsl(var(--border));
  border-top: 3px solid hsl(var(--primary));
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

#loadingOverlay {
  position: absolute;
  inset: 0;
  background: hsl(var(--background) / 0.92);
  backdrop-filter: blur(4px);
  z-index: 100;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

/* ---- Export Button ---- */
.export-btn {
  margin-top: 1.875rem;
  background: hsl(var(--background));
  border: 1.5px solid hsl(var(--border));
  padding: 0.625rem 2rem;
  border-radius: 9999px;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--transition);
  font-size: 0.875rem;
  font-family: inherit;
  color: hsl(var(--foreground));
}

.export-btn:hover {
  background: hsl(var(--foreground));
  color: hsl(var(--background));
  border-color: hsl(var(--foreground));
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.export-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* ---- Badge / Pill ---- */
.badge {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  background: hsl(var(--primary) / 0.1);
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
  color: hsl(var(--primary));
  align-self: flex-start;
}

/* ---- Progress Bar ---- */
.progress-bar {
  width: 100%;
  height: 8px;
  background: hsl(var(--muted));
  border-radius: 9999px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, hsl(var(--primary)), hsl(263 70% 50.4%));
  border-radius: 9999px;
  transition: width 0.3s ease;
}

/* ---- Empty State ---- */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: hsl(var(--muted-foreground));
  padding: 3.75rem 1.25rem;
  text-align: center;
  border: 1px dashed hsl(var(--border));
  border-radius: var(--radius);
}

.empty-state i {
  font-size: 3rem;
  margin-bottom: 1rem;
  opacity: 0.2;
}

.empty-state p {
  margin-bottom: 0.25rem;
  font-size: 0.9rem;
}

.empty-state .hint {
  font-size: 0.8rem;
  opacity: 0.6;
}

/* ---- Preview Container ---- */
.preview-container {
  flex: 1;
  width: 100%;
  overflow-y: auto;
  padding: 0.625rem;
}

/* ---- Scrollbar ---- */
.scroll-area {
  scrollbar-width: thin;
  scrollbar-color: hsl(var(--border)) transparent;
}

.scroll-area::-webkit-scrollbar {
  width: 4px;
}

.scroll-area::-webkit-scrollbar-thumb {
  background: hsl(var(--border));
  border-radius: 9999px;
}

/* ---- Toast 通知 (配合 common.js) ---- */
.toast-error {
  position: fixed;
  top: 1.25rem;
  right: 1.25rem;
  background: hsl(var(--destructive));
  color: hsl(var(--destructive-foreground));
  padding: 0.875rem 1.375rem;
  border-radius: calc(var(--radius) - 2px);
  font-size: 0.875rem;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  z-index: 10000;
  animation: toastIn 0.3s ease-out;
  max-width: 90vw;
  word-break: break-word;
}

.toast-success {
  position: fixed;
  top: 1.25rem;
  right: 1.25rem;
  background: hsl(var(--success));
  color: #fff;
  padding: 0.875rem 1.375rem;
  border-radius: calc(var(--radius) - 2px);
  font-size: 0.875rem;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  z-index: 10000;
  animation: toastIn 0.3s ease-out;
  max-width: 90vw;
  word-break: break-word;
}

/* ---- Switch / Checkbox ---- */
.switch-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  font-size: 0.875rem;
  color: hsl(var(--muted-foreground));
}

.switch-item input[type="checkbox"] {
  accent-color: hsl(var(--primary));
  width: 1rem;
  height: 1rem;
}

/* ---- Error Box ---- */
.error-box {
  background: hsl(var(--destructive) / 0.1);
  border: 1px solid hsl(var(--destructive) / 0.2);
  color: hsl(var(--destructive));
  padding: 0.75rem 1rem;
  border-radius: calc(var(--radius) - 2px);
  font-size: 0.875rem;
  margin-top: 0.75rem;
}
