/* ===========================================================================
   EDITAKU — Studio (laboratoire)
   ---------------------------------------------------------------------------
   3-zone layout : top bar / left sidebar (steps) / workspace / right panel.
   Built on top of tokens.css + components.css. Legacy variable aliases kept
   so the existing per-step inline CSS (character grid, snippet grid, etc.)
   still resolves without rewriting every selector.
   =========================================================================== */

/* ── Legacy aliases — bridge old variable names to the new tokens ────────── */
:root {
  --bg-soft:    var(--bg-elev-1);
  --card:       var(--bg-elev-2);
  --card-hover: var(--bg-elev-3);
  --muted:      var(--text-muted);
  --accent-from: var(--accent);
  --accent-to:   #6366f1;
  --electric:    var(--accent-bright);
  --ok-soft:     rgba(34, 197, 94, 0.22);
  --radius:      var(--r-lg);
  --radius-sm:   var(--r-sm);
}

@property --angle-fast {
  syntax: '<angle>';
  initial-value: 0deg;
  inherits: false;
}
@keyframes rotate-angle-fast { to { --angle-fast: 360deg; } }
@keyframes electric-pulse {
  0%, 100% { box-shadow: 0 0 0 0 var(--accent-soft), 0 0 14px var(--accent-soft); }
  50%      { box-shadow: 0 0 0 1px var(--accent-soft), 0 0 28px var(--accent-strong); }
}

/* ── Body / background ───────────────────────────────────────────────────── */
body.studio {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  min-height: 100vh;
  overflow-x: hidden;
}
.studio-bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
}
.studio-bg::before, .studio-bg::after {
  content: '';
  position: absolute;
  border-radius: 50%;
  filter: blur(140px);
}
.studio-bg::before {
  top: -200px; left: -150px;
  width: 540px; height: 540px;
  background: radial-gradient(circle, var(--viral-from), transparent 70%);
  opacity: 0.18;
}
.studio-bg::after {
  bottom: -200px; right: -150px;
  width: 600px; height: 600px;
  background: radial-gradient(circle, var(--accent), transparent 70%);
  opacity: 0.14;
}

/* ── Top bar ─────────────────────────────────────────────────────────────── */
.studio-topbar {
  position: sticky;
  top: 0;
  z-index: var(--z-nav);
  background: var(--bg-overlay);
  backdrop-filter: blur(16px) saturate(140%);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  height: 64px;
  display: flex;
  align-items: center;
  gap: var(--s-6);
  padding: 0 var(--s-6);
  max-width: 1600px;
  margin: 0 auto;
}
.topbar-brand {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  font-family: var(--font-accent);
  font-size: 1.5rem;
  letter-spacing: 0.04em;
  background: var(--hero-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  -webkit-text-fill-color: transparent;
  flex-shrink: 0;
  text-decoration: none;
  white-space: nowrap;
}
.topbar-divider {
  width: 1px;
  height: 24px;
  background: var(--border-strong);
  flex-shrink: 0;
}

/* Template tabs — replace the old pill row. Sits in the topbar. */
.template-tabs {
  display: flex;
  gap: var(--s-1);
  flex: 1;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: thin;
}
.template-tabs::-webkit-scrollbar { height: 0; }

/* Existing JS targets `.template-pill[data-template]` — we keep the class. */
.template-pill {
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--r-md);
  padding: var(--s-2) var(--s-4);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  min-width: 0;
  white-space: nowrap;
  transition: all var(--t-fast) var(--ease);
  color: var(--text-soft);
  font-family: inherit;
}
.template-pill > span:first-child {
  font-weight: 600;
  font-size: var(--fs-small);
  color: var(--text);
}
.template-pill > span:nth-child(2) {
  font-size: var(--fs-xs);
  color: var(--text-muted);
}
.template-pill:hover {
  background: var(--bg-elev-2);
  border-color: var(--border);
}
.template-pill--active {
  background: linear-gradient(135deg, rgba(168,85,247,0.15), rgba(236,72,153,0.10));
  border-color: rgba(168,85,247,0.35);
}
.template-pill--active > span:first-child {
  background: var(--hero-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  -webkit-text-fill-color: transparent;
}

/* End of topbar (quota + auth + lang) */
.topbar-end {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  flex-shrink: 0;
}

/* Quota badge — restyled. JS sets id="quotaBadge" and toggles .visible. */
.quota-badge {
  display: none;
  padding: var(--s-1) var(--s-3);
  border-radius: var(--r-full);
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  font-size: var(--fs-xs);
  color: var(--text-soft);
  font-weight: 500;
}
.quota-badge.visible { display: inline-flex; align-items: center; gap: var(--s-2); }
.quota-badge.depleted { background: rgba(239,68,68,0.10); border-color: rgba(239,68,68,0.35); color: var(--error); }

/* Auth slot inside topbar — auth-btn and auth-pill are populated by JS. */
.auth-btn {
  height: 36px;
  padding: 0 var(--s-4);
  border-radius: var(--r-full);
  background: var(--text);
  color: #000;
  font-weight: 600;
  font-size: var(--fs-small);
  cursor: pointer;
  transition: transform var(--t-fast), background var(--t-base);
}
.auth-btn:hover { transform: translateY(-1px); background: #fff; }

.auth-pill {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  padding: 4px 4px 4px var(--s-3);
  border-radius: var(--r-full);
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  font-size: var(--fs-xs);
}
.auth-email {
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-soft);
}
.auth-logout {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: var(--fs-xs);
  padding: 4px 8px;
  border-radius: var(--r-sm);
  transition: all var(--t-fast) var(--ease);
}
.auth-logout:hover { background: var(--bg-elev-3); color: var(--text); }

/* Language switcher — compact in topbar. */
.lang-switcher {
  display: flex;
  gap: 2px;
  padding: 2px;
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
}
.lang-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--text-muted);
  font-size: var(--fs-xs);
  font-weight: 600;
  cursor: pointer;
  transition: all var(--t-fast) var(--ease);
}
.lang-btn:hover { color: var(--text); }
.lang-btn.active { background: var(--bg-elev-3); color: var(--text); }
.lang-btn .flag {
  display: inline-block;
  width: 16px;
  height: 12px;
  border-radius: 2px;
  overflow: hidden;
  flex-shrink: 0;
}
.lang-btn .flag svg { display: block; width: 100%; height: 100%; }

/* ── Main 3-zone grid ────────────────────────────────────────────────────── */
.studio-grid {
  display: grid;
  grid-template-columns: 260px 1fr 320px;
  gap: var(--s-6);
  max-width: 1600px;
  margin: 0 auto;
  padding: var(--s-6);
  min-height: calc(100vh - 64px);
}

/* ── Sidebar (vertical stepper) ──────────────────────────────────────────── */
.studio-sidebar {
  position: sticky;
  top: calc(64px + var(--s-6));
  align-self: start;
  height: fit-content;
}
.sidebar-title {
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: var(--s-4);
  padding: 0 var(--s-2);
}

/* Vertical stepper — restyles the existing `.stepper` markup. */
.stepper {
  display: flex;
  flex-direction: column;
  gap: 0;
  background: var(--bg-elev-1);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--s-3);
  position: relative;
}
.step {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  gap: var(--s-2);
  padding: var(--s-4) var(--s-3);
  border-radius: var(--r-md);
  cursor: default;
  position: relative;
  text-align: center;
  transition: background var(--t-fast) var(--ease);
}
.step .num {
  width: 32px;
  height: 32px;
  border-radius: var(--r-full);
  background: var(--bg-elev-3);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--fs-small);
  font-weight: 700;
  color: var(--text-soft);
  flex-shrink: 0;
  transition: all var(--t-base) var(--ease);
}
.step .label {
  font-size: var(--fs-small);
  font-weight: 500;
  color: var(--text-muted);
  transition: color var(--t-base) var(--ease);
}
.step.active {
  background: linear-gradient(135deg, rgba(168,85,247,0.10), rgba(236,72,153,0.06));
}
.step.active .num {
  background: var(--viral-gradient);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 0 0 4px rgba(168,85,247,0.18);
}
.step.active .label { color: var(--text); font-weight: 600; }
.step.done .num {
  background: rgba(34, 197, 94, 0.15);
  border-color: rgba(34, 197, 94, 0.35);
  color: var(--ok);
}
.step.done .label { color: var(--text-soft); }

/* Vertical separator between steps — centered short connector line. */
.step-sep {
  width: 1px;
  height: 14px;
  background: var(--border);
  margin: 0 auto;
}

/* ── Workspace (center) ──────────────────────────────────────────────────── */
.studio-workspace {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: var(--s-5);
}

/* Hide the old template banner (template selector moved to topbar). */
#templateBanner { display: none !important; }

/* Cards — restyled to match the new tokens. The .card class is shared with
   the rest of the app but the studio cards need more breathing room. */
.studio-workspace .card {
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: var(--s-8);
  position: relative;
  transition: border-color var(--t-base) var(--ease);
}
.studio-workspace .card.hidden { display: none; }
.studio-workspace .card-title {
  font-size: var(--fs-h3);
  font-weight: 700;
  letter-spacing: var(--tracking-snug);
  margin: 0 0 var(--s-3);
  color: var(--text);
  display: flex;
  align-items: center;
  gap: var(--s-3);
}
.studio-workspace .card-subtitle {
  color: var(--text-soft);
  margin: 0 0 var(--s-6);
  line-height: var(--lh-relaxed);
}
.studio-workspace .step-tag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--r-full);
  background: var(--viral-gradient);
  color: #fff;
  font-size: var(--fs-small);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* Card-level form bits (form-row, field-label, time-inputs, hint, btn) */
.form-row {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  margin-bottom: var(--s-4);
}
.field-label {
  font-size: var(--fs-small);
  font-weight: 600;
  color: var(--text);
}
.time-inputs {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  background: var(--bg-elev-1);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--s-2) var(--s-3);
  width: fit-content;
}
.time-inputs input {
  background: transparent;
  border: none;
  color: var(--text);
  font-size: var(--fs-body);
  font-weight: 600;
  width: 56px;
  text-align: center;
  outline: none;
  font-variant-numeric: tabular-nums;
}
.time-inputs input::-webkit-outer-spin-button,
.time-inputs input::-webkit-inner-spin-button {
  -webkit-appearance: none; margin: 0;
}
.time-sep { color: var(--text-muted); font-weight: 700; }
.hint {
  font-size: var(--fs-small);
  color: var(--text-muted);
  line-height: var(--lh-relaxed);
  margin: var(--s-3) 0 0;
}

/* Primary action button used inside step cards (Continuer, Générer…). */
.studio-workspace .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  height: 48px;
  padding: 0 var(--s-6);
  border-radius: var(--r-full);
  font-size: var(--fs-body);
  font-weight: 600;
  background: var(--viral-gradient);
  color: #fff;
  cursor: pointer;
  border: none;
  transition: transform var(--t-fast) var(--ease-out),
              box-shadow var(--t-base) var(--ease),
              opacity var(--t-base) var(--ease);
}
.studio-workspace .btn:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: var(--glow-viral);
}
.studio-workspace .btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  background: var(--bg-elev-3);
  color: var(--text-muted);
}
.studio-workspace .btn.full { width: 100%; }
.studio-workspace .btn.secondary {
  background: var(--bg-elev-3);
  color: var(--text);
  border: 1px solid var(--border-strong);
}
.studio-workspace .btn.secondary:hover:not(:disabled) {
  background: var(--bg-elev-2);
  border-color: var(--border-accent);
  box-shadow: none;
}

.error-msg {
  margin-top: var(--s-3);
  padding: var(--s-3) var(--s-4);
  background: rgba(239,68,68,0.10);
  border: 1px solid rgba(239,68,68,0.30);
  border-radius: var(--r-md);
  color: var(--error);
  font-size: var(--fs-small);
}
.error-msg.hidden { display: none; }

/* ── Status panel (right) ────────────────────────────────────────────────── */
.studio-status {
  display: flex;
  flex-direction: column;
  gap: var(--s-4);
  position: sticky;
  top: calc(64px + var(--s-6));
  align-self: start;
  height: fit-content;
}
.status-card {
  background: var(--bg-elev-1);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--s-5);
}
.status-card h4 {
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  color: var(--text-muted);
  margin: 0 0 var(--s-3);
}
.status-card p {
  font-size: var(--fs-small);
  color: var(--text-soft);
  line-height: var(--lh-relaxed);
  margin: 0;
}
.status-card .big {
  font-size: 1.75rem;
  font-weight: 800;
  letter-spacing: var(--tracking-tight);
  background: var(--hero-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  -webkit-text-fill-color: transparent;
  display: block;
  margin-bottom: var(--s-1);
}
.status-card a.tip-link {
  display: inline-block;
  margin-top: var(--s-2);
  font-size: var(--fs-xs);
  color: var(--accent-bright);
}
.status-card a.tip-link:hover { text-decoration: underline; }

/* ── Modals (auth + pricing) — restyled to match landing modal. ─────────── */
.studio-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.75);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: var(--z-modal);
  padding: var(--s-4);
  animation: fade-up 200ms var(--ease-out);
}
.studio-modal {
  background: var(--bg-elev-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-xl);
  padding: var(--s-8);
  max-width: 460px;
  width: 100%;
  box-shadow: var(--shadow-xl);
}

/* ── Responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 1200px) {
  .studio-grid {
    grid-template-columns: 240px 1fr;
  }
  .studio-status {
    grid-column: 1 / -1;
    flex-direction: row;
    position: static;
    flex-wrap: wrap;
  }
  .status-card { flex: 1; min-width: 200px; }
}

@media (max-width: 800px) {
  .topbar-inner { gap: var(--s-3); padding: 0 var(--s-4); }
  .topbar-brand { font-size: 1.25rem; }
  .topbar-divider { display: none; }
  .template-tabs { gap: 2px; }
  .template-pill { padding: var(--s-1) var(--s-3); }
  .template-pill > span:nth-child(2) { display: none; }
  .lang-switcher { display: none; }
  .studio-grid {
    grid-template-columns: 1fr;
    padding: var(--s-4);
    gap: var(--s-4);
  }
  .studio-sidebar { position: static; }
  .stepper { flex-direction: row; overflow-x: auto; padding: var(--s-2); }
  .step { flex-direction: column; gap: var(--s-1); padding: var(--s-2) var(--s-3); min-width: 80px; text-align: center; }
  .step .label { font-size: var(--fs-xs); }
  .step-sep { display: none; }
  .studio-workspace .card { padding: var(--s-5); }
  .studio-status { flex-direction: column; }
}
