/* ============================================
   COMPONENTS — Buttons, Cards, Forms, Badges
   ============================================ */

/* -------- BUTTONS -------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 10px var(--space-5);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: 600;
  letter-spacing: 0.01em;
  transition: var(--transition-base);
  cursor: pointer;
  white-space: nowrap;
  position: relative;
  overflow: hidden;
  user-select: none;
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

/* Primary gradient button */
.btn-primary {
  background: var(--gradient-primary);
  color: white;
  box-shadow: 0 4px 20px rgba(124,58,237,0.3);
}
.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 28px rgba(124,58,237,0.45);
}
.btn-primary:active { transform: translateY(0); }

/* Outline button */
.btn-outline {
  background: transparent;
  color: var(--text-primary);
  border: 1px solid var(--border-accent);
}
.btn-outline:hover {
  background: rgba(124,58,237,0.08);
  border-color: var(--accent-violet);
}

/* Ghost button */
.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}
.btn-ghost:hover {
  background: rgba(255,255,255,0.05);
  color: var(--text-primary);
}

/* Surface button */
.btn-surface {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border: 1px solid var(--border);
}
.btn-surface:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-accent);
}

/* Danger button */
.btn-danger {
  background: rgba(239,68,68,0.1);
  color: var(--error);
  border: 1px solid rgba(239,68,68,0.2);
}
.btn-danger:hover {
  background: rgba(239,68,68,0.2);
}

/* Sizes */
.btn-sm { padding: 7px 14px; font-size: var(--text-xs); border-radius: var(--radius-sm); }
.btn-lg { padding: 14px 32px; font-size: var(--text-base); border-radius: var(--radius-lg); }
.btn-xl { padding: 18px 40px; font-size: var(--text-lg); border-radius: var(--radius-xl); }
.btn-icon { padding: 10px; width: 40px; height: 40px; }
.btn-icon-sm { padding: 6px; width: 30px; height: 30px; }

/* Generate button - special animated */
.btn-generate {
  background: linear-gradient(135deg, #7C3AED, #EC4899, #F97316);
  background-size: 200% 200%;
  animation: gradientShift 3s ease infinite;
  color: white;
  font-size: var(--text-base);
  font-weight: 700;
  padding: 16px 40px;
  border-radius: var(--radius-xl);
  box-shadow: 0 6px 30px rgba(124,58,237,0.4);
  letter-spacing: 0.02em;
  width: 100%;
}
.btn-generate:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 40px rgba(124,58,237,0.55);
}
.btn-generate:active { transform: translateY(0); }

/* Loading state */
.btn-loading {
  pointer-events: none;
  opacity: 0.85;
}
.btn-loading .btn-text { opacity: 0; }
.btn-loading::before {
  content: '';
  position: absolute;
  width: 18px; height: 18px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}


/* -------- CARDS -------- */

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  transition: var(--transition-base);
}

.card-hover:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-accent);
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.card-glass {
  background: rgba(20,20,32,0.7);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

.card-gradient {
  background: var(--gradient-card);
  border: 1px solid var(--border-accent);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
}

.card-glow {
  box-shadow: 0 0 0 1px var(--border-accent), var(--shadow-accent);
}


/* -------- BADGES -------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.04em;
}

.badge-violet { background: rgba(124,58,237,0.15); color: var(--accent-violet-light); border: 1px solid rgba(124,58,237,0.25); }
.badge-pink   { background: rgba(236,72,153,0.12); color: var(--accent-pink); border: 1px solid rgba(236,72,153,0.2); }
.badge-orange { background: rgba(249,115,22,0.12); color: var(--accent-orange); border: 1px solid rgba(249,115,22,0.2); }
.badge-teal   { background: rgba(20,184,166,0.12); color: var(--accent-teal); border: 1px solid rgba(20,184,166,0.2); }
.badge-blue   { background: rgba(59,130,246,0.12); color: var(--accent-blue); border: 1px solid rgba(59,130,246,0.2); }
.badge-success{ background: rgba(34,197,94,0.12); color: var(--success); border: 1px solid rgba(34,197,94,0.2); }
.badge-warning{ background: rgba(245,158,11,0.12); color: var(--warning); border: 1px solid rgba(245,158,11,0.2); }
.badge-error  { background: rgba(239,68,68,0.12); color: var(--error); border: 1px solid rgba(239,68,68,0.2); }
.badge-new {
  background: var(--gradient-primary);
  color: white;
  animation: pulseSoft 2s ease-in-out infinite;
}


/* -------- FORM ELEMENTS -------- */

.form-group { display: flex; flex-direction: column; gap: var(--space-2); }
.form-label {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-secondary);
}

.form-input {
  width: 100%;
  padding: 11px var(--space-4);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: var(--text-sm);
  transition: var(--transition-base);
}
.form-input::placeholder { color: var(--text-muted); }
.form-input:focus {
  border-color: var(--border-accent-bright);
  background: var(--bg-card);
  box-shadow: 0 0 0 3px rgba(124,58,237,0.1);
}

.form-textarea {
  resize: vertical;
  min-height: 100px;
}

.form-select {
  width: 100%;
  padding: 11px var(--space-4);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: var(--text-sm);
  cursor: pointer;
  transition: var(--transition-base);
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2364748B'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 16px;
  padding-right: 40px;
}
.form-select:focus {
  border-color: var(--border-accent-bright);
  box-shadow: 0 0 0 3px rgba(124,58,237,0.1);
  outline: none;
}
.form-select option { background: var(--bg-elevated); }


/* -------- TOGGLE SWITCH -------- */

.toggle-wrapper {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}

.toggle {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  transition: 0.3s ease;
}
.toggle-slider::before {
  content: '';
  position: absolute;
  height: 18px; width: 18px;
  left: 2px; top: 2px;
  background: var(--text-muted);
  border-radius: 50%;
  transition: 0.3s ease;
}
.toggle input:checked + .toggle-slider {
  background: rgba(124,58,237,0.3);
  border-color: var(--accent-violet);
}
.toggle input:checked + .toggle-slider::before {
  transform: translateX(20px);
  background: var(--accent-violet-light);
}


/* -------- RADIO OPTION CARDS -------- */

.option-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: var(--space-3); }

.option-card {
  padding: var(--space-3);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  text-align: center;
  transition: var(--transition-base);
  user-select: none;
}
.option-card:hover {
  border-color: var(--border-accent);
  background: var(--bg-card-hover);
}
.option-card.selected {
  border-color: var(--accent-violet);
  background: rgba(124,58,237,0.1);
  box-shadow: 0 0 0 1px rgba(124,58,237,0.3);
}
.option-card .option-icon {
  font-size: 1.5rem;
  margin-bottom: 6px;
}
.option-card .option-label {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--text-secondary);
}
.option-card.selected .option-label { color: var(--accent-violet-light); }


/* -------- IMAGE UPLOAD ZONE -------- */

.upload-zone {
  border: 2px dashed var(--border-accent);
  border-radius: var(--radius-xl);
  padding: var(--space-3) var(--space-4);
  text-align: center;
  cursor: pointer;
  transition: var(--transition-base);
  background: rgba(124,58,237,0.02);
  position: relative;
  overflow: hidden;
}
.upload-zone:hover,
.upload-zone.drag-over {
  border-color: var(--accent-violet);
  background: rgba(124,58,237,0.06);
  transform: scale(1.005);
}
.upload-zone input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}
.upload-zone .upload-icon {
  font-size: 1.4rem;
  margin-bottom: var(--space-1);
  animation: float 3s ease-in-out infinite;
}
.upload-zone .upload-title {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 2px;
}
.upload-zone .upload-sub {
  font-size: var(--text-xs);
  color: var(--text-muted);
}
.upload-zone.has-image {
  border-style: solid;
  border-color: var(--accent-violet);
  padding: 0;
}
.upload-zone.has-image img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  max-height: 180px;
  border-radius: calc(var(--radius-xl) - 2px);
}


/* -------- PROGRESS BAR -------- */

.progress-wrapper { width: 100%; }
.progress-bar-container {
  height: 4px;
  background: var(--bg-elevated);
  border-radius: var(--radius-full);
  overflow: hidden;
}
.progress-bar-fill {
  height: 100%;
  background: var(--gradient-primary);
  border-radius: var(--radius-full);
  transition: width 0.3s ease;
  position: relative;
  overflow: hidden;
}
.progress-bar-fill::after {
  content: '';
  position: absolute;
  top: 0; left: -100%;
  width: 60%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.4), transparent);
  animation: shimmer 1.2s infinite;
}

/* Thick progress (generation) */
.progress-bar-container.thick { height: 8px; }
.progress-label {
  display: flex;
  justify-content: space-between;
  margin-bottom: var(--space-2);
  font-size: var(--text-sm);
}


/* -------- DIVIDER -------- */

.divider {
  height: 1px;
  background: var(--border);
  margin: var(--space-2) 0;
}
.divider-label {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  color: var(--text-muted);
  font-size: var(--text-xs);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin: var(--space-6) 0;
}
.divider-label::before,
.divider-label::after { content: ''; flex: 1; height: 1px; background: var(--border); }


/* -------- OUTPUT CARD -------- */

.output-card {
  position: relative;
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--bg-card);
  border: 1px solid var(--border);
  transition: var(--transition-base);
  cursor: pointer;
  aspect-ratio: 1;
}
.output-card:hover { border-color: var(--accent-violet); transform: scale(1.02); }
.output-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.4s ease;
}
.output-card:hover img { transform: scale(1.04); }
.output-card-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(0,0,0,0.8), transparent);
  opacity: 0;
  transition: var(--transition-base);
  display: flex;
  align-items: flex-end;
  padding: var(--space-4);
  gap: var(--space-2);
}
.output-card:hover .output-card-overlay { opacity: 1; }


/* -------- FORMAT SELECTOR CARDS (ps-fmt-card) -------- */

.ps-fmt-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 6px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  background: var(--bg-surface);
  transition: var(--transition-base);
  text-align: center;
  user-select: none;
}
.ps-fmt-card:hover {
  border-color: var(--accent-violet);
  background: rgba(124,58,237,0.04);
}
.ps-fmt-card.selected {
  border-color: var(--accent-violet);
  background: rgba(124,58,237,0.1);
  box-shadow: 0 0 0 1px rgba(124,58,237,0.25);
}
.ps-fmt-label {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-primary);
}
.ps-fmt-sub {
  font-size: 0.65rem;
  color: var(--text-muted);
}
.ps-fmt-card.selected .ps-fmt-label { color: var(--accent-violet-light); }


/* -------- STAT CARD -------- */

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  display: flex;
  align-items: center;
  gap: var(--space-4);
  transition: var(--transition-base);
}
.stat-card:hover { border-color: var(--border-accent); }
.stat-icon {
  width: 48px; height: 48px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  flex-shrink: 0;
}
.stat-number {
  font-size: var(--text-2xl);
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1;
}
.stat-label {
  font-size: var(--text-sm);
  color: var(--text-muted);
  margin-top: 3px;
}
.stat-change {
  font-size: var(--text-xs);
  font-weight: 600;
  margin-top: 4px;
}
.stat-change.up { color: var(--success); }
.stat-change.down { color: var(--error); }


/* -------- TOOLTIP -------- */

[data-tooltip] {
  position: relative;
}
[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-primary);
  font-size: var(--text-xs);
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease;
  z-index: var(--z-dropdown);
}
[data-tooltip]:hover::after { opacity: 1; }


/* -------- NOTIFICATION TOAST -------- */

#toast-container {
  position: fixed;
  bottom: var(--space-6);
  right: var(--space-6);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  z-index: var(--z-toast);
}

.toast {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-5);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  min-width: 280px;
  animation: slideInBottom 0.3s ease both;
  cursor: pointer;
}
.toast-icon { font-size: 1.2rem; }
.toast-body { flex: 1; }
.toast-title { font-size: var(--text-sm); font-weight: 600; color: var(--text-primary); }
.toast-msg { font-size: var(--text-xs); color: var(--text-secondary); }
.toast.success { border-color: rgba(34,197,94,0.3); }
.toast.error   { border-color: rgba(239,68,68,0.3); }
.toast.info    { border-color: var(--border-accent); }


/* -------- SLIDER -------- */

input[type="range"] {
  -webkit-appearance: none;
  width: 100%;
  height: 4px;
  background: var(--bg-elevated);
  border-radius: var(--radius-full);
  outline: none;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--gradient-primary);
  box-shadow: 0 2px 8px rgba(124,58,237,0.4);
  cursor: pointer;
  transition: transform 0.2s ease;
}
input[type="range"]::-webkit-slider-thumb:hover { transform: scale(1.2); }

/* -------- STEP INDICATOR -------- */

.step-indicator {
  display: flex;
  align-items: center;
  gap: 0;
  margin-bottom: var(--space-6);
}
.step {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  position: relative;
}
.step::after {
  content: '';
  position: absolute;
  top: 16px;
  left: 50%;
  width: 100%;
  height: 2px;
  background: var(--border);
}
.step:last-child::after { display: none; }
.step.active::after { background: var(--gradient-primary); }
.step-dot {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--bg-elevated);
  border: 2px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--text-muted);
  z-index: 1;
  transition: var(--transition-base);
}
.step.active .step-dot {
  background: var(--gradient-primary);
  border-color: transparent;
  color: white;
  box-shadow: var(--shadow-glow);
}
.step.done .step-dot {
  background: rgba(34,197,94,0.2);
  border-color: var(--success);
  color: var(--success);
}
.step-label {
  font-size: 10px;
  font-weight: 500;
  color: var(--text-muted);
  margin-top: var(--space-2);
  text-align: center;
}
.step.active .step-label { color: var(--accent-violet-light); }

/* -------- GENERATION STATUS -------- */

.gen-status {
  padding: var(--space-5);
  background: var(--bg-card);
  border: 1px solid var(--border-accent);
  border-radius: var(--radius-lg);
  text-align: center;
}
.gen-spinner {
  width: 56px; height: 56px;
  margin: 0 auto var(--space-4);
  position: relative;
}
.gen-spinner::before,
.gen-spinner::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 3px solid transparent;
}
.gen-spinner::before {
  border-top-color: var(--accent-violet);
  animation: spin 1s linear infinite;
}
.gen-spinner::after {
  border-bottom-color: var(--accent-pink);
  animation: spinReverse 1.5s linear infinite;
}
.gen-step-label {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: var(--space-4);
}

/* Color pickers */
.color-picker-group {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
}
.color-swatch {
  width: 32px; height: 32px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  border: 2px solid transparent;
  transition: var(--transition-base);
}
.color-swatch.selected { border-color: white; transform: scale(1.15); }
