/* =============================================================
   Meetles — Event Form Wizard (v1.5.0)
   Habillage multi-étapes du formulaire TEC Community Events.
   Palette alignée sur main.css du thème Meetles.
   ============================================================= */

/* ----------------- Tokens ----------------- */
.meetles-wizard {
  --mw-primary: #164f5e;        /* vert foncé (boutons submit TEC existants) */
  --mw-primary-hover: #0d3a47;
  --mw-accent: #ce3557;         /* rose / bouton publier natif */
  --mw-accent-hover: #a82944;
  --mw-bgg: #5800FF;            /* violet BGG existant */
  --mw-teal: #2c8a9e;           /* teal tags / retour */
  --mw-warn: #e0a30c;
  --mw-bg: #f5f7fa;
  --mw-card: #ffffff;
  --mw-text: #1f2a37;
  --mw-muted: #6b7785;
  --mw-border: #d9e1e8;
  --mw-border-soft: #eef1f4;
  --mw-radius: 12px;
  --mw-radius-sm: 8px;
  --mw-radius-pill: 50px;
  --mw-shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --mw-shadow-md: 0 4px 14px rgba(15, 23, 42, 0.08);
}

/* Activation : quand .meetles-wizard est présent, on cache certains éléments TEC
   non déplacés (ex : éventuels anciens wrappers) et on restyle ceux qu'on bouge. */

/* ----------------- Masquages pendant le wizard ----------------- */
.meetles-wizard-active #tribe-community-events .events-community-post-title,
.meetles-wizard-active #tribe-community-events .tribe-community-post-title {
  display: none; /* On a notre propre titre de page en haut */
}

/* Masque la zone du bouton publier natif — elle est rendue par notre étape 5 */
.meetles-wizard-active .tribe-events-community-footer,
.meetles-wizard-active .tribe-community-notice,
.meetles-wizard-active input.button.submit.events-community-submit {
  display: none !important;
}

/* Filet de sécurité : toute section du form natif restée à sa place (non déplacée
   par le wizard) est masquée pour éviter le "doublon" formulaire natif + wizard.
   La classe est ajoutée à la volée par event-form-wizard.js en fin de move. */
.meetles-wizard-active .mw-legacy-hidden {
  display: none !important;
}


/* ----------------- En-tête page ----------------- */
.meetles-wizard {
  font-family: inherit;
  color: var(--mw-text);
}

.meetles-wizard-hero {
  padding: 8px 0 16px;
  border-bottom: 1px solid var(--mw-border-soft);
  margin-bottom: 20px;
}
.meetles-wizard-hero h1 {
  margin: 0 0 4px;
  font-size: 26px;
  color: var(--mw-text);
}
.meetles-wizard-hero p {
  margin: 0;
  color: var(--mw-muted);
  font-size: 15px;
}

/* ----------------- Progress bar ----------------- */
.meetles-wizard-progress {
  display: flex;
  gap: 8px;
  background: var(--mw-card);
  padding: 14px 18px;
  border-radius: var(--mw-radius);
  box-shadow: var(--mw-shadow-sm);
  margin-bottom: 22px;
  border: 1px solid var(--mw-border-soft);
}
.mw-step-pill {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  cursor: pointer;
  user-select: none;
  transition: opacity .15s;
  background: transparent;
  border: 0;
  font: inherit;
  text-align: left;
  color: var(--mw-muted);
  padding: 2px 4px;
}
.mw-step-pill.is-locked { cursor: not-allowed; opacity: .45; }
.mw-step-pill:focus-visible { outline: 2px solid var(--mw-primary); border-radius: 6px; }

.mw-step-num {
  flex-shrink: 0;
  width: 28px; height: 28px;
  border-radius: 50%;
  display: grid; place-items: center;
  font-size: 13px; font-weight: 700;
  background: var(--mw-bg);
  color: var(--mw-muted);
  border: 2px solid var(--mw-border);
  transition: all .2s;
}
.mw-step-pill.is-done .mw-step-num {
  background: var(--mw-primary);
  color: #fff;
  border-color: var(--mw-primary);
}
.mw-step-pill.is-done .mw-step-num::before { content: "✓"; }
.mw-step-pill.is-done .mw-step-num span { display: none; }

.mw-step-pill.is-active {
  color: var(--mw-text);
  font-weight: 600;
}
.mw-step-pill.is-active .mw-step-num {
  background: var(--mw-accent);
  color: #fff;
  border-color: var(--mw-accent);
  box-shadow: 0 0 0 4px rgba(206, 53, 87, .18);
}

.mw-step-label {
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ----------------- Layout ----------------- */
.meetles-wizard-layout {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 28px;
  align-items: start;
}
.meetles-wizard-form {
  min-width: 0;
}
.meetles-wizard-preview-col {
  position: sticky;
  top: 20px;
  min-width: 0;
}

/* ----------------- Card / écrans ----------------- */
.meetles-wizard-card {
  background: var(--mw-card);
  border-radius: var(--mw-radius);
  box-shadow: var(--mw-shadow-sm);
  border: 1px solid var(--mw-border-soft);
  padding: 26px 28px;
}

.mw-step {
  display: none;
  animation: mwFade .22s ease;
}
.mw-step.is-active { display: block; }

@keyframes mwFade {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.mw-step-header {
  margin-bottom: 18px;
}
.mw-step-header .mw-eyebrow {
  color: var(--mw-accent);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .5px;
  text-transform: uppercase;
  margin-bottom: 4px;
}
.mw-step-header h2 {
  margin: 0 0 6px;
  font-size: 22px;
  color: var(--mw-text);
}
.mw-step-header p {
  margin: 0;
  color: var(--mw-muted);
  font-size: 14px;
}

/* ----------------- Restyle des champs injectés dans les étapes ----------------- */
/* On hérite du rendu TEC mais on adoucit : plus compacts, radius, focus clair */

.meetles-wizard .tribe-bgg-game-field,
.meetles-wizard .tribe-lieu-game-field,
.meetles-wizard .tribe-joueurs-game-field,
.meetles-wizard .tribe-predefined-venue-field,
.meetles-wizard .tribe-datetime-block,
.meetles-wizard .tribe-event-recurrence,
.meetles-wizard .tribe-section {
  margin-bottom: 16px;
}

.meetles-wizard label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: var(--mw-text);
  margin-bottom: 6px;
  text-transform: none;
}

/* Inputs TEC — override plus doux (main.css met font-size 20px partout) */
.meetles-wizard .tribe-community-events input[type="text"],
.meetles-wizard .tribe-community-events input[type="email"],
.meetles-wizard .tribe-community-events input[type="url"],
.meetles-wizard .tribe-community-events input[type="search"],
.meetles-wizard .tribe-community-events input[type="number"],
.meetles-wizard .tribe-community-events select,
.meetles-wizard .tribe-community-events textarea,
.meetles-wizard input.mw-input,
.meetles-wizard select.mw-select,
.meetles-wizard textarea.mw-textarea,
.meetles-wizard #bgg_game,
.meetles-wizard #event_address_input,
.meetles-wizard #event_player_count,
.meetles-wizard #meetles_venue_select {
  font-size: 15px !important;
  padding: 10px 12px !important;
  border: 1.5px solid var(--mw-border) !important;
  border-radius: var(--mw-radius-sm) !important;
  background: #fff;
  width: 100%;
  box-sizing: border-box;
  transition: border-color .15s, box-shadow .15s;
}
.meetles-wizard .tribe-community-events input:focus,
.meetles-wizard .tribe-community-events select:focus,
.meetles-wizard .tribe-community-events textarea:focus,
.meetles-wizard #bgg_game:focus,
.meetles-wizard #event_address_input:focus {
  outline: none;
  border-color: var(--mw-primary) !important;
  box-shadow: 0 0 0 3px rgba(22, 79, 94, .14);
}

/* Date / heure TEC — rangée compacte */
.meetles-wizard .tribe-datetime-block .tribe-section-content-field label {
  font-size: 14px !important;
}
.meetles-wizard .tribe-datetime-block input[type="text"] {
  max-width: 180px;
}

/* BGG preview thumbnail — plus grande */
.meetles-wizard #bgg-thumbnail-preview img {
  max-width: 160px !important;
  border-radius: var(--mw-radius-sm);
  box-shadow: var(--mw-shadow-sm);
  border: 1px solid var(--mw-border-soft) !important;
}

/* Message "Obligatoire" */
.meetles-wizard .req {
  color: var(--mw-warn) !important;
  font-size: 13px !important;
  font-weight: 700 !important;
  text-transform: none !important;
}

/* ----------------- Chips (nb joueurs) ----------------- */
.mw-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 6px;
}
.mw-chip {
  padding: 8px 16px;
  border-radius: var(--mw-radius-pill);
  border: 1.5px solid var(--mw-border);
  background: #fff;
  font-size: 14px;
  cursor: pointer;
  transition: all .15s;
  user-select: none;
  font-weight: 600;
  color: var(--mw-text);
}
.mw-chip:hover { border-color: var(--mw-primary); }
.mw-chip.is-selected {
  background: var(--mw-primary);
  color: #fff;
  border-color: var(--mw-primary);
}

/* ----------------- Check cards (type de joueurs / visibilité) ----------------- */
.mw-check-card {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  border: 1.5px solid var(--mw-border);
  border-radius: var(--mw-radius-sm);
  cursor: pointer;
  margin-bottom: 8px;
  transition: all .15s;
  background: #fff;
}
.mw-check-card:hover { border-color: var(--mw-primary); }
.mw-check-card.is-selected {
  border-color: var(--mw-primary);
  background: rgba(22, 79, 94, 0.04);
}
.mw-check-card input { margin-top: 3px; }
.mw-check-card .mw-cc-t { font-weight: 600; font-size: 14px; display: block; }
.mw-check-card .mw-cc-d { font-size: 13px; color: var(--mw-muted); display: block; margin-top: 2px; }

/* ----------------- Navigation actions ----------------- */
.mw-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--mw-border-soft);
  gap: 10px;
}
.mw-btn {
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  padding: 11px 22px;
  border-radius: var(--mw-radius-pill);
  border: 0;
  cursor: pointer;
  transition: all .15s ease;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  line-height: 1;
}
.mw-btn-primary {
  background: var(--mw-primary);
  color: #fff;
}
.mw-btn-primary:hover { background: var(--mw-primary-hover); color: #fff; }

.mw-btn-publish {
  background: var(--mw-accent);
  color: #fff;
  padding: 13px 30px;
  font-size: 16px;
}
.mw-btn-publish:hover { background: var(--mw-accent-hover); color: #fff; }

.mw-btn-ghost {
  background: transparent;
  color: var(--mw-muted);
}
.mw-btn-ghost:hover {
  background: var(--mw-bg);
  color: var(--mw-text);
}

.mw-btn:disabled,
.mw-btn[aria-disabled="true"] {
  opacity: .5;
  cursor: not-allowed;
}

/* ----------------- Preview sticky ----------------- */
.meetles-wizard-preview {
  background: var(--mw-card);
  border-radius: var(--mw-radius);
  box-shadow: var(--mw-shadow-md);
  overflow: hidden;
  border: 1px solid var(--mw-border-soft);
}
.mw-preview-header {
  padding: 10px 16px;
  background: var(--mw-primary);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .5px;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  gap: 6px;
}
.mw-preview-img {
  width: 100%;
  aspect-ratio: 16 / 10;
  background: linear-gradient(135deg, #eef1f4, #d9e1e8);
  display: grid;
  place-items: center;
  color: var(--mw-muted);
  font-size: 13px;
  padding: 10px;
  text-align: center;
}
.mw-preview-img img { width: 100%; height: 100%; object-fit: cover; border-radius: 6px; }

.mw-preview-body { padding: 14px 16px 16px; }
.mw-preview-body h3 {
  margin: 0 0 10px;
  font-size: 17px;
  color: var(--mw-text);
  word-break: break-word;
}
.mw-preview-meta {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: var(--mw-text);
}
.mw-preview-meta .mw-row {
  display: flex;
  align-items: center;
  gap: 8px;
  line-height: 1.4;
}
.mw-preview-meta .mw-row.is-empty {
  color: var(--mw-muted);
  opacity: .65;
}
.mw-preview-meta .mw-icon {
  width: 18px;
  text-align: center;
  flex-shrink: 0;
}
.mw-preview-desc {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--mw-border-soft);
  font-size: 13px;
  color: var(--mw-muted);
  white-space: pre-wrap;
  word-break: break-word;
}
.mw-preview-placeholder {
  color: var(--mw-muted);
  font-style: italic;
}

/* Badge "auto BGG" */
.mw-autofill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(88, 0, 255, 0.1);
  color: var(--mw-bgg);
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: var(--mw-radius-pill);
  margin-left: 6px;
  vertical-align: middle;
}

/* ----------------- Récap (étape 5) ----------------- */
.mw-recap {
  display: grid;
  gap: 10px;
  margin-bottom: 18px;
}
.mw-recap-item {
  display: grid;
  grid-template-columns: 160px 1fr auto;
  gap: 12px;
  padding: 12px 14px;
  background: var(--mw-bg);
  border-radius: var(--mw-radius-sm);
  align-items: center;
}
.mw-recap-k {
  font-size: 13px;
  color: var(--mw-muted);
  font-weight: 600;
}
.mw-recap-v { font-weight: 500; word-break: break-word; }
.mw-recap-edit {
  font-size: 12px;
  color: var(--mw-primary);
  cursor: pointer;
  background: none;
  border: 0;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 4px;
}
.mw-recap-edit:hover {
  text-decoration: underline;
  background: rgba(22, 79, 94, .06);
}

.mw-legal {
  background: rgba(22, 79, 94, 0.05);
  padding: 14px 16px;
  border-radius: var(--mw-radius-sm);
  font-size: 13px;
  line-height: 1.5;
  margin: 14px 0;
  border: 1px solid var(--mw-border-soft);
}
.mw-legal label {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  cursor: pointer;
  font-weight: 500;
  margin: 0;
}

/* ----------------- Mobile ----------------- */
@media (max-width: 900px) {
  .meetles-wizard-layout { grid-template-columns: 1fr; }
  .meetles-wizard-preview-col {
    position: static;
    order: -1;           /* aperçu en haut sur mobile */
  }
  .meetles-wizard-preview { margin-bottom: 8px; }
  .mw-step-label { display: none; }
  .meetles-wizard-progress { padding: 10px 12px; overflow-x: auto; }
  .mw-step-pill { flex: 0 0 auto; }
  .mw-recap-item { grid-template-columns: 1fr; gap: 4px; }
  .mw-recap-edit { justify-self: start; }
  .meetles-wizard-card { padding: 20px 18px; }
}

/* ----------------- Toast mini-info (restore draft) ----------------- */
.mw-toast {
  background: rgba(22, 79, 94, 0.08);
  border: 1px solid rgba(22, 79, 94, 0.2);
  border-radius: var(--mw-radius-sm);
  padding: 10px 14px;
  margin-bottom: 14px;
  font-size: 13px;
  color: var(--mw-text);
  display: flex;
  align-items: center;
  gap: 10px;
}
.mw-toast button {
  background: none;
  border: 0;
  color: var(--mw-primary);
  font-weight: 700;
  cursor: pointer;
  font-size: 13px;
  padding: 4px 8px;
  border-radius: 4px;
}
.mw-toast button:hover { background: rgba(22, 79, 94, .12); }

/* ----------------- Description textarea custom ----------------- */
.mw-textarea {
  min-height: 120px;
  resize: vertical;
  font-family: inherit;
}

/* ----------------- Placeholder pour sections déplacées ----------------- */
.mw-moved-stub {
  display: none;
}

/* ----------------- v2.1.0 — Mode édition ----------------- */
/* Overlay de chargement pendant le GET /tables/{id} */
.meetles-wizard-v2 { position: relative; }
.meetles-wizard-v2.mw-loading { min-height: 320px; }
.mw-loading-overlay {
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, .85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  border-radius: inherit;
}
.mw-loading-overlay__box {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 22px;
  background: #fff;
  border: 1px solid rgba(22, 79, 94, .15);
  border-radius: 8px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, .08);
  font-weight: 600;
  color: #164f5e;
}
.mw-loading-overlay__spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(22, 79, 94, .25);
  border-top-color: #164f5e;
  border-radius: 50%;
  animation: mwSpin .9s linear infinite;
}
@keyframes mwSpin {
  to { transform: rotate(360deg); }
}

/* Bandeau d'info "vous êtes en mode édition" */
.mw-edit-notice {
  margin: 8px 0 18px;
  padding: 10px 14px;
  background: rgba(22, 79, 94, .06);
  border-left: 3px solid #164f5e;
  border-radius: 4px;
  font-size: 14px;
  color: #164f5e;
}
.mw-edit-notice strong { font-weight: 700; }

/* Pills "is-locked" → toutes déverrouillées en édition */
.meetles-wizard-edit .mw-step-pill.is-locked {
  opacity: 1;
  cursor: pointer;
}
