/* ─── Variables ───────────────────────────────────────────────────────────── */
:root {
  --bg: #0d0e1a;
  --bg-card: rgba(255 255 255 / 0.04);
  --bg-card-hover: rgba(255 255 255 / 0.07);
  --border: rgba(255 255 255 / 0.1);
  --border-focus: rgba(139 92 246 / 0.7);

  --accent-1: #8b5cf6;   /* violet */
  --accent-2: #6366f1;   /* indigo */
  --accent-3: #a78bfa;   /* violet clair */
  --accent-grad: linear-gradient(135deg, var(--accent-1), var(--accent-2));

  --text-primary: #f1f0ff;
  --text-secondary: rgba(241 240 255 / 0.55);
  --text-tertiary: rgba(241 240 255 / 0.35);

  --success: #34d399;
  --error: #f87171;
  --warning: #fbbf24;

  --radius-sm: 8px;
  --radius-md: 16px;
  --radius-lg: 24px;

  --shadow-glow: 0 0 40px rgba(139 92 246 / 0.25);
  --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ─── Reset & Base ────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', system-ui, sans-serif;
  background-color: var(--bg);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  line-height: 1.6;
}

/* ─── Orbes flottantes ────────────────────────────────────────────────────── */
.bg-orbs {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}
.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(120px);
  opacity: 0.28;
  animation: drift 14s ease-in-out infinite alternate;
}
.orb-1 {
  width: 480px; height: 480px;
  background: radial-gradient(circle, #8b5cf6, transparent 70%);
  top: -120px; left: -80px;
  animation-delay: 0s;
}
.orb-2 {
  width: 560px; height: 560px;
  background: radial-gradient(circle, #6366f1, transparent 70%);
  bottom: -160px; right: -100px;
  animation-delay: -5s;
}
.orb-3 {
  width: 320px; height: 320px;
  background: radial-gradient(circle, #a78bfa, transparent 70%);
  top: 40%; left: 55%;
  animation-delay: -9s;
}
@keyframes drift {
  from { transform: translate(0, 0) scale(1); }
  to   { transform: translate(30px, 40px) scale(1.08); }
}

/* ─── Layout ──────────────────────────────────────────────────────────────── */
.container {
  position: relative;
  z-index: 1;
  max-width: 720px;
  margin: 0 auto;
  padding: 48px 20px 80px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* ─── Header ──────────────────────────────────────────────────────────────── */
.header {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding-bottom: 8px;
}
.logo {
  font-size: clamp(2.4rem, 6vw, 3.6rem);
  font-weight: 700;
  letter-spacing: -1.5px;
  line-height: 1;
}
.logo-px {
  background: var(--accent-grad);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.logo-at { color: var(--text-primary); }

.tagline {
  font-size: 0.95rem;
  color: var(--text-secondary);
  max-width: 40ch;
}

/* Health badge */
.health-badge {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--text-tertiary);
  transition: background var(--transition), box-shadow var(--transition);
  margin-top: 4px;
  cursor: default;
}
.health-badge.ok {
  background: var(--success);
  box-shadow: 0 0 8px var(--success);
}
.health-badge.error { background: var(--error); }

/* ─── Card ────────────────────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  transition: border-color var(--transition), background var(--transition);
}
.card:hover { background: var(--bg-card-hover); }
.card-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 20px;
}

/* ─── Drop Zone ───────────────────────────────────────────────────────────── */
.drop-zone-card { padding: 16px; }

.drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius-md);
  min-height: 220px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
  position: relative;
  overflow: hidden;
}
.drop-zone:hover,
.drop-zone.drag-over {
  border-color: var(--accent-1);
  background: rgba(139 92 246 / 0.07);
}
.drop-zone:focus-visible {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(139 92 246 / 0.25);
}

.drop-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  text-align: center;
  padding: 24px;
  pointer-events: none;
}
.drop-icon {
  width: 56px; height: 56px;
  color: var(--accent-3);
  opacity: 0.6;
}
.drop-label {
  font-size: 1rem;
  font-weight: 500;
  color: var(--text-primary);
}
.drop-sublabel {
  font-size: 0.8rem;
  color: var(--text-tertiary);
}

.preview-img {
  width: 100%;
  height: 100%;
  max-height: 340px;
  object-fit: contain;
  border-radius: calc(var(--radius-md) - 2px);
  display: block;
}

.btn-ghost {
  margin-top: 10px;
  background: none;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: 6px 18px;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-family: inherit;
  cursor: pointer;
  transition: border-color var(--transition), color var(--transition);
  align-self: center;
  display: block;
  margin-left: auto;
  margin-right: auto;
}
.btn-ghost:hover {
  border-color: var(--accent-3);
  color: var(--accent-3);
}

/* ─── Params ──────────────────────────────────────────────────────────────── */
.params-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px 32px;
}
@media (max-width: 520px) {
  .params-grid { grid-template-columns: 1fr; }
}

.param-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.param-label {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.param-value-display {
  display: inline-block;
  background: var(--accent-grad);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  font-weight: 700;
  font-size: 0.9rem;
  min-width: 3ch;
  text-align: right;
}

/* Range */
.range-input {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}
.range-input::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--accent-grad);
  cursor: pointer;
  box-shadow: 0 0 8px rgba(139 92 246 / 0.5);
  transition: transform var(--transition);
}
.range-input::-webkit-slider-thumb:hover { transform: scale(1.2); }
.range-input::-moz-range-thumb {
  width: 18px; height: 18px;
  border-radius: 50%;
  border: none;
  background: var(--accent-1);
  cursor: pointer;
}
.range-hint {
  display: flex;
  justify-content: space-between;
  font-size: 0.72rem;
  color: var(--text-tertiary);
}

/* Select */
.select-wrapper {
  position: relative;
}
.select-wrapper::after {
  content: '▾';
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--accent-3);
  pointer-events: none;
  font-size: 0.85rem;
}
.select-input {
  width: 100%;
  background: rgba(255 255 255 / 0.05);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.88rem;
  padding: 10px 36px 10px 14px;
  cursor: pointer;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  transition: border-color var(--transition);
}
.select-input:focus { border-color: var(--border-focus); }

/* Toggle */
.toggle {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
}
.toggle input { position: absolute; opacity: 0; width: 0; height: 0; }
.toggle-track {
  width: 44px; height: 24px;
  background: rgba(255 255 255 / 0.12);
  border-radius: 12px;
  position: relative;
  transition: background var(--transition);
  flex-shrink: 0;
}
.toggle input:checked + .toggle-track { background: var(--accent-1); }
.toggle-thumb {
  position: absolute;
  top: 3px; left: 3px;
  width: 18px; height: 18px;
  background: #fff;
  border-radius: 50%;
  transition: transform var(--transition);
  box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}
.toggle input:checked + .toggle-track .toggle-thumb { transform: translateX(20px); }
.toggle-label { font-size: 0.85rem; color: var(--text-secondary); }

/* ─── Bouton principal ────────────────────────────────────────────────────── */
.action-row {
  display: flex;
  justify-content: center;
}
.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 14px 40px;
  border-radius: 50px;
  border: none;
  background: var(--accent-grad);
  color: #fff;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: pointer;
  text-decoration: none;
  transition: opacity var(--transition), transform var(--transition), box-shadow var(--transition);
  box-shadow: 0 4px 24px rgba(139 92 246 / 0.4);
}
.btn-primary:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 8px 32px rgba(139 92 246 / 0.55);
}
.btn-primary:active:not(:disabled) { transform: translateY(0); }
.btn-primary:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  box-shadow: none;
}

/* Spinner dans le bouton */
.btn-spinner {
  width: 18px; height: 18px;
  border: 2px solid rgba(255 255 255 / 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Progression ─────────────────────────────────────────────────────────── */
.progress-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
  font-size: 0.88rem;
}
.progress-label { color: var(--text-secondary); }
.progress-timer { color: var(--accent-3); font-weight: 600; font-variant-numeric: tabular-nums; }

.progress-bar-track {
  height: 6px;
  background: rgba(255 255 255 / 0.1);
  border-radius: 3px;
  overflow: hidden;
}
.progress-bar-fill {
  height: 100%;
  border-radius: 3px;
  background: var(--accent-grad);
  transition: width 0.3s ease;
}
.progress-bar-fill.indeterminate {
  width: 40%;
  animation: indeterminate 1.6s ease-in-out infinite;
}
@keyframes indeterminate {
  0%   { transform: translateX(-120%); }
  100% { transform: translateX(350%); }
}

/* ─── Résultat ────────────────────────────────────────────────────────────── */
.result-video {
  width: 100%;
  border-radius: var(--radius-md);
  background: #000;
  display: block;
  margin-bottom: 20px;
  box-shadow: var(--shadow-glow);
}
.result-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

/* ─── Erreur ──────────────────────────────────────────────────────────────── */
.error-msg {
  background: rgba(248 113 113 / 0.12);
  border: 1px solid rgba(248 113 113 / 0.35);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  color: var(--error);
  font-size: 0.88rem;
  line-height: 1.5;
}

/* ─── Footer ──────────────────────────────────────────────────────────────── */
.footer {
  text-align: center;
  font-size: 0.78rem;
  color: var(--text-tertiary);
  padding-top: 8px;
}
.footer-link {
  color: var(--accent-3);
  text-decoration: none;
  opacity: 0.7;
}
.footer-link:hover { opacity: 1; }

/* ─── Utilitaires ─────────────────────────────────────────────────────────── */
.hidden { display: none !important; }

/* Card appear animation */
.card { animation: card-in 0.5s ease both; }
@keyframes card-in {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
.progress-card, .result-card {
  animation: card-in 0.4s ease both;
}
