/* ==========================================================================
   Panneau « Ajouter mon produit » (CONTRAT §2) : formulaire, description avec
   compteur, champs de fichier (logo, image, vidéo) avec aperçu, progression et retrait.
   Chargé après app.css.
   ========================================================================== */

.sx-add-body {
  flex: 1 1 auto;
  min-height: 0;
  padding: 0 calc(env(safe-area-inset-right) + var(--pad-x)) 0 calc(env(safe-area-inset-left) + var(--pad-x));
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}
.sx-add-inner { width: 100%; max-width: 1060px; margin: 0 auto; padding-top: 18px; }

.add-notice {
  margin-bottom: 14px;
  padding: 10px 12px;
  font-size: 13.5px;
  color: var(--text);
  background: color-mix(in srgb, var(--gold) 12%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--gold) 40%, var(--line));
  border-left: 3px solid var(--gold);
  border-radius: var(--radius);
}
.add-notice--quiet {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
  background: var(--surface);
  border-color: var(--line-soft);
  border-left-color: var(--muted-2);
}
.sx-addpanel .aim-note { margin: 0 0 14px; }

/* Formulaire : une colonne (mobile), deux sur grand écran (fiche | montant) */
.sx-addpanel .add-form { margin-top: 0; }
.add-main,
.add-side { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
@media (min-width: 960px) {
  .sx-addpanel .add-form {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(320px, 380px);
    align-items: start;
    gap: 32px;
  }
  .add-side { position: sticky; top: 18px; padding-bottom: 28px; }
}

/* Description et compteur */
.field-label-row { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.field-count { font-family: var(--mono); font-size: 11.5px; color: var(--muted-2); font-variant-numeric: tabular-nums; }
.field-count.is-near { color: var(--gold); }
.textarea { min-height: 88px; padding: 10px 12px; line-height: 1.45; resize: vertical; }

/* Médias facultatifs */
.add-media { display: flex; flex-direction: column; gap: 8px; min-width: 0; margin: 2px 0 0; padding: 0; border: 0; }
.add-media-box {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
  background: var(--bg-2);
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  container: addmedia / inline-size;
}
.add-media-lead { font-size: 12.5px; color: var(--muted-2); }
.upl-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
@container addmedia (min-width: 540px) {
  .upl-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

.upl { position: relative; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.upl-head { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.upl-hint { font-size: 11.5px; color: var(--muted-2); }
.upl-input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  opacity: 0;
  pointer-events: none;
}
.upl-pick {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  min-height: 76px;
  padding: 10px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  background: var(--surface);
  border: 1.5px dashed var(--line);
  border-radius: 10px;
  transition: border-color 150ms var(--ease), background-color 150ms var(--ease);
}
.upl-pick svg { color: var(--muted); }
.upl-pick:hover:not([disabled]) { background: var(--surface-2); border-color: var(--muted); }
.upl-pick[disabled] { color: var(--muted-2); cursor: not-allowed; opacity: 0.6; }
.upl.is-dragover .upl-pick { background: color-mix(in srgb, var(--good) 10%, var(--surface)); border-color: var(--good); }
.upl.is-disabled .upl-head { opacity: 0.75; }

.upl-file {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-height: 76px;
  padding: 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
}
.upl[data-state="done"] .upl-file { border-color: color-mix(in srgb, var(--good) 55%, var(--line)); }
.upl-preview { width: 48px; height: 48px; overflow: hidden; background: #0a0a0a; border-radius: 8px; }
/* Aperçu entier, jamais étiré (images et vidéos verticales comprises) */
.upl-preview img,
.upl-preview video { display: block; width: 100%; height: 100%; object-fit: contain; }
.upl[data-kind="logo"] .upl-preview { background: #ffffff; }
.upl-body { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.upl-name { overflow: hidden; font-size: 13px; font-weight: 600; white-space: nowrap; text-overflow: ellipsis; }
.upl-status { font-family: var(--mono); font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.upl[data-state="done"] .upl-status { color: var(--good); }
.upl-bar { position: relative; display: block; height: 4px; overflow: hidden; background: var(--surface-2); border-radius: 999px; }
.upl-bar-fill {
  position: absolute;
  inset: 0;
  background: var(--good);
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform 160ms linear;
}
.upl-remove {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--line-soft);
  border-radius: 50%;
}
.upl-remove:hover { color: var(--text); border-color: var(--line); }
/* « Annuler » pendant l'envoi (interrompt l'envoi, révoque l'aperçu) */
.upl-cancel {
  min-height: 34px;
  padding: 0 12px;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 999px;
}
.upl-cancel:hover { border-color: var(--muted-2); }
/* Gros fichier (plus de 200 Mo) : l'envoi prend du temps */
.upl-note { font-size: 12px; line-height: 1.35; color: var(--gold); }
.upl-status { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }

/* Tuile étroite (grille à trois colonnes) : aperçu + texte, puis l'action sur sa propre ligne */
.upl { container: upl / inline-size; }
@container upl (max-width: 300px) {
  .upl-file { grid-template-columns: 40px minmax(0, 1fr); gap: 8px 10px; }
  .upl-preview { width: 40px; height: 40px; }
  .upl-cancel { grid-column: 1 / -1; justify-self: stretch; }
  .upl-remove { grid-column: 1 / -1; justify-self: end; }
}

/* Pied : collant sur mobile (l'action reste visible), simple sur grand écran */
.sx-addpanel .form-foot {
  padding-bottom: calc(env(safe-area-inset-bottom) + 14px);
  background: linear-gradient(180deg, color-mix(in srgb, var(--bg) 0%, transparent), var(--bg) 22%);
}
@media (min-width: 960px) {
  .sx-addpanel .form-foot { position: static; margin: 0; padding: 4px 0 0; background: none; }
}
