/*
 * AWP Affiliate Manager — Encart partenaire
 * Stylesheet partagée : utilisée par l'aperçu admin ET le plugin WordPress.
 *
 * Layout basculé via container query (point de rupture : 490px), pas media query :
 *  - < 490px de largeur de conteneur : empilé (logo au-dessus, CTA en bas pleine largeur)
 *  - ≥ 490px : horizontal (logo / contenu / CTA sur une ligne)
 */

.awp-am__container {
  container-type: inline-size;
  container-name: awp-encart;
  margin: 32px 0;

  /* Tokens locaux — fond clair par défaut, valeurs neutres réutilisables sur les sites du réseau */
  --awp-base:       #d9d9d9;
  --awp-bg:         #f7f7f7;
  --awp-card:       #ffffff;
  --awp-fg:         #1f1f1f;
  --awp-muted:      #555555;
  --awp-accent:     #173dff;
  --awp-accent-2:   #0d27a3;
  --awp-accent-fg:  #ffffff;
  --awp-radius:     8px;
}

.awp-am__label {
  display: inline-block;
  transform: translateY(2px);
  background-color: var(--awp-bg);
  color: var(--awp-muted);
  font-size: .85em;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  font-weight: 600;
  border-radius: var(--awp-radius) var(--awp-radius) 0 0;
  padding: 8px 16px 0;
  border-left: 1px solid var(--awp-base);
  border-right: 1px solid var(--awp-base);
  border-top: 1px solid var(--awp-base);
  z-index: 1;
  position: relative;
}

.awp-am {
  display: grid;
  grid-template-columns: 60px auto;
  align-items: center;
  gap: 12px;
  padding: 24px;
  border: 1px solid var(--awp-base);
  border-radius: 0 var(--awp-radius) var(--awp-radius) var(--awp-radius);
  background-color: var(--awp-bg);
  color: var(--awp-fg);
  transition: box-shadow 0.15s;
}
.awp-am.is-clickable { cursor: pointer; user-select: none; }
.awp-am.is-clickable:hover { box-shadow: 0 6px 16px -8px rgba(0,0,0,0.18); }
.awp-am.is-clickable:focus-visible {
  outline: 2px solid var(--awp-accent);
  outline-offset: 2px;
}

.awp-am__logo {
  display: flex; align-items: center; justify-content: center;
  width: 60px; height: 60px;
}
.awp-am__logo img {
  max-width: 60px;
  max-height: 60px;
  border-radius: 8px;
  display: block;
  object-fit: contain;
}
.awp-am__logo-placeholder {
  width: 60px; height: 60px;
  border-radius: 8px;
  border: 1px dashed var(--awp-base);
  display: flex; align-items: center; justify-content: center;
  color: var(--awp-muted);
  font-size: 24px;
}

.awp-am__content { min-width: 0; }
.awp-am__name {
  font-weight: 700;
  font-size: 1.2em;
  margin-bottom: 0.2em;
  line-height: 1.2;
}
.awp-am__advantage {
  color: var(--awp-muted);
  margin: 0;
  font-size: .9em;
  font-weight: 500;
}

.awp-am__link {
  grid-column: 1 / -1;
  margin-top: 16px;
  justify-self: stretch;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
}

.awp-am__code {
  display: block;
  font-size: 0.8125rem;
  color: var(--awp-muted);
  text-align: center;
  line-height: 1.3;
}
.awp-am__code strong {
  color: var(--awp-fg);
  font-weight: 700;
}

.awp-am__btn {
  display: inline-block;
  padding: 10px 20px;
  background-color: var(--awp-accent);
  color: var(--awp-accent-fg) !important;
  text-decoration: none !important;
  border-radius: var(--awp-radius);
  border: 0;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  font: inherit;
  font-weight: 600;
  line-height: 1.2;
  text-align: center;
}
.awp-am__btn::after {
  display: inline-block;
  content: "";
  margin-left: .25em;
  width: .8em;
  height: .8em;
  aspect-ratio: 1;
  clip-path: shape(from 62.5% 0%, arc by 0% 12.5% of 6.25% large ccw, hline by 16.15%, line to 39.34% 51.84%, arc by 8.85% 8.85% of 6.25% small ccw, line to 87.5% 21.35%, vline to 37.5%, arc by 12.5% 0% of 6.25% large ccw, vline to 6.25%, arc by -6.25% -6.25% of 6.25% small ccw, hline to 62.5%, close, move to 15.63% 6.25%, arc by -15.63% 15.63% of 15.63% small ccw, vline by 62.5%, arc by 15.63% 15.63% of 15.63% small ccw, hline by 62.5%, arc by 15.63% -15.63% of 15.63% small ccw, vline to 62.5%, arc by -12.5% 0% of 6.25% large ccw, vline by 21.88%, arc by -3.13% 3.13% of 3.13% small cw, hline to 15.63%, arc by -3.13% -3.13% of 3.13% small cw, vline to 21.88%, arc by 3.13% -3.13% of 3.13% small cw, hline by 21.88%, arc by 0% -12.5% of 6.25% large ccw, hline to 15.63%, close);
  vertical-align: -.075em;
  background-color: currentColor;
}
.awp-am__btn:hover,
.awp-am__btn.is-hover,
.is-clickable:hover .awp-am__btn,
.is-clickable:focus-visible .awp-am__btn {
  background-color: var(--awp-accent-2);
  color: var(--awp-accent-hover-fg, var(--awp-accent-fg)) !important;
}
.awp-am__btn:focus-visible {
  outline: 2px solid var(--awp-accent);
  outline-offset: 2px;
}

/* ≥ 490px : passage en mode horizontal */
@container awp-encart (min-width: 490px) {
  .awp-am {
    grid-template-columns: 60px 1fr auto;
  }
  .awp-am__link {
    grid-column: auto;
    margin-top: 0;
    flex-direction: column;
    align-items: stretch;
    justify-content: center;
  }
}

/* ──────────────────────────────────────────────────────────
   Admin-only — cadre simulant un fond de site pour l'aperçu
   ────────────────────────────────────────────────────────── */
.encart-preview-frame {
  margin-top: 16px;
  padding: 16px;
  background-color: #eef2f7;
  border-radius: 10px;
  border: 1px dashed #c8d0db;
  resize: horizontal;
  overflow: auto;
  min-width: 280px;
  max-width: 100%;
}
html.dark .encart-preview-frame {
  background-color: #1d2330;
  border-color: #2a3343;
}
.encart-preview-frame .awp-am__container {
  margin: 0;
}
.encart-preview-resize-hint {
  margin-top: 8px;
  font-size: 0.75rem;
  color: hsl(var(--muted-foreground));
  text-align: center;
}
