/* ============================================
   Components
   Buttons, cards, inputs, sliders, etc.
   ============================================ */

/* ========== BUTTONS ========== */

.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  background: var(--gradient-primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-lg);
  padding: 12px var(--space-lg);
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  box-shadow: var(--shadow-glow-pink);
  transition: transform var(--transition-fast), box-shadow var(--transition-normal);
  position: relative;
  overflow: hidden;
}

.btn-primary::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.2), transparent);
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.btn-primary:hover {
  transform: scale(1.02);
  box-shadow: 0 6px 28px rgba(255, 143, 171, 0.4);
}

.btn-primary:hover::before {
  opacity: 1;
}

.btn-primary:active {
  transform: scale(0.98);
}

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

.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  background: var(--color-bg-card);
  color: var(--color-text-primary);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 10px var(--space-lg);
  font-weight: 500;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-secondary:hover {
  border-color: var(--color-candy-lavender);
  background: #faf5ff;
  color: var(--color-candy-lavender);
}

.btn-secondary:active {
  transform: scale(0.98);
}

.btn-secondary:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-text {
  background: none;
  border: none;
  color: var(--color-candy-lavender);
  font-weight: 500;
  font-size: 0.85rem;
  cursor: pointer;
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--radius-sm);
  transition: color var(--transition-fast), background var(--transition-fast);
}

.btn-text:hover {
  color: var(--color-candy-pink);
  background: rgba(255, 143, 171, 0.06);
}

.btn-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--color-text-secondary);
  transition: background var(--transition-fast), color var(--transition-fast);
  flex-shrink: 0;
}

.btn-icon:hover {
  background: var(--color-border-light);
  color: var(--color-candy-pink);
}

.btn-icon svg {
  width: 20px;
  height: 20px;
}

.btn-sm {
  padding: 6px 14px;
  font-size: 0.82rem;
  border-radius: var(--radius-md);
}

.btn-full {
  width: 100%;
}

/* ========== CARDS ========== */

.card {
  background: var(--color-bg-card);
  border-radius: var(--radius-xl);
  padding: var(--space-xl);
  border: 1px solid var(--color-border-light);
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition-normal);
}

.card:hover {
  box-shadow: var(--shadow-md);
}

.card-title {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--color-text-primary);
  margin-bottom: var(--space-md);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-md);
}

.card-header .card-title {
  margin-bottom: 0;
}

.card-actions {
  display: flex;
  gap: var(--space-sm);
}

/* ========== TEXTAREA ========== */

.prompt-textarea {
  width: 100%;
  min-height: 160px;
  resize: vertical;
  background: var(--color-bg-input);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-md);
  font-size: 0.95rem;
  line-height: 1.75;
  color: var(--color-text-primary);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  margin-bottom: var(--space-md);
}

.prompt-textarea:focus {
  outline: none;
  border-color: var(--color-candy-lavender);
  box-shadow: 0 0 0 3px rgba(195, 166, 255, 0.15);
}

.prompt-textarea::placeholder {
  color: var(--color-text-tertiary);
}

/* ========== FORM ========== */

.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.form-group label {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--color-text-secondary);
}

.form-group input[type='text'],
.form-group input[type='password'],
.form-group input[type='url'] {
  padding: 10px var(--space-md);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  background: var(--color-bg-card);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.form-group input:focus {
  outline: none;
  border-color: var(--color-candy-lavender);
  box-shadow: 0 0 0 3px rgba(195, 166, 255, 0.15);
}

.input-with-toggle {
  position: relative;
}

.input-with-toggle input {
  width: 100%;
  padding-right: 44px;
}

.input-with-toggle .btn-icon {
  position: absolute;
  right: 2px;
  top: 50%;
  transform: translateY(-50%);
  width: 36px;
  height: 36px;
}

/* ========== API MODE SWITCH ========== */

.api-mode-group {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-sm);
}

.api-mode-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 10px;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: border-color var(--transition-fast), background var(--transition-fast);
}

.api-mode-option input {
  margin: 0;
  accent-color: var(--color-candy-pink);
}

.api-mode-option input:checked + span {
  color: var(--color-candy-pink);
  font-weight: 600;
}

.api-mode-option:has(input:checked) {
  border-color: var(--color-candy-pink);
  background: linear-gradient(135deg, rgba(255,143,171,0.08), rgba(195,166,255,0.08));
}

.settings-mode-section {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

/* ========== SCENE CONFIRM DIALOG ========== */

.scene-confirm-overlay {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-lg);
  z-index: 980;
}

.scene-confirm-dialog {
  width: min(520px, 100%);
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  padding: var(--space-lg);
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.scene-confirm-dialog h3 {
  margin: 0;
  font-size: 1.05rem;
  color: var(--color-text-primary);
}

.scene-confirm-desc,
.scene-confirm-summary,
.scene-confirm-reason {
  margin: 0;
  font-size: 0.86rem;
  line-height: 1.6;
  color: var(--color-text-secondary);
}

.scene-confirm-summary {
  color: var(--color-text-primary);
  font-weight: 600;
}

.scene-confirm-actions {
  margin-top: var(--space-sm);
  display: flex;
  justify-content: flex-end;
  gap: var(--space-sm);
}

/* ========== SLIDERS ========== */

.slider-item {
  padding: var(--space-md) 0;
  border-bottom: 1px solid var(--color-border-light);
}

.slider-item:last-child {
  border-bottom: none;
}

.slider-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.slider-label {
  font-weight: 500;
  font-size: 0.9rem;
  color: var(--color-text-primary);
}

.slider-desc {
  font-size: 0.75rem;
  color: var(--color-text-tertiary);
  margin-bottom: 6px;
}

.slider-value {
  font-weight: 700;
  font-size: 0.9rem;
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  min-width: 28px;
  text-align: right;
}

.slider-labels {
  display: flex;
  justify-content: space-between;
  margin-top: 4px;
}

.slider-label-min,
.slider-label-max {
  font-size: 0.72rem;
  color: var(--color-text-tertiary);
}

/* Custom range input */
.slider-range {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: var(--radius-full);
  outline: none;
  cursor: pointer;
  background: var(--color-border);
  transition: background var(--transition-fast);
}

.slider-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--gradient-primary);
  box-shadow: var(--shadow-glow-pink);
  cursor: grab;
  border: 2.5px solid #fff;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.slider-range::-webkit-slider-thumb:hover {
  transform: scale(1.2);
  box-shadow: 0 4px 24px rgba(255, 143, 171, 0.45);
}

.slider-range::-webkit-slider-thumb:active {
  cursor: grabbing;
  transform: scale(1.1);
}

/* Firefox */
.slider-range::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--gradient-primary);
  box-shadow: var(--shadow-glow-pink);
  cursor: grab;
  border: 2.5px solid #fff;
  transition: transform var(--transition-fast);
}

.slider-range::-moz-range-thumb:hover {
  transform: scale(1.2);
}

.slider-range::-moz-range-track {
  height: 6px;
  border-radius: var(--radius-full);
  background: transparent;
}

/* ========== RADAR ========== */

.radar-wrapper {
  width: 100%;
  max-width: 380px;
  margin: 0 auto;
  padding: var(--space-sm);
}

.radar-wrapper canvas {
  width: 100% !important;
  height: auto !important;
}

/* ========== RESULT CONTENT ========== */

.result-content {
  padding: var(--space-lg);
  background: var(--color-bg-input);
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-border-light);
  min-height: 120px;
  font-size: 0.93rem;
  line-height: 1.85;
  color: var(--color-text-primary);
  word-break: break-word;
}

.result-content p {
  margin-bottom: var(--space-sm);
}

.result-content p:last-child {
  margin-bottom: 0;
}

.result-content strong {
  color: var(--color-candy-pink);
  font-weight: 600;
}

.result-content code {
  background: var(--color-border-light);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 0.85em;
}

.result-content em {
  color: var(--color-candy-lavender);
  font-style: italic;
}

/* ========== LOADING ========== */

.loading-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: var(--space-3xl) var(--space-xl);
  gap: var(--space-lg);
}

.loading-dots {
  display: flex;
  gap: 8px;
}

.loading-dots span {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  animation: loadingBounce 1.4s ease-in-out infinite;
}

.loading-dots span:nth-child(1) {
  background: var(--color-candy-pink);
}

.loading-dots span:nth-child(2) {
  background: var(--color-candy-lavender);
  animation-delay: 0.2s;
}

.loading-dots span:nth-child(3) {
  background: var(--color-candy-mint);
  animation-delay: 0.4s;
}

.loading-text {
  font-size: 0.88rem;
  color: var(--color-text-secondary);
}

/* ========== TOAST ========== */

#toast-container {
  position: fixed;
  top: var(--space-lg);
  right: var(--space-lg);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  pointer-events: none;
}

.toast {
  padding: 10px var(--space-lg);
  border-radius: var(--radius-lg);
  font-size: 0.88rem;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  animation: toastIn var(--transition-normal) ease,
             toastOut var(--transition-normal) ease 2.7s forwards;
  pointer-events: auto;
  max-width: 360px;
}

.toast-info {
  background: rgba(137, 207, 243, 0.92);
  color: #1a4a6b;
}

.toast-success {
  background: rgba(125, 223, 195, 0.92);
  color: #1a5c4a;
}

.toast-error {
  background: rgba(255, 107, 138, 0.92);
  color: #5c1a2a;
}

/* ========== HISTORY ITEMS ========== */

.history-item {
  padding: var(--space-md);
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border-light);
  cursor: pointer;
  transition: all var(--transition-fast);
  margin-bottom: var(--space-sm);
  position: relative;
}

.history-item:hover {
  background: #faf5ff;
  border-color: var(--color-candy-lavender);
}

.history-prompt {
  font-size: 0.85rem;
  color: var(--color-text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-bottom: var(--space-xs);
  padding-right: var(--space-xl);
}

.history-date {
  font-size: 0.72rem;
  color: var(--color-text-tertiary);
}

.history-delete {
  position: absolute;
  top: var(--space-sm);
  right: var(--space-sm);
  background: none;
  border: none;
  color: var(--color-text-tertiary);
  cursor: pointer;
  font-size: 0.78rem;
  opacity: 0;
  transition: opacity var(--transition-fast), color var(--transition-fast);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
}

.history-item:hover .history-delete {
  opacity: 1;
}

.history-delete:hover {
  color: var(--color-error);
  background: rgba(255, 107, 138, 0.08);
}

/* ========== EMPTY STATE ========== */

.empty-state {
  text-align: center;
  padding: var(--space-3xl) var(--space-lg);
  color: var(--color-text-tertiary);
  font-size: 0.88rem;
}

/* ========== UTILITY ========== */

.hidden {
  display: none !important;
}

.text-gradient {
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* Candy stripe decorative bar */
.candy-stripe-bar {
  height: 3px;
  border-radius: var(--radius-full);
  background: repeating-linear-gradient(
    90deg,
    var(--color-candy-pink) 0px,
    var(--color-candy-pink) 8px,
    var(--color-candy-lavender) 8px,
    var(--color-candy-lavender) 16px,
    var(--color-candy-mint) 16px,
    var(--color-candy-mint) 24px,
    var(--color-candy-peach) 24px,
    var(--color-candy-peach) 32px
  );
  opacity: 0.5;
  margin: var(--space-md) 0;
}

/* ========== PRESET CARDS ========== */

.presets-row {
  display: flex;
  gap: var(--space-sm);
  overflow-x: auto;
  padding-bottom: var(--space-xs);
  scrollbar-width: thin;
  scrollbar-color: var(--color-border) transparent;
}

.presets-row::-webkit-scrollbar {
  height: 4px;
}

.presets-row::-webkit-scrollbar-thumb {
  background: var(--color-border);
  border-radius: var(--radius-full);
}

.preset-card {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 14px;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-bg-card);
  cursor: pointer;
  transition: all var(--transition-fast);
  text-align: left;
  min-width: 0;
}

.preset-card:hover {
  border-color: var(--color-candy-lavender);
  background: #faf5ff;
}

.preset-card.active {
  border-color: var(--color-candy-pink);
  background: linear-gradient(135deg, rgba(255,143,171,0.08), rgba(195,166,255,0.08));
  box-shadow: 0 2px 12px rgba(255,143,171,0.12);
}

.preset-card-name {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--color-text-primary);
  white-space: nowrap;
}

.preset-card-desc {
  font-size: 0.68rem;
  color: var(--color-text-tertiary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 140px;
}

/* ========== COMPOSITION SELECTOR ========== */

.comp-selector {
  display: flex;
  gap: var(--space-xs);
}

.comp-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 8px 14px;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-bg-card);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.comp-option:hover {
  border-color: var(--color-candy-lavender);
}

.comp-option.active {
  border-color: var(--color-candy-pink);
  background: linear-gradient(135deg, rgba(255,143,171,0.08), rgba(195,166,255,0.08));
  box-shadow: 0 2px 10px rgba(255,143,171,0.12);
}

.comp-option .comp-icon {
  color: var(--color-text-secondary);
  transition: color var(--transition-fast);
}

.comp-option.active .comp-icon {
  color: var(--color-candy-pink);
}

.comp-label {
  font-size: 0.68rem;
  font-weight: 500;
  color: var(--color-text-tertiary);
}

.comp-option.active .comp-label {
  color: var(--color-candy-pink);
}

/* ========== STYLE SLIDER (Anime ↔ Realistic, 10 steps) ========== */

.style-slider-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
}

.style-slider-label {
  font-size: 0.68rem;
  font-weight: 500;
  color: var(--color-text-tertiary);
  white-space: nowrap;
  user-select: none;
}

.style-slider-label-left {
  color: var(--color-candy-pink);
}

.style-slider-label-right {
  color: var(--color-candy-sky);
}

.style-slider-track-wrap {
  position: relative;
  width: 120px;
  flex-shrink: 0;
}

.style-slider-input {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 5px;
  border-radius: var(--radius-full);
  outline: none;
  cursor: pointer;
  background: var(--color-border);
}

.style-slider-input::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--gradient-primary);
  box-shadow: var(--shadow-glow-pink);
  cursor: grab;
  border: 2px solid #fff;
  transition: transform var(--transition-fast);
}

.style-slider-input::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

.style-slider-input::-webkit-slider-thumb:active {
  cursor: grabbing;
  transform: scale(1.1);
}

.style-slider-input::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--gradient-primary);
  box-shadow: var(--shadow-glow-pink);
  border: 2px solid #fff;
  cursor: grab;
}

.style-slider-ticks {
  display: flex;
  justify-content: space-between;
  padding: 0 2px;
  margin-top: 2px;
}

.style-slider-tick {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--color-border);
  transition: background var(--transition-fast), transform var(--transition-fast);
}

.style-slider-tick.active {
  background: var(--color-candy-pink);
  transform: scale(1.5);
}

.style-slider-value {
  font-size: 0.72rem;
  font-weight: 700;
  min-width: 16px;
  text-align: center;
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* ========== GUIDE CARDS ========== */

.guide-cards {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  transition: opacity var(--transition-slow), max-height var(--transition-slow);
  overflow: hidden;
}

.guide-cards.hiding {
  opacity: 0;
  max-height: 0 !important;
  margin: 0;
  padding: 0;
}

.guide-card {
  background: var(--color-bg-card);
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-lg);
  padding: var(--space-md);
  box-shadow: var(--shadow-sm);
}

.guide-card-title {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--color-text-primary);
  margin-bottom: var(--space-sm);
  padding-bottom: var(--space-xs);
  border-bottom: 1px solid var(--color-border-light);
}

/* Style spectrum table */
.guide-table {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.guide-row {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: 3px 0;
}

.guide-level {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  padding: 1px 6px;
  border-radius: var(--radius-full);
  background: var(--gradient-primary);
  color: #fff;
  font-size: 0.62rem;
  font-weight: 700;
  flex-shrink: 0;
}

.guide-desc {
  font-size: 0.72rem;
  color: var(--color-text-secondary);
  line-height: 1.4;
}

/* Operation steps */
.guide-steps {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.guide-step {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-size: 0.72rem;
  color: var(--color-text-secondary);
  line-height: 1.4;
}

.guide-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--gradient-secondary);
  color: #fff;
  font-size: 0.6rem;
  font-weight: 700;
  flex-shrink: 0;
}
