/* ==========================================================
   06 - Panneau d'edition : formulaires, controles, boutons
   ========================================================== */

/* --- Selecteurs de type --- */
.type-toggle-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}
.type-toggle-item {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 15px;
  border-radius: var(--r-full);
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: -0.012em;
  cursor: pointer;
  border: 1px solid color-mix(in srgb, var(--tc, var(--gray)) 30%, transparent);
  background: color-mix(in srgb, var(--tc, var(--gray)) 7%, #fff);
  color: color-mix(in srgb, var(--tc, var(--gray)) 85%, var(--t1));
  transition: background 0.18s, border-color 0.18s, color 0.18s, box-shadow 0.18s, transform 0.12s;
  user-select: none;
}
.type-toggle-item input[type="checkbox"] { display: none; }
.type-toggle-item:hover {
  background: color-mix(in srgb, var(--tc, var(--gray)) 15%, #fff);
  border-color: color-mix(in srgb, var(--tc, var(--gray)) 45%, transparent);
}
.type-toggle-item:active { transform: scale(0.97); }
.type-toggle-item.active {
  background: var(--tc, var(--gray));
  border-color: var(--tc, var(--gray));
  color: #fff;
  box-shadow: 0 3px 12px -3px color-mix(in srgb, var(--tc, var(--gray)) 55%, transparent);
}

/* --- Conteneur d'edition --- */
.edit-container {
  background: var(--surface);
  border-radius: var(--r-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.edit-placeholder {
  padding: 64px 32px;
  text-align: center;
}
.edit-placeholder-icon {
  width: 52px; height: 52px;
  background: var(--surface-3);
  border-radius: var(--r-md);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
  color: var(--t4);
}
.edit-placeholder-icon svg { width: 22px; height: 22px; }
.edit-placeholder p {
  font-size: 14px;
  color: var(--t3);
  font-weight: 400;
}

.edit-header { padding: 24px 28px 0; }
.edit-op-name {
  font-family: var(--display);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.032em;
  color: var(--t1);
  margin-bottom: 7px;
  line-height: 1.15;
}
.edit-mecanique {
  font-size: 13px;
  color: var(--t3);
  line-height: 1.65;
  margin-bottom: 16px;
}
.edit-badges {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 11px;
  border-radius: var(--r-full);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: -0.008em;
}
.badge-mag  { background: var(--blue-soft);   color: var(--blue); }
.badge-web  { background: var(--green-soft);  color: var(--green); }
.badge-mail { background: color-mix(in srgb, var(--purple) 10%, transparent); color: var(--purple); }
.badge-plv  { background: var(--orange-soft); color: var(--orange); }
.badge-opt  { background: var(--surface-3);   color: var(--t3); }

.edit-form { padding: 24px 28px 28px; }

/* Titre de section : filet + petites capitales */
.form-section-title {
  display: flex;
  align-items: center;
  gap: 12px;
  font-family: var(--display);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.11em;
  color: var(--t3);
  margin-bottom: 14px;
  margin-top: 28px;
}
.form-section-title::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}
.form-section-title:first-child { margin-top: 0; }

/* --- Cases enseigne --- */
.form-enseignes {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}
.enseigne-check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 15px;
  border: 1px solid var(--border-2);
  border-radius: var(--r-full);
  cursor: pointer;
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: -0.012em;
  color: var(--t2);
  background: var(--surface);
  transition: border-color .18s, background .18s, color .18s, box-shadow .18s;
  user-select: none;
}
.enseigne-check input[type=checkbox] { display: none; }
.enseigne-check::before {
  content: '';
  width: 15px;
  height: 15px;
  border: 1.5px solid var(--border-3);
  border-radius: 5px;
  background: var(--surface);
  flex-shrink: 0;
  transition: background .18s, border-color .18s;
}
.enseigne-check:hover { border-color: var(--border-3); background: var(--surface-2); }
.enseigne-check.checked {
  border-color: color-mix(in srgb, var(--blue) 50%, transparent);
  background: var(--blue-soft);
  color: var(--blue);
}
.enseigne-check.checked::before {
  background: var(--blue);
  border-color: var(--blue);
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 10 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 4l3 3 5-6' stroke='white' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
  background-size: 10px 8px;
}

/* --- Statut --- */
.form-statut {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}
.statut-check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 17px;
  border: 1px solid var(--border-2);
  border-radius: var(--r-full);
  cursor: pointer;
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: -0.012em;
  color: var(--t2);
  background: var(--surface);
  transition: border-color .18s, background .18s, color .18s;
  user-select: none;
}
.statut-check input[type=radio] { display: none; }
.statut-check:hover { border-color: var(--border-3); background: var(--surface-2); }
.statut-check.statut-active {
  border-color: color-mix(in srgb, var(--orange) 50%, transparent);
  background: var(--orange-soft);
  color: var(--orange);
  font-weight: 700;
}

/* --- Bandeau enseigne sur les cards --- */
.op-card-image { position: relative; }
.op-card-enseigne-banner {
  display: flex;
  overflow: hidden;
  height: 35px;
  width: 100%;
}
.op-card-enseigne-item {
  flex: 1;
  padding: 0 8px;
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
}
.op-card-enseigne-logo {
  display: block;
  width: calc(100% - 16px);
  height: 27px;
  background-size: contain;
  background-position: center;
  background-repeat: no-repeat;
}

/* --- Grille de formulaire --- */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px 20px;
}
.form-field { display: flex; flex-direction: column; gap: 6px; }
.form-field.full { grid-column: 1 / -1; }

/* --- Editeur riche --- */
.rich-toolbar {
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 5px 7px;
  background: var(--surface-2);
  border: 1px solid var(--border-2);
  border-bottom: none;
  border-radius: var(--r-sm) var(--r-sm) 0 0;
}
.rich-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 27px; height: 27px;
  padding: 0 5px;
  background: none;
  border: 1px solid transparent;
  border-radius: 7px;
  font-size: 12px;
  color: var(--t2);
  cursor: pointer;
  transition: background .14s, border-color .14s, color .14s;
}
.rich-btn:hover { background: var(--surface); border-color: var(--border-2); color: var(--t1); }
.rich-btn-b { font-weight: 700; }
.rich-btn-i { font-style: italic; }
.rich-btn svg { width: 14px; height: 12px; display: block; }
.rich-sep {
  width: 1px; height: 16px;
  background: var(--border-2);
  margin: 0 4px;
}
.rich-editor {
  min-height: 84px;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: 0 0 var(--r-sm) var(--r-sm);
  font-size: 13px;
  font-family: var(--sf);
  color: var(--t1);
  line-height: 1.65;
  outline: none;
  transition: border-color .18s, box-shadow .18s;
}
.rich-editor:focus {
  border-color: var(--blue);
  box-shadow: var(--ring);
}
.rich-editor font[size="2"] { font-size: 11px; }
.rich-editor font[size="3"] { font-size: 14px; }
.rich-editor font[size="5"] { font-size: 18px; }
.op-card-comment font[size="2"] { font-size: 10px; }
.op-card-comment font[size="5"] { font-size: 16px; }

/* --- Champs --- */
.form-field label {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--t3);
  letter-spacing: 0.005em;
}
.form-field input,
.form-field select,
.form-field textarea {
  padding: 10px 13px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  font-size: 13px;
  color: var(--t1);
  outline: none;
  transition: border-color 0.18s, box-shadow 0.18s, background 0.18s;
  width: 100%;
}
.form-field input:hover,
.form-field select:hover,
.form-field textarea:hover { border-color: var(--border-2); }
.form-field input:focus,
.form-field select:focus,
.form-field textarea:focus {
  border-color: var(--blue);
  box-shadow: var(--ring);
  background: var(--surface);
}
.form-field textarea { resize: none; min-height: 76px; line-height: 1.55; overflow: hidden; field-sizing: content; }

.form-image-preview {
  width: 100%;
  aspect-ratio: 450 / 250;
  border-radius: var(--r-sm);
  overflow: hidden;
  margin-bottom: 8px;
  background: var(--surface-3);
  border: 1px solid var(--border);
}
.form-image-preview img,
.form-image-preview video { width: 100%; height: 100%; object-fit: cover; display: block; }

.form-file-input {
  padding: 10px 12px;
  background: var(--surface-2);
  border: 1.5px dashed var(--border-3);
  border-radius: var(--r-sm);
  font-size: 12.5px;
  color: var(--t3);
  cursor: pointer;
  width: 100%;
  transition: border-color 0.18s, color 0.18s, background 0.18s;
}
.form-file-input:hover { border-color: var(--blue); color: var(--t1); background: var(--blue-soft); }

.form-pdf-current {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 11px;
  margin-bottom: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
}
.form-pdf-link {
  font-size: 13px;
  color: var(--blue);
  text-decoration: none;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.form-pdf-link:hover { text-decoration: underline; text-underline-offset: 2px; }
.form-pdf-delete-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--red);
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
}

/* ==========================================================
   Boutons
   ========================================================== */
.btn-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 26px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 10px 20px;
  border-radius: var(--r-sm);
  font-size: 13px;
  font-weight: 600;
  border: 1px solid transparent;
  transition: background 0.18s, color 0.18s, border-color 0.18s, box-shadow 0.18s, transform 0.12s;
  letter-spacing: -0.014em;
  line-height: 1;
}
.btn:disabled {
  opacity: 0.65;
  cursor: not-allowed;
  transform: none !important;
}
.btn-spinner {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  animation: btn-spin 0.7s linear infinite;
}
@keyframes btn-spin {
  to { transform: rotate(360deg); }
}
.btn-primary {
  background: var(--blue);
  color: #fff;
  box-shadow: 0 1px 0 rgba(255,255,255,0.16) inset, 0 2px 8px -2px rgba(43,82,224,0.42);
}
.btn-primary:hover { background: var(--blue-press); box-shadow: 0 1px 0 rgba(255,255,255,0.16) inset, 0 4px 14px -3px rgba(43,82,224,0.50); }
.btn-primary:active { transform: scale(0.98); }
.btn-success {
  background: var(--green);
  color: #fff;
  box-shadow: 0 1px 0 rgba(255,255,255,0.16) inset, 0 2px 8px -2px rgba(11,128,85,0.42);
}
.btn-success:hover { background: var(--green-press); box-shadow: 0 1px 0 rgba(255,255,255,0.16) inset, 0 4px 14px -3px rgba(11,128,85,0.50); }
.btn-success:active { transform: scale(0.98); }
.btn-secondary {
  background: var(--surface);
  border-color: var(--border-2);
  color: var(--t2);
  box-shadow: var(--shadow-xs);
}
.btn-secondary:hover { background: var(--surface-2); border-color: var(--border-3); color: var(--t1); }
.btn-secondary:active { transform: scale(0.98); }
.btn-danger {
  background: var(--red-soft);
  border-color: color-mix(in srgb, var(--red) 22%, transparent);
  color: var(--red);
}
.btn-danger:hover { background: var(--red); border-color: var(--red); color: #fff; box-shadow: 0 4px 14px -3px rgba(224,36,36,0.45); }
.btn-danger:active { transform: scale(0.98); }

.save-toast {
  position: absolute;
  left: calc(100% + 10px);
  top: 50%;
  transform: translateY(-50%) translateX(-4px);
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: var(--green);
  font-weight: 600;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.3s, transform 0.3s var(--ease);
  pointer-events: none;
}
.save-toast.show { opacity: 1; transform: translateY(-50%) translateX(0); }
.save-toast svg { width: 14px; height: 14px; }
