/* ============================================
   ROUTE D'OR — Widget de location (ro_rental)
   Aligné sur les variables du thème (_variables.css)
   ============================================ */

.ro-rental {
  font-family: var(--ro-font-body, sans-serif);
  color: var(--ro-text, #392d24);
}

/* ── Paire d'actions : Acheter | Louer ───── */
/* Le JS déplace le bouton « Louer » dans .add, aux côtés du bouton panier. */

.ro-product__qty-row .add.ro-rental-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--ro-space-sm, .5rem);
  align-items: stretch;
}

/* Le thème impose width:100% au bouton panier : en mode deux actions, c'est
   le flex qui doit répartir la largeur, sinon le bouton « Louer » déborde. */
#main.ro-product-page .product-quantity .add.ro-rental-actions .add-to-cart,
.ro-product__qty-row .add.ro-rental-actions > .btn {
  width: auto;
  flex: 1 1 0;
  min-width: 0;
}

.ro-rental__toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--ro-space-xs, .25rem);
  /* Aligné sur la hauteur du bouton panier du thème (52px). */
  min-height: 52px;
  padding: var(--ro-space-sm, .5rem) var(--ro-space-md, 1rem);
  border: 2px solid var(--ro-brown, #392d24);
  border-radius: var(--ro-radius-md, 8px);
  background: transparent;
  color: var(--ro-brown, #392d24);
  font-family: inherit;
  font-size: var(--ro-text-base, 1rem);
  font-weight: var(--ro-font-bold, 700);
  line-height: 1.2;
  cursor: pointer;
  transition: background var(--ro-transition-fast, 150ms ease),
              color var(--ro-transition-fast, 150ms ease);
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}

.ro-rental__toggle:hover,
.ro-rental__toggle--active {
  background: var(--ro-brown, #392d24);
  color: var(--ro-beige-light, #f5f0e8);
}

.ro-rental__toggle-icon {
  flex: none;
}

/* ── Panneau dépliant ────────────────────── */

.ro-rental__panel {
  box-sizing: border-box;
  max-width: 100%;
  margin-top: var(--ro-space-md, 1rem);
  padding: var(--ro-space-lg, 1.5rem);
  background: var(--ro-bg-card, #fff);
  border: 1px solid var(--ro-border, #e0dbd3);
  border-radius: var(--ro-radius-lg, 12px);
  box-shadow: var(--ro-shadow-md, 0 4px 6px rgba(57, 45, 36, .07));
  opacity: 0;
  transform: translateY(-6px);
  transition: opacity var(--ro-transition-base, 250ms ease),
              transform var(--ro-transition-base, 250ms ease);
}

.ro-rental__panel--open {
  opacity: 1;
  transform: none;
}

@media (prefers-reduced-motion: reduce) {
  .ro-rental__panel { transition: none; opacity: 1; transform: none; }
}

/* ── En-tête du panneau ──────────────────── */

.ro-rental__header {
  margin-bottom: var(--ro-space-md, 1rem);
}

/* ── Grille tarifaire ────────────────────── */

.ro-rental__tariffs {
  list-style: none;
  margin: 0 0 var(--ro-space-md, 1rem);
  padding: 0;
  border: 1px solid var(--ro-border, #e0dbd3);
  border-radius: var(--ro-radius-md, 8px);
  overflow: hidden;
}

.ro-rental__tariff {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--ro-space-xs, .25rem) var(--ro-space-sm, .5rem);
  padding: var(--ro-space-sm, .5rem) var(--ro-space-md, 1rem);
  border-bottom: 1px solid var(--ro-border-light, #eeebe5);
  font-size: var(--ro-text-sm, .875rem);
}

.ro-rental__tariff:last-child { border-bottom: 0; }

.ro-rental__tariff--deal {
  background: var(--ro-beige-light, #f5f0e8);
}

.ro-rental__tariff-label {
  flex: 1 1 auto;
  font-weight: var(--ro-font-medium, 500);
}

.ro-rental__tariff-price {
  font-weight: var(--ro-font-bold, 700);
  font-size: var(--ro-text-base, 1rem);
  color: var(--ro-brown, #392d24);
}

.ro-rental__tariff-instead {
  flex: 1 1 100%;
  font-size: var(--ro-text-xs, .75rem);
  color: var(--ro-text-muted, #555);
}

.ro-rental__tariff-instead del { opacity: .7; }

.ro-rental__tariff-instead strong {
  color: var(--ro-orange-dark, #c47a2e);
}

.ro-rental__title {
  margin: 0 0 var(--ro-space-xs, .25rem);
  font-family: var(--ro-font-heading, Georgia, serif);
  font-size: var(--ro-text-md, 1.125rem);
  color: var(--ro-heading, #392d24);
}

.ro-rental__intro {
  margin: 0;
  font-size: var(--ro-text-sm, .875rem);
  line-height: var(--ro-leading-snug, 1.35);
  color: var(--ro-text-muted, #555);
}

/* Contenu réservé aux lecteurs d'écran */
.ro-rental__sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Piège à robots : invisible et hors flux, mais pas display:none
   (certains robots ignorent les champs masqués de cette façon). */
.ro-rental__hp {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

/* ── Calendrier ──────────────────────────── */

.ro-rental__loading {
  padding: var(--ro-space-lg, 1.5rem) 0;
  text-align: center;
  font-size: var(--ro-text-sm, .875rem);
  color: var(--ro-text-light, #878787);
}

.ro-rental__month {
  max-width: 340px;
  margin: 0 auto;
}

.ro-rental__month-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--ro-space-sm, .5rem);
}

.ro-rental__month-title {
  font-weight: var(--ro-font-semibold, 600);
  font-size: var(--ro-text-base, 1rem);
  text-transform: capitalize;
}

.ro-rental__nav {
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--ro-border, #e0dbd3);
  border-radius: var(--ro-radius-full, 9999px);
  background: var(--ro-white, #fff);
  color: var(--ro-brown, #392d24);
  font-size: var(--ro-text-md, 1.125rem);
  line-height: 1;
  cursor: pointer;
  transition: background var(--ro-transition-fast, 150ms ease);
}

.ro-rental__nav:hover:not(:disabled) {
  background: var(--ro-beige-light, #f5f0e8);
}

.ro-rental__nav:disabled {
  opacity: .3;
  cursor: not-allowed;
}

.ro-rental__weekdays,
.ro-rental__days {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 3px;
}

.ro-rental__weekday {
  padding: var(--ro-space-xs, .25rem) 0;
  text-align: center;
  font-size: var(--ro-text-xs, .75rem);
  font-weight: var(--ro-font-semibold, 600);
  color: var(--ro-text-light, #878787);
  text-transform: uppercase;
}

.ro-rental__day {
  aspect-ratio: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 1px solid transparent;
  border-radius: var(--ro-radius-sm, 4px);
  background: var(--ro-beige-light, #f5f0e8);
  color: var(--ro-text, #392d24);
  font-size: var(--ro-text-sm, .875rem);
  font-family: inherit;
  cursor: pointer;
  transition: background var(--ro-transition-fast, 150ms ease);
}

@supports not (aspect-ratio: 1 / 1) {
  .ro-rental__day { height: 36px; }
}

.ro-rental__day:hover:not(:disabled) {
  background: var(--ro-gold-light, #ffe14d);
}

.ro-rental__day:focus-visible,
.ro-rental__nav:focus-visible,
.ro-rental__toggle:focus-visible {
  outline: 2px solid var(--ro-orange, #e28f3b);
  outline-offset: 2px;
}

.ro-rental__day--empty {
  background: transparent;
  cursor: default;
}

/* Fond gris franc plutôt qu'un simple texte barré : un jour pris doit se
   distinguer d'un coup d'œil d'un jour libre. */
.ro-rental__day--disabled,
.ro-rental__day:disabled {
  background: #eae7e1;
  color: #9c948a;
  text-decoration: line-through;
  cursor: not-allowed;
}

.ro-rental__day--today {
  border-color: var(--ro-orange, #e28f3b);
  font-weight: var(--ro-font-semibold, 600);
}

/* Clic refusé : sans retour visuel, l'utilisateur croit que rien ne répond. */
.ro-rental__day--rejected {
  animation: ro-rental-shake 400ms ease;
  background: #fdecea;
  color: #a4342a;
}

@keyframes ro-rental-shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-3px); }
  75% { transform: translateX(3px); }
}

@media (prefers-reduced-motion: reduce) {
  .ro-rental__day--rejected { animation: none; }
}

.ro-rental__day--in-range {
  background: var(--ro-gold-light, #ffe14d);
}

.ro-rental__day--start,
.ro-rental__day--end {
  background: var(--ro-gold, #ffd304);
  color: var(--ro-brown, #392d24);
  font-weight: var(--ro-font-bold, 700);
}

/* ── Légende ─────────────────────────────── */

.ro-rental__legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--ro-space-md, 1rem);
  margin: var(--ro-space-sm, .5rem) 0 0;
  font-size: var(--ro-text-xs, .75rem);
  color: var(--ro-text-muted, #555);
}

.ro-rental__legend-item {
  display: inline-flex;
  align-items: center;
  gap: var(--ro-space-xs, .25rem);
}

.ro-rental__swatch {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  display: inline-block;
}

.ro-rental__swatch--busy { background: #eae7e1; }
.ro-rental__swatch--selected { background: var(--ro-gold, #ffd304); }

/* ── Récapitulatif ───────────────────────── */

.ro-rental__summary {
  margin-top: var(--ro-space-md, 1rem);
  padding: var(--ro-space-md, 1rem);
  background: var(--ro-beige-light, #f5f0e8);
  border-radius: var(--ro-radius-md, 8px);
}

.ro-rental__summary-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--ro-space-sm, .5rem);
  padding: 2px 0;
  font-size: var(--ro-text-sm, .875rem);
}

.ro-rental__summary-row--total {
  margin-top: var(--ro-space-xs, .25rem);
  padding-top: var(--ro-space-sm, .5rem);
  border-top: 1px solid var(--ro-beige-dark, #d9d0c0);
  font-size: var(--ro-text-md, 1.125rem);
  font-weight: var(--ro-font-bold, 700);
}

.ro-rental__summary-label { color: var(--ro-text-muted, #555); }
.ro-rental__summary-value { font-weight: var(--ro-font-semibold, 600); text-align: right; }

.ro-rental__deposit {
  margin: var(--ro-space-sm, .5rem) 0 0;
  font-size: var(--ro-text-xs, .75rem);
  color: var(--ro-text-muted, #555);
}

/* Forfait appliqué : sans ce rappel, l'effort tarifaire passe inaperçu. */
.ro-rental__applied {
  margin: var(--ro-space-sm, .5rem) 0 0;
  padding: var(--ro-space-xs, .25rem) var(--ro-space-sm, .5rem);
  background: var(--ro-gold, #ffd304);
  border-radius: var(--ro-radius-sm, 4px);
  font-size: var(--ro-text-xs, .75rem);
  font-weight: var(--ro-font-semibold, 600);
  color: var(--ro-brown, #392d24);
}

/* ── Suggestion de forfait ───────────────── */

.ro-rental__upsell {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--ro-space-sm, .5rem);
  margin-top: var(--ro-space-sm, .5rem);
  padding: var(--ro-space-sm, .5rem) var(--ro-space-md, 1rem);
  background: #fff8dd;
  border: 1px solid var(--ro-gold, #ffd304);
  border-radius: var(--ro-radius-md, 8px);
  font-size: var(--ro-text-sm, .875rem);
  color: var(--ro-brown, #392d24);
}

.ro-rental__upsell > span { flex: 1 1 200px; }

.ro-rental__upsell-btn {
  flex: none;
  padding: var(--ro-space-xs, .25rem) var(--ro-space-md, 1rem);
  min-height: 36px;
  border: 0;
  border-radius: var(--ro-radius-sm, 4px);
  background: var(--ro-brown, #392d24);
  color: var(--ro-beige-light, #f5f0e8);
  font-family: inherit;
  font-weight: var(--ro-font-semibold, 600);
  cursor: pointer;
}

.ro-rental__upsell-btn:hover { background: var(--ro-brown-dark, #2a1f18); }

/* ── Champs ──────────────────────────────── */

.ro-rental__fields {
  margin-top: var(--ro-space-md, 1rem);
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--ro-space-sm, .5rem) var(--ro-space-md, 1rem);
}

/* Classe explicite plutôt qu'un :nth-child fragile : le champ quantité
   n'est rendu que si le matériel a plusieurs exemplaires. */
.ro-rental__field--full {
  grid-column: 1 / -1;
}

.ro-rental__label {
  display: block;
  margin-bottom: 2px;
  font-size: var(--ro-text-sm, .875rem);
  font-weight: var(--ro-font-medium, 500);
  color: var(--ro-text, #392d24);
}

.ro-rental__label abbr {
  color: var(--ro-orange-dark, #c47a2e);
  text-decoration: none;
}

.ro-rental .form-control {
  width: 100%;
  font-family: inherit;
}

/* ── Message & action ────────────────────── */

.ro-rental__message {
  margin-top: var(--ro-space-md, 1rem);
  padding: var(--ro-space-sm, .5rem) var(--ro-space-md, 1rem);
  border-radius: var(--ro-radius-sm, 4px);
  font-size: var(--ro-text-sm, .875rem);
  line-height: var(--ro-leading-normal, 1.6);
}

.ro-rental__message--error {
  background: #fdecea;
  color: #a4342a;
  border: 1px solid #f5c6c2;
}

.ro-rental__message--success {
  background: #e8f5e9;
  color: #1e5c25;
  border: 1px solid #c3e6c8;
}

.ro-rental__submit {
  width: 100%;
  margin-top: var(--ro-space-md, 1rem);
  font-weight: var(--ro-font-semibold, 600);
}

.ro-rental__submit:disabled {
  opacity: .5;
  cursor: not-allowed;
}

.ro-rental__notice {
  margin: var(--ro-space-sm, .5rem) 0 0;
  text-align: center;
  font-size: var(--ro-text-xs, .75rem);
  color: var(--ro-text-light, #878787);
}

/* ── Responsive ──────────────────────────── */
/* Points de rupture alignés sur ceux du thème (768 / 576 / 375). */

@media (max-width: 768px) {
  .ro-rental__panel {
    padding: var(--ro-space-md, 1rem);
  }

  .ro-rental__header {
    flex-direction: column;
    gap: var(--ro-space-sm, .5rem);
  }

  .ro-rental__price-tag {
    align-self: flex-start;
    text-align: left;
  }

  .ro-rental__fields {
    grid-template-columns: 1fr;
  }

  /* Le calendrier occupe toute la largeur disponible sur mobile. */
  .ro-rental__month {
    max-width: none;
  }

  /* Deux actions empilées : côte à côte, les libellés seraient illisibles. */
  #main.ro-product-page .product-quantity .add.ro-rental-actions .add-to-cart,
  .ro-product__qty-row .add.ro-rental-actions > .btn {
    flex: 1 1 100%;
  }

  /* iOS zoome sur un champ dont la police fait moins de 16px : la fiche
     produit sauterait à chaque focus. */
  .ro-rental input.form-control,
  .ro-rental textarea.form-control {
    font-size: 16px;
  }

  /* Cible tactile confortable même quand la largeur écrase les cellules. */
  .ro-rental__day {
    min-height: 40px;
  }
}

@media (max-width: 576px) {
  .ro-rental__panel {
    padding: var(--ro-space-sm, .5rem);
  }

  .ro-rental__weekdays,
  .ro-rental__days {
    gap: 2px;
  }

  .ro-rental__legend {
    gap: var(--ro-space-sm, .5rem);
  }
}

@media (max-width: 375px) {
  .ro-rental__day {
    font-size: var(--ro-text-xs, .75rem);
    min-height: 38px;
  }

  .ro-rental__month-title {
    font-size: var(--ro-text-sm, .875rem);
  }
}
