/*
 * Reprend le formulaire "Nouvelle recherche" de l'app (NewSearch / NewSearchForm) et les tokens du thème
 * emt-components-v2 en mode pet-sitting (palette purple).
 */
.tps-search {
  --tps-purple: #ae59c6; /* purple.main / [600] */
  --tps-purple-hover: #dd7df9; /* purple[450] */
  --tps-purple-dark: #8a35a2;
  --tps-purple-50: #fbf1fe;
  --tps-purple-bg: #f7eef9;
  --tps-text: #34303e; /* greyGradient.main */
  --tps-text-strong: #1d1929; /* greyGradient[550] */
  --tps-label: #77757f; /* greyGradient.light */
  --tps-muted: #a5a3a9; /* greyGradient[250] */
  --tps-disabled: #8e8c94; /* greyGradient[300] */
  --tps-border: #e8e8ea; /* greyGradient[100] */
  --tps-grey-50: #f9f9f9;
  --tps-bg: #f6f6f6;
  --tps-error: #f42829;

  container-type: inline-size;
  width: 100%;
  max-width: 1152px;
  margin: 0 auto;
  color: var(--tps-text);
  font-family: 'Nunito Sans', 'Helvetica', 'Arial', sans-serif;
  font-size: 16px;
  line-height: 1.5;
  text-align: left;
}

/* Réserve la place avant l'exécution du JS (évite le décalage de mise en page) */
.tps-search:empty {
  min-height: 560px;
}
.tps-search[data-variant='light']:empty {
  min-height: 280px;
}

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

.tps-search svg {
  display: block;
  width: 1em;
  height: 1em;
  fill: currentColor;
}

.tps-search [hidden] {
  display: none !important;
}

/* ---------- Carte ---------- */

.tps-search__form {
  display: grid;
  grid-template-columns: 1fr;
  gap: 15px;
  margin: 0;
  padding: 30px;
  border-radius: 16px;
  background: var(--tps-bg);
  box-shadow: 0 4px 25px 0 #00000029, 0 -6px 8px 0 #00000014;
}

.tps-search__col {
  display: flex;
  flex-direction: column;
  gap: 15px;
  min-width: 0;
}

/* ---------- Options du shortcode ---------- */

/* bare="yes" : formulaire "nu", l'environnement (fond, marges, largeur) est géré par la page */
.tps-search--bare {
  max-width: none;
}

.tps-search--bare .tps-search__form {
  padding: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

/* titles="no" : titres masqués visuellement mais lus par les lecteurs d'écran.
   En position absolue, ils ne comptent plus dans les espacements. */
.tps-search--no-titles .tps-search__group,
.tps-search--no-titles .tps-search__col {
  position: relative;
}

.tps-search--no-titles .tps-search__title {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.tps-search__group {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.tps-search__title {
  margin: 0;
  color: var(--tps-text);
  font-size: 18px;
  font-weight: 700;
  line-height: 1.5;
}

/* ---------- Listes déroulantes (EmtSelect) ---------- */

.tps-select {
  position: relative;
  min-width: 0;
}

.tps-select__button {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
  margin: 0;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.tps-select__button:focus-visible {
  outline: 2px solid var(--tps-purple-dark);
  outline-offset: 2px;
}

.tps-select__value {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.tps-select__icon,
.tps-select__caret {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
}

/* Variante "service" : bouton violet avec icône (ServiceSection) */
.tps-select--service .tps-select__button {
  height: 56px;
  padding: 0 44px 0 56px;
  border: 0;
  border-radius: 18px;
  background: var(--tps-purple);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
}

.tps-select--service .tps-select__icon {
  left: 16px;
  font-size: 16px;
}

.tps-select--service .tps-select__caret {
  right: 16px;
  font-size: 18px;
}

/* Variante "field" : champ blanc à libellé flottant (MuiFilledInput) */
.tps-select--field .tps-select__button {
  height: 50px;
  padding: 21px 40px 4px 12px;
  border: 1px solid var(--tps-border);
  border-radius: 14px;
  background: #fff;
  color: var(--tps-text);
  font-size: 14px;
  font-weight: 700;
}

.tps-select--field.is-open .tps-select__button {
  border-color: var(--tps-muted);
}

.tps-select--field .tps-select__label {
  position: absolute;
  top: 0;
  left: 12px;
  right: 40px;
  overflow: hidden;
  color: var(--tps-label);
  font-size: 14px;
  font-weight: 400;
  line-height: 1;
  white-space: nowrap;
  text-overflow: ellipsis;
  pointer-events: none;
  transform: translateY(18px);
  transform-origin: left top;
  transition: transform 0.2s;
}

.tps-select--field.has-value .tps-select__label,
.tps-select--field.is-open .tps-select__label {
  right: auto;
  max-width: calc((100% - 52px) / 0.75);
  transform: translateY(8px) scale(0.75);
}

.tps-select--field .tps-select__caret {
  right: 12px;
  color: var(--tps-text-strong);
  font-size: 16px;
}

/* Menu (MuiMenu + MenuItemBox de EmtSelect) */
.tps-select__menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 30;
  max-height: 320px;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  list-style: none;
  border-radius: 12px;
  background: var(--tps-grey-50);
  box-shadow: 0 0 3px -1px rgba(0, 0, 0, 0.57), 0 8px 24px rgba(0, 0, 0, 0.08);
  outline: none;
}

.tps-select__option {
  margin: 0;
  padding: 5px;
  cursor: pointer;
}

.tps-select__option[aria-disabled='true'] {
  opacity: 0.5;
  cursor: default;
}

.tps-select__option-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 50px;
  padding: 3px 10px;
  border-radius: 16px;
  color: var(--tps-text);
}

.tps-select__option-label {
  font-size: 16px;
  font-weight: 700;
}

.tps-select__tick {
  flex-shrink: 0;
  font-size: 16px;
  visibility: hidden;
}

.tps-select__option[aria-selected='true'] .tps-select__tick {
  visibility: visible;
}

.tps-select__option[aria-selected='true'] .tps-select__option-box,
.tps-select__option.is-highlighted .tps-select__option-box {
  background: var(--tps-purple);
  color: #fff;
}

/* ---------- Promenade / visite (DateTimeFormRecurrent) ---------- */

.tps-recurrent {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.tps-days {
  display: flex;
  gap: 6px;
  max-width: 100%;
}

/* EmtChip : gris, vert (successlight) quand sélectionné */
.tps-day {
  flex: 1 1 0;
  min-width: 0;
  height: 40px;
  margin: 0;
  padding: 0 4px;
  border: 1px solid var(--tps-label);
  border-radius: 100vmax;
  background: transparent;
  color: var(--tps-text);
  font: inherit;
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
}

.tps-day:hover {
  background: #f0f0f0;
}

.tps-day[aria-pressed='true'] {
  border-color: #19ba92;
  background: #e9fdf8;
  color: #18ba92;
}

.tps-day__short {
  display: none;
}

.tps-time-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

/* ---------- Champs (MuiFilledInput du thème) ---------- */

.tps-field {
  position: relative;
}

.tps-field input {
  display: block;
  width: 100%;
  height: 50px;
  margin: 0;
  padding: 21px 12px 4px;
  border: 1px solid var(--tps-border);
  border-radius: 14px;
  background: #fff;
  color: var(--tps-text);
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  box-shadow: none;
  transition: border-color 0.2s;
}

.tps-field input:focus {
  outline: none;
  border-color: var(--tps-muted);
}

/* Champ en erreur (MuiFilledInput .Mui-error : error[450]) */
.tps-field.is-error input,
.tps-field-wrap.is-error .tps-field input,
.tps-field-wrap.is-error .tps-field__display,
.tps-field-wrap.is-error .tps-select__button {
  border-color: #f53e3e;
}

.tps-field label {
  position: absolute;
  top: 0;
  left: 12px;
  color: var(--tps-label);
  font-size: 14px;
  font-weight: 400;
  line-height: 1;
  pointer-events: none;
  transform: translateY(18px);
  transform-origin: left top;
  transition: transform 0.2s;
}

/* Libellé réduit en haut du champ (label "shrink" MUI) */
.tps-field input:focus + label,
.tps-field input:not(:placeholder-shown) + label,
.tps-field--date label {
  transform: translateY(8px) scale(0.75);
}

.tps-field--date input {
  cursor: pointer;
}

.tps-field--icon input {
  padding-left: 49px;
  padding-right: 44px;
}

.tps-field--icon label {
  left: 49px;
}

.tps-field__icon {
  position: absolute;
  top: 50%;
  left: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 12px;
  background: var(--tps-purple-50);
  color: var(--tps-purple);
  font-size: 14px;
  transform: translateY(-50%);
  pointer-events: none;
}

/* Icône de fin (EmtAutocomplete + MuiIcon : 14px, 3px de marge, greyGradient[550]).
   La zone cliquable reste plus large que l'icône pour le tactile. */
.tps-field__action {
  position: absolute;
  top: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px; /* icône centrée à 17px du bord, comme dans l'app */
  height: 50px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0 14px 14px 0;
  background: none;
  color: var(--tps-text-strong);
  cursor: pointer;
}

.tps-field__action:disabled {
  cursor: default;
}

.tps-field__action:focus-visible {
  outline: 2px solid var(--tps-purple-dark);
  outline-offset: -4px;
}

.tps-field__action-icon {
  display: flex;
  padding: 3px;
  font-size: 14px;
}

/* Indicateur de chargement (CircularProgress 16px) */
.tps-spinner {
  display: none;
  width: 16px;
  height: 16px;
  border: 1.5px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: tps-spin 0.8s linear infinite;
}

.tps-field.is-loading .tps-field__action-icon {
  display: none;
}

.tps-field.is-loading .tps-spinner {
  display: block;
}

@keyframes tps-spin {
  to {
    transform: rotate(360deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .tps-spinner {
    animation-duration: 2.4s;
  }
}

.tps-search__error {
  margin: -10px 0 0;
  color: var(--tps-error);
  font-size: 0.75rem;
  letter-spacing: 0.03333em;
}

.tps-search__dates {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.tps-search__dates--single {
  grid-template-columns: minmax(0, 1fr);
}

.tps-search__error--caption {
  margin: 0;
}

/* Champ + message d'erreur dessous (helperText) */
.tps-field-wrap {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.tps-search__error--field {
  margin: 0;
}

/* Les champs date natifs ont une largeur minimale qui fait déborder la grille sur mobile */
.tps-field--date input {
  min-width: 0;
}

/* L'icône du navigateur n'ouvre plus son calendrier : le clic passe au champ, qui ouvre celui du plugin */
.tps-field--date input::-webkit-calendar-picker-indicator {
  pointer-events: none;
}

/* Écran tactile : le champ ne doit jamais prendre le focus (roue de date du téléphone) ; l'appui passe au conteneur */
.tps-field--date.is-touch {
  cursor: pointer;
}
.tps-field--date.is-touch input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  pointer-events: none;
}

.tps-field__display {
  position: relative;
  display: flex;
  align-items: center;
  height: 50px;
  padding: 21px 40px 4px 12px;
  border: 1px solid var(--tps-border);
  border-radius: 14px;
  background: #fff;
  color: var(--tps-text);
  font-size: 14px;
  font-weight: 700;
}

.tps-field__display-value {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.tps-field__display-icon {
  position: absolute;
  top: 50%;
  right: 12px;
  display: flex;
  color: var(--tps-text-strong);
  transform: translateY(-50%);
  font-size: 16px;
}

/* iOS zoome sur un champ dont le texte fait moins de 16px : le champ adresse passe à 16px sur mobile */
@media (hover: none), (pointer: coarse) {
  .tps-field--icon input {
    font-size: 16px;
  }
}

/* ---------- Calendrier (DatePickerField + Calendar.module.css de l'app) ---------- */

.tps-cal {
  position: absolute;
  top: 100%;
  left: 0;
  z-index: 40;
  width: 320px;
  max-width: calc(100vw - 32px);
  margin-top: 4px;
  padding: 6px 16px 16px;
  border: 1px solid var(--tps-border);
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  color: var(--tps-text);
  cursor: default;
  user-select: none;
}

.tps-cal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 10px 0;
}

.tps-cal__arrow {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  margin: 0;
  padding: 8px;
  border: 1px solid var(--tps-border);
  border-radius: 12px;
  background: none;
  cursor: pointer;
}

.tps-cal__arrow svg {
  width: 15px;
  height: 15px;
  fill: none;
}

.tps-cal__arrow--prev {
  transform: rotate(-90deg);
}

.tps-cal__arrow--next {
  transform: rotate(90deg);
}

.tps-cal__title {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
}

.tps-cal__title-button {
  margin: 0;
  padding: 4px 6px;
  border: 0;
  border-radius: 8px;
  background: none;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

.tps-cal__title-button:hover {
  background: #f0f0f0;
}

.tps-cal__separator {
  width: 100%;
  height: 1px;
  margin-bottom: 20px;
  background: var(--tps-border);
}

.tps-cal__weekdays,
.tps-cal__days {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  width: 100%;
}

.tps-cal__weekdays {
  margin-bottom: 10px;
  text-align: center;
}

.tps-cal__weekday {
  padding: 10px 0;
  color: var(--tps-disabled);
  font-size: 12px;
  font-weight: 600;
}

.tps-cal__day {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 40px;
  padding: 10px;
  border-radius: 8px;
  color: var(--tps-text);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}

.tps-cal__day:hover {
  background: #f0f0f0;
}

.tps-cal__day.is-other-month {
  color: #bbbabf;
  font-weight: 400;
}

.tps-cal__day.is-disabled {
  color: #bbbabf;
  font-weight: 400;
  pointer-events: none;
}

.tps-cal__day.is-selected {
  background: var(--tps-purple);
  color: #fff;
}

.tps-cal__day.is-selected:hover {
  opacity: 0.5;
}

/* Listes mois / années, à peu près de la hauteur de la grille des jours */
.tps-cal__list {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 2px;
  width: 100%;
  height: 290px;
  overflow-y: auto;
}

.tps-cal__item {
  flex-shrink: 0;
  margin: 0;
  padding: 10px;
  border: 0;
  border-radius: 8px;
  background: none;
  color: var(--tps-text);
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}

.tps-cal__item:not(.is-selected):hover {
  background: #f0f0f0;
}

.tps-cal__item.is-selected {
  background: var(--tps-purple);
  color: #fff;
}

.tps-cal__item:disabled {
  color: #bbbabf;
  font-weight: 400;
  cursor: default;
  pointer-events: none;
}

/* ---------- Suggestions d'adresse (Autocomplete MUI + MenuItemBox de l'app) ---------- */

/* Paper MUI : coins 12px, ombre "elevation 1", collée sous le champ */
.tps-suggestions {
  position: absolute;
  top: calc(100% + 1px);
  left: 0;
  right: 0;
  z-index: 20;
  max-height: 360px;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  list-style: none;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 2px 1px -1px rgba(0, 0, 0, 0.2), 0 1px 1px 0 rgba(0, 0, 0, 0.14), 0 1px 3px 0 rgba(0, 0, 0, 0.12);
}

.tps-suggestions--options {
  padding: 8px 0;
}

/* Option : ligne grise de 60px, case violette au survol / au clavier */
.tps-suggestions__option {
  margin: 0;
  padding: 5px;
  background: var(--tps-grey-50);
  cursor: pointer;
}

.tps-suggestions__box {
  display: flex;
  align-items: center;
  min-height: 50px;
  padding: 3px 10px;
  border-radius: 16px;
  color: var(--tps-text);
}

.tps-suggestions__label {
  overflow: hidden;
  font-size: 16px;
  font-weight: 700;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.tps-suggestions__option.is-active .tps-suggestions__box {
  background: var(--tps-purple);
  color: #fff;
}

/* Messages (noOptionsText) */
.tps-suggestions__message {
  margin: 0;
  padding: 14px 16px;
  color: rgba(0, 0, 0, 0.6);
  font-size: 16px;
  font-weight: 400;
  line-height: 1.5;
}

.tps-suggestions__geolocate {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  cursor: pointer;
}

.tps-suggestions__geolocate.is-active {
  background: rgba(0, 0, 0, 0.04);
}

.tps-suggestions__geolocate-icon {
  display: flex;
  padding: 3px;
  color: var(--tps-purple);
  font-size: 14px;
}

/* Chargement (EmtLoader 22px dans un Paper de 60px) */
.tps-suggestions__loader {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 60px;
  margin: 0;
  color: var(--tps-purple);
}

.tps-field .tps-spinner--large {
  display: block;
  width: 22px;
  height: 22px;
  border-width: 2px;
}

/* ---------- Animaux (AnimalIncrement) ---------- */

.tps-pets {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.tps-pet {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 5px;
  min-width: 0;
  padding: 12px 10px;
  border: 1px solid var(--tps-border);
  border-radius: 16px;
  background: #fff;
}

.tps-pet__name {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.tps-pet__icon {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 12px;
  background: var(--tps-bg);
  color: var(--tps-muted);
  font-size: 16px;
}

.tps-pet.is-active .tps-pet__icon {
  background: var(--tps-purple-bg);
  color: var(--tps-purple);
}

.tps-pet__label {
  overflow: hidden;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.tps-pet__counter {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  gap: 5px;
}

.tps-pet__count {
  min-width: 10px;
  font-size: 16px;
  font-weight: 700;
  text-align: center;
}

.tps-pet__btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  margin: 0;
  padding: 0;
  border: 2px solid var(--tps-purple);
  border-radius: 10px;
  background: var(--tps-purple);
  color: #fff;
  font-size: 13px;
  cursor: pointer;
}

.tps-pet__btn:hover {
  border-color: var(--tps-purple-hover);
  background: var(--tps-purple-hover);
}

.tps-pet__btn--minus {
  border-color: var(--tps-purple-50);
  background: var(--tps-purple-50);
  color: var(--tps-purple);
}

.tps-pet__btn--minus:hover {
  border-color: #f7e2fe;
  background: #f7e2fe;
}

.tps-pet__btn--minus:disabled {
  border-color: var(--tps-grey-50);
  background: var(--tps-grey-50);
  color: var(--tps-disabled);
  cursor: default;
}

/* ---------- Bouton (EmtButton contained purple, size large) ---------- */

.tps-search__submit {
  width: 100%;
  margin: 0;
  padding: 8px 22px;
  border: 2px solid var(--tps-purple);
  border-radius: 16px;
  background: var(--tps-purple);
  color: #fff;
  font: inherit;
  font-size: 16px;
  font-weight: 700;
  line-height: 1.55;
  text-transform: none;
  box-shadow: none;
  cursor: pointer;
}

.tps-search__submit:hover,
.tps-search__submit:focus-visible {
  border-color: var(--tps-purple-hover);
  background: var(--tps-purple-hover);
}

/* ---------- Mise en page selon la largeur disponible ---------- */

@container (min-width: 520px) {
  .tps-pets {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* Desktop : deux colonnes, comme l'app (5fr / 6fr) */
@container (min-width: 860px) {
  .tps-search__form {
    grid-template-columns: 5fr 6fr;
    gap: 20px;
  }
  .tps-search__col {
    gap: 30px;
  }
  .tps-search__submit {
    grid-column: 1 / -1;
  }
  /* Comme l'app, l'icône animal n'est affichée que si les cartes sont assez larges */
  .tps-pet__icon {
    display: none;
  }
}

@container (min-width: 1100px) {
  .tps-pet__icon {
    display: flex;
  }
}

@container (max-width: 519px) {
  .tps-search__form {
    padding: 20px 16px;
  }
  .tps-day__long {
    display: none;
  }
  .tps-day__short {
    display: inline;
  }
}
