/* ==========================================================================
   ALFATOUR — moteur de recherche hôtels (accueil)
   Portage du moteur Votre Voyage (hotel-engine.css) sur les tokens AlfaTour :
   même structure (barre 4 zones, panneaux calendrier / destination / chambres),
   palette rouge de la marque.
   Markup : views/hotels/inc/inc-search-hotels.ejs — piloté par hotel-engine.js.
   ========================================================================== */

.he {
  --he-primary: var(--af-red);
  --he-primary-dark: var(--af-red-hover);
  --he-primary-soft: var(--af-red-soft);
  --he-primary-ink: var(--af-red-dark);
  --he-ink: var(--af-ink);
  --he-muted: var(--af-muted);
  --he-line: #d9dfe6;
  --he-line-soft: #e8ecf1;
  --he-placeholder: #8c96a3;
  --he-bg-soft: #f4f6f9;
  --he-radius: var(--af-radius);
  --he-shadow: 0 12px 40px rgba(20, 33, 46, .18);
  position: relative;
  font-family: inherit;
}

.he *,
.he *::before,
.he *::after { box-sizing: border-box; }

/* Barre : 4 zones sur desktop, empilées sur mobile */
.he-bar { display: grid; grid-template-columns: 1fr; gap: 8px; }

@media (min-width: 992px) {
  .he-bar {
    grid-template-columns: minmax(0, 1.35fr) minmax(0, 1.3fr) minmax(0, 1.45fr) auto;
    gap: 0;
    border: 1px solid var(--he-line);
    border-radius: var(--he-radius);
    background: #fff;
  }

  /* Séparateurs courts entre les zones, plutôt qu'une bordure pleine hauteur */
  .he-bar > .he-field + .he-field::before {
    content: "";
    position: absolute;
    left: 0;
    top: 14px;
    bottom: 14px;
    width: 1px;
    background: var(--he-line-soft);
    z-index: 1;
  }

  .he-bar .he-trigger { border: 0; border-radius: 0; }
  .he-bar > .he-field:first-child .he-trigger { border-radius: var(--he-radius) 0 0 var(--he-radius); }
  .he-submit-wrap { padding: 6px; }

  /* Fiche hôtel : pas de destination, 2 zones + bouton sur desktop */
  .he--fiche .he-bar { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; }
}

.he-field { position: relative; min-width: 0; }

.he-trigger {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 44px;
  padding: 10px 18px;
  background: #fff;
  border: 1px solid var(--he-line);
  border-radius: var(--he-radius);
  font: inherit;
  color: var(--he-ink);
  text-align: left;
  cursor: pointer;
  transition: background-color .15s;
}

.he-trigger:hover { background: #f9fafb; }
.he-trigger:focus-visible { outline: 2px solid var(--he-primary); outline-offset: -2px; }
.he-field.is-open .he-trigger { background: #f9fafb; box-shadow: inset 0 -2px 0 var(--he-primary); }

/* Icônes au trait fin, couleur de la marque (stroke-width CSS prime sur l'attribut SVG) */
.he-icon { width: 18px; height: 18px; flex: none; color: var(--he-primary); stroke-width: 1.6; }
.he-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.he-label { font-size: 12px; font-weight: 500; line-height: 1.2; color: var(--he-muted); letter-spacing: .01em; }
.he-value { font-size: 15px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 1.4; }
.he-value.is-placeholder { font-weight: 400; color: var(--he-placeholder); }

/* Destination : le champ texte est la zone cliquable */
.he-dest .he-trigger { cursor: text; }
.he-input {
  border: 0;
  padding: 0;
  margin: 0;
  width: 100%;
  background: transparent;
  font: inherit;
  font-size: 15px;
  font-weight: 500;
  line-height: 1.4;
  color: var(--he-ink);
  outline: none;
}
.he-input::placeholder { font-weight: 400; color: var(--he-placeholder); opacity: 1; }

.he-clear {
  flex: none;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  display: none;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.he-clear:hover { background: var(--he-line-soft); }
.he-dest.has-value .he-clear { display: inline-flex; }

.he-error { display: none; margin: 6px 4px 0; font-size: 13px; font-weight: 500; color: #b42318; }
.he-field.has-error .he-error { display: block; }
.he-field.has-error .he-trigger { box-shadow: inset 0 0 0 2px #b42318; }

.he-submit {
  width: 100%;
  height: 44px;
  padding: 0 22px;
  border: 0;
  border-radius: var(--af-radius-sm);
  background: var(--he-primary);
  color: #fff;
  font: inherit;
  font-size: 15px;
  font-weight: 500;
  letter-spacing: .01em;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  transition: background-color .15s;
}
.he-submit svg { width: 16px; height: 16px; flex: none; }
.he-submit:hover { background: var(--he-primary-dark); }
.he-submit:disabled { opacity: .7; cursor: wait; }

/* Panneaux déroulants */
.he-panel {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 1060;
  display: none;
  background: #fff;
  border-radius: 16px;
  box-shadow: var(--he-shadow);
  border: 1px solid var(--he-line-soft);
}
.he-field.is-open > .he-panel { display: block; }
.he-panel-head { display: none; }
.he-panel-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 20px; border-top: 1px solid var(--he-line-soft); }
.he-panel-foot .he-summary { font-size: 14px; }
.he-done {
  min-height: 38px;
  padding: 0 22px;
  border: 0;
  border-radius: 10px;
  background: var(--he-primary);
  color: #fff;
  font: inherit;
  font-weight: 500;
  cursor: pointer;
}
.he-done:hover { background: var(--he-primary-dark); }
.he-link { border: 0; background: none; padding: 8px 4px; font: inherit; font-weight: 500; color: var(--he-primary); cursor: pointer; }
.he-link:hover { text-decoration: underline; }

/* Autocomplete */
.he-panel--dest { width: min(440px, 100%); min-width: 100%; padding: 8px 0; max-height: 420px; overflow-y: auto; }
@media (min-width: 992px) { .he-panel--dest { width: 440px; } }
.he-group { padding: 10px 16px 4px; font-size: 13px; font-weight: 500; }
.he-options { list-style: none; margin: 0; padding: 0; }
.he-option { display: flex; align-items: center; gap: 12px; padding: 10px 16px; cursor: pointer; min-height: 44px; }
.he-option[aria-selected="true"],
.he-option:hover { background: var(--he-primary-soft); }
.he-option-icon {
  width: 36px;
  height: 36px;
  flex: none;
  border-radius: 10px;
  background: var(--he-bg-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--he-primary);
}
.he-option-icon svg { width: 18px; height: 18px; }
.he-option-main { display: flex; flex-direction: column; min-width: 0; }
.he-option-title { font-size: 15px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.he-option-title mark { background: none; color: var(--he-primary-ink); font-weight: 800; padding: 0; }
.he-option-sub { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--he-muted); }
.he-status { padding: 14px 16px; font-size: 14px; }

/* Calendrier */
.he-panel--dates { padding: 16px 20px 0; width: max-content; }
.he-field--dates:not(:first-child) .he-panel--dates { left: 50%; transform: translateX(-50%); }
.he-cal-nav { position: relative; }
.he-cal-arrow {
  position: absolute;
  top: -4px;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 1;
  color: var(--he-ink);
}
.he-cal-arrow:hover:not(:disabled) { background: var(--he-bg-soft); }
.he-cal-arrow:disabled { opacity: .3; cursor: default; }
.he-cal-arrow--prev { left: -8px; }
.he-cal-arrow--next { right: -8px; }
.he-months { display: flex; gap: 32px; }
.he-month { width: 296px; }
.he-month-title { text-align: center; font-weight: 500; font-size: 16px; margin: 4px 0 12px; text-transform: capitalize; }
.he-weekdays,
.he-days { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.he-weekdays span { text-align: center; font-size: 12px; font-weight: 500; padding-bottom: 6px; }
.he-day {
  height: 42px;
  border: 0;
  background: transparent;
  padding: 0;
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  position: relative;
  color: var(--he-ink);
}
.he-day span {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  margin: 1px auto;
  border-radius: 50%;
  position: relative;
  z-index: 1;
}
.he-day:hover:not(:disabled) span { box-shadow: inset 0 0 0 1.5px var(--he-primary); }
.he-day:disabled { color: #a7b1bd; cursor: default; text-decoration: line-through; text-decoration-color: rgba(167, 177, 189, .6); }
.he-day.is-today span { font-weight: 800; }
.he-day.is-today span::after {
  content: "";
  position: absolute;
  bottom: 5px;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: currentColor;
}
.he-day.in-range::before { content: ""; position: absolute; inset: 1px 0; background: var(--he-primary-soft); }
.he-day.is-start::before { left: 50%; }
.he-day.is-end::before { right: 50%; }
.he-day.is-start.is-end::before { display: none; }
.he-day.is-start span,
.he-day.is-end span { background: var(--he-primary); color: #fff; font-weight: 500; }
.he-cal-hint { text-align: center; font-size: 13px; padding: 4px 0 12px; color: var(--he-muted); }

/* Chambres & occupation */
.he-panel--guests { right: 0; left: auto; width: 380px; }
.he-rooms { max-height: 440px; overflow-y: auto; padding: 4px 20px; }
.he-room { padding: 14px 0; border-bottom: 1px solid var(--he-line-soft); }
.he-room:last-child { border-bottom: 0; }
.he-room-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.he-room-title { font-weight: 500; font-size: 15px; }
.he-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 44px; }
.he-row-label { display: flex; flex-direction: column; }
.he-row-label strong { font-size: 15px; font-weight: 500; }
.he-row-label small { font-size: 13px; color: var(--he-muted); }
.he-stepper { display: flex; align-items: center; gap: 4px; }
.he-step {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1.5px solid var(--he-line);
  background: #fff;
  color: var(--he-primary-ink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
}
.he-step svg { width: 14px; height: 14px; }
.he-step:hover:not(:disabled) { border-color: var(--he-primary); background: var(--he-primary-soft); }
.he-step:disabled { color: #a7b1bd; border-color: var(--he-line-soft); cursor: default; }
.he-count { width: 32px; text-align: center; font-weight: 500; font-size: 16px; }
.he-ages { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin: 4px 0 2px; }
.he-age label { display: block; font-size: 12px; font-weight: 500; margin-bottom: 4px; }
.he-age select {
  width: 100%;
  height: 40px;
  padding: 0 8px;
  border: 1px solid var(--he-line);
  border-radius: 8px;
  background: #fff;
  font: inherit;
  font-size: 14px;
}
.he-age select.is-invalid { border-color: #b42318; box-shadow: 0 0 0 1px #b42318; }
.he-ages-help { grid-column: 1 / -1; font-size: 12px; color: var(--he-muted); }
.he-add-room { display: flex; align-items: center; gap: 8px; margin: 4px 20px 12px; }
.he-add-room svg { width: 16px; height: 16px; }

/* Liste de résultats : récapitulatif repliable sur mobile */
.he-recap { display: none; }

/* Mobile : panneaux plein écran */
@media (max-width: 991.98px) {
  .he-field.is-open > .he-panel {
    position: fixed;
    inset: 0;
    top: 0;
    z-index: 1080;
    border-radius: 0;
    border: 0;
    width: auto;
    max-height: none;
    display: flex;
    flex-direction: column;
    transform: none;
  }
  .he-panel-head {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--he-line-soft);
    flex: none;
  }
  .he-panel-head strong { font-size: 17px; flex: 1; text-align: center; margin-right: 44px; }
  .he-close {
    width: 44px;
    height: 44px;
    border: 0;
    background: transparent;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
  }
  .he-panel--dest .he-mobile-input { display: flex; }
  .he-panel--dest { padding: 0; }
  .he-panel--dest .he-list { flex: 1; min-height: 0; overflow-y: auto; }
  .he-panel--dates { padding: 0; }
  .he-panel--dates .he-cal-body { flex: 1; min-height: 0; overflow-y: auto; padding: 8px 16px; }
  .he-months { flex-direction: column; gap: 24px; }
  .he-month { width: 100%; }
  .he-cal-arrow { display: none; }
  .he-panel--guests .he-rooms { flex: 1; min-height: 0; max-height: none; }
  .he-panel-foot { flex: none; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); box-shadow: 0 -4px 12px rgba(20, 33, 46, .06); }
  .he-done { flex: 1; min-height: 38px; max-width: 220px; }
  body.he-locked { overflow: hidden; }
  /* Panneau ouvert : l'en-tête collant et les widgets flottants (WhatsApp, chat)
     passaient par-dessus la tête et le pied du panneau plein écran */
  body.he-locked .site-header { z-index: auto; position: static; }
  body.he-locked > [id*="whatsapp" i], body.he-locked > [class*="whatsapp" i],
  body.he-locked > [id*="wa-" i], body.he-locked > [class*="wa-" i],
  body.he-locked > [id*="chat" i], body.he-locked > [class*="chat" i] { display: none !important; }

  .he--collapsible .he-recap {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    min-height: 44px;
    padding: 8px 8px 8px 16px;
    border: 1px solid var(--he-line);
    border-radius: 999px;
    background: #fff;
    font: inherit;
    text-align: left;
    cursor: pointer;
  }
  .he-recap-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
  .he-recap-text strong { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .he-recap-text span { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .he-recap-btn {
    width: 40px;
    height: 40px;
    flex: none;
    border-radius: 50%;
    background: var(--he-primary);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
  .he--collapsible .he-bar { display: none; margin-top: 12px; }
  .he--collapsible.is-expanded .he-bar { display: grid; }
}

.he-mobile-input {
  display: none;
  align-items: center;
  gap: 10px;
  margin: 12px 16px 4px;
  padding: 0 12px;
  height: 44px;
  border: 2px solid var(--he-primary);
  border-radius: var(--he-radius);
}
.he-mobile-input .he-input { font-size: 16px; }

/* Focus : le contour du champ ouvert suffit pour la saisie ; les boutons gardent
   un contour visible aux couleurs du moteur. */
.he .he-input:focus,
.he .he-input:focus-visible { outline: none; box-shadow: none; }
.he .he-bar button:focus-visible,
.he .he-panel button:focus-visible,
.he .he-panel select:focus-visible { outline: 2px solid var(--he-primary); outline-offset: 2px; }
.he .he-bar .he-trigger:focus-visible { outline-offset: -2px; }
.he .he-trigger:focus-within { outline: 2px solid var(--he-primary); outline-offset: -2px; }

/* iOS zoome sur un champ de moins de 16 px */
@media (max-width: 767.98px) { .he-input { font-size: 16px; } }
