/* ==========================================================================
   OLESSEN – Recettes > Bouton, Modale, Grille produits (responsive)
   - Bouton "Produits de la recette" centré sans wrapper supplémentaire.
   - Style bouton primaire aligné au thème (variables + fallbacks).
   ========================================================================== */

/* ---------- Variables de thème (fallbacks sûrs) ---------- */
:root {
  --olrp-primary: var(--ps-primary, var(--btn-primary-bg, #2fb5d2));
  --olrp-on-primary: var(--ps-on-primary, #ffffff);
  --olrp-primary-hover: var(--ps-primary-600, #27a5bf);
  --olrp-primary-active: var(--ps-primary-700, #1f90a6);

  --olrp-surface: #ffffff;
  --olrp-border: rgba(0,0,0,.12);

  --olrp-shadow-sm: 0 2px 6px rgba(0,0,0,.10);
  --olrp-shadow-md: 0 4px 10px rgba(0,0,0,.15);
  --olrp-shadow-lg: 0 22px 60px rgba(0,0,0,.25);
}

/* ==========================================================================
   BOUTON "Produits de la recette"
   ========================================================================== */
.olrp-open-link {
  display: block;                /* occupe une ligne complète */
  width: fit-content;            /* réduit au contenu */
  margin: 0.8rem auto 1.2rem;    /* centre horizontalement */
  text-align: center;

  padding: 0.65rem 1.2rem;
  font-weight: 600;
  font-size: 0.95rem;
  line-height: 1;
  border-radius: 8px;
  text-decoration: none;
  cursor: pointer;

  background-color: var(--olrp-primary);
  color: var(--olrp-on-primary);
  border: 1px solid var(--olrp-primary);
  box-shadow: var(--olrp-shadow-sm);
  transition: transform .15s ease, box-shadow .15s ease,
              background-color .15s ease, border-color .15s ease;
}
.olrp-open-link:hover {
  background-color: var(--olrp-primary-hover);
  border-color: var(--olrp-primary-hover);
  box-shadow: var(--olrp-shadow-md);
  transform: translateY(-1px);
}
.olrp-open-link:active {
  background-color: var(--olrp-primary-active);
  border-color: var(--olrp-primary-active);
  transform: translateY(0);
}
.olrp-open-link:focus {
  outline: 2px solid rgba(47,181,210,.35);
  outline-offset: 2px;
}

/* En mobile : bouton 100% largeur */
@media (max-width: 575px) {
  .olrp-open-link {
    width: 100%;
  }
}

/* ==========================================================================
   MODALE
   ========================================================================== */
.olrp-modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  display: none;
  align-items: center; justify-content: center;
  z-index: 10000;
}
.olrp-modal-overlay.is-open { display: flex; }

.olrp-modal {
  width: min(860px, 94vw);
  max-height: 92vh;
  background: var(--olrp-surface);
  border-radius: 14px;
  box-shadow: var(--olrp-shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
@media (max-width: 575px) {
  .olrp-modal { width: 100vw; height: 94vh; border-radius: 0; }
}

.olrp-modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: .9rem 1rem;
  border-bottom: 1px solid var(--olrp-border);
}
.olrp-modal-title { font-weight: 800; font-size: 1.05rem; }
.olrp-close {
  border: 0; background: transparent; font-size: 1.4rem; line-height: 1;
  cursor: pointer; opacity: .7;
}
.olrp-close:hover { opacity: 1; }

.olrp-modal-body { padding: 1rem; overflow: auto; }

.olrp-modal-footer {
  border-top: 1px solid var(--olrp-border);
  padding: .75rem 1rem;
  display: flex; flex-wrap: wrap; gap: .5rem;
  justify-content: space-between; align-items: center;
  position: sticky; bottom: 0; background: var(--olrp-surface);
}

/* ==========================================================================
   GRILLE PRODUITS
   ========================================================================== */
.olessenrp-title {
  font-weight: 700; font-size: 1.02rem;
  margin: .2rem 0 .8rem 0;
}

.olessenrp-grid {
  --olessenrp-cols: 3;
  display: grid;
  grid-template-columns: repeat(var(--olessenrp-cols), minmax(0, 1fr));
  gap: 1rem;
}
@media (max-width: 991px) { .olessenrp-grid { grid-template-columns: repeat(2, minmax(0,1fr)); } }
@media (max-width: 575px) { .olessenrp-grid { grid-template-columns: 1fr; } }

.olessenrp-card {
  display: flex; flex-direction: column; height: 100%;
  border: 1px solid var(--olrp-border);
  border-radius: 10px;
  background: var(--olrp-surface);
  padding: .75rem;
  box-shadow: 0 2px 10px rgba(0,0,0,.04);
  transition: box-shadow .2s ease, transform .2s ease;
}
.olessenrp-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(0,0,0,.08);
}

.olrp-select { display: inline-flex; align-items: center; gap: .4rem; margin-bottom: .35rem; user-select: none; }
.olrp-check { width: 16px; height: 16px; }
.olrp-check-label { font-size: .85rem; opacity: .75; }

.olrp-qty { display: flex; align-items: center; gap: .35rem; margin: .35rem 0 .6rem; }
.olrp-qty button {
  width: 32px; height: 32px; border: 1px solid var(--olrp-border);
  border-radius: 8px; background: #fff; cursor: pointer;
}
.olrp-qty-input {
  width: 56px; text-align: center; height: 32px;
  border-radius: 8px; border: 1px solid var(--olrp-border);
}

.olessenrp-image { display: block; width: 100%; aspect-ratio: 4/3; border-radius: 8px; overflow: hidden; background: #f6f6f6; }
.olessenrp-image img { width: 100%; height: 100%; object-fit: cover; display: block; }

.olessenrp-name {
  margin-top: .6rem; color: inherit; text-decoration: none;
  font-weight: 600; font-size: .96rem; line-height: 1.3;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  min-height: calc(1.3 * 2 * 1em);
}
.olessenrp-name:hover { text-decoration: underline; }

.olessenrp-price { margin: .4rem 0 .6rem; font-weight: 800; font-size: 1rem; font-variant-numeric: tabular-nums; }

.olessenrp-btn {
  margin-top: auto;
  width: 100%;
  text-align: center;
  border-radius: 8px;
  padding: .55rem .75rem;
  font-weight: 700;
}

/* ==========================================================================
   FEEDBACK / TOASTS
   ========================================================================== */
.recipe-products.olessenrp--loading { position: relative; min-height: 42px; }
.recipe-products.olessenrp--loading::after {
  content: "Chargement…"; position: absolute; left: 0; top: 0; opacity: .7;
}

.olessenrp-error {
  padding: .75rem 1rem; border: 1px solid rgba(255,0,0,.25);
  background: rgba(255,0,0,.05); border-radius: 8px;
}

.olrp-toast-holder { position: fixed; right: 16px; bottom: 16px; z-index: 99999; }
.olrp-toast {
  color: #fff; padding: 10px 12px; margin-top: 8px;
  border-radius: 8px; box-shadow: var(--olrp-shadow-md);
  font-weight: 600; font-size: .95rem;
}

/* ======= Produit -> Recettes liées (grille compacte) ======= */
#olrp-related-recipes { margin-top: 2rem; }
#olrp-related-recipes .h3 { margin-bottom: .75rem; }

.olrp-recipes-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0,1fr));
  gap: .75rem;
}
@media (max-width: 991px) { .olrp-recipes-grid { grid-template-columns: repeat(2, minmax(0,1fr)); } }
@media (max-width: 575px) { .olrp-recipes-grid { grid-template-columns: 1fr; } }

.olrp-recipe-card {
  border: 1px solid rgba(0,0,0,.08);
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 2px 10px rgba(0,0,0,.04);
  transition: box-shadow .2s ease, transform .2s ease;
}
.olrp-recipe-card:hover { transform: translateY(-2px); box-shadow: 0 6px 18px rgba(0,0,0,.08); }

.olrp-recipe-link {
  display: block;
  padding: .8rem .9rem;
  text-decoration: none;
  color: inherit;
}
.olrp-recipe-title { font-weight: 700; line-height: 1.3; }
.olrp-recipe-sub { opacity: .7; font-size: .9rem; margin-top: .2rem; }
