/* ============================================================
   CRD Habitat — page de contact
   Calendrier de prise de rendez-vous + fenêtre de confirmation.
   Complète css/style.css et css/pages.css.
   ============================================================ */

/* ------------------------------------------------------------
   Carte commune aux deux colonnes du rendez-vous
   ------------------------------------------------------------ */
.rdv-card {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 1.5rem;
  border-radius: var(--r-lg);
  border: 1px solid rgba(12, 27, 43, 0.1);
  background: #fff;
}
@media (min-width: 768px) { .rdv-card { padding: 2rem; border-radius: var(--r-xl); } }

.rdv-card-title {
  margin-bottom: 1.35rem;
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--pierre-2);
}

/* ------------------------------------------------------------
   Calendrier
   ------------------------------------------------------------ */
.cal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
}
.cal-month {
  font-size: 1.05rem;
  font-weight: 500;
  color: var(--nuit);
  text-transform: capitalize;
}
.cal-nav { display: flex; gap: 0.5rem; }
.cal-nav button {
  display: grid;
  place-items: center;
  width: 2.4rem;
  height: 2.4rem;
  border-radius: 50%;
  border: 1px solid rgba(12, 27, 43, 0.14);
  background: transparent;
  color: var(--nuit);
  cursor: pointer;
  transition: background-color 0.35s var(--ease), border-color 0.35s var(--ease), color 0.35s var(--ease);
}
.cal-nav button:hover:not(:disabled) { background: var(--nuit); border-color: var(--nuit); color: var(--ivoire); }
.cal-nav button:disabled { opacity: 0.3; cursor: default; }
.cal-nav svg { width: 0.85rem; height: 0.85rem; }

.cal-dow, .cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 0.35rem; }
.cal-dow {
  margin-bottom: 0.5rem;
  font-size: 0.66rem;
  font-weight: 500;
  color: var(--pierre-2);
  text-align: center;
}

.cal-day {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  border-radius: var(--r-sm);
  border: 1px solid transparent;
  background: transparent;
  font-family: inherit;
  font-size: 0.88rem;
  color: var(--encre);
  cursor: pointer;
  transition: background-color 0.3s var(--ease), color 0.3s var(--ease), border-color 0.3s var(--ease);
}
.cal-day:hover:not(:disabled) { background: rgba(12, 27, 43, 0.06); }
.cal-day:disabled { color: rgba(26, 26, 24, 0.24); cursor: default; }
.cal-day.is-empty { pointer-events: none; }

/* Jour ouvrable disponible : petite pastille sous le chiffre */
.cal-day.has-slots::after {
  content: "";
  position: absolute;
  bottom: 0.42rem;
  width: 0.26rem;
  height: 0.26rem;
  border-radius: 50%;
  background: var(--pierre);
}
.cal-day.is-today { border-color: rgba(12, 27, 43, 0.22); }
.cal-day.is-selected,
.cal-day.is-selected:hover { background: var(--nuit); border-color: var(--nuit); color: var(--ivoire); }
.cal-day.is-selected::after { background: var(--ivoire); }

.cal-legend {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 1.25rem;
  font-size: 0.72rem;
  color: rgba(26, 26, 24, 0.55);
}
.cal-legend::before {
  content: "";
  width: 0.26rem;
  height: 0.26rem;
  border-radius: 50%;
  background: var(--pierre);
}

/* ------------------------------------------------------------
   Créneaux
   ------------------------------------------------------------ */
.slot-day {
  margin-bottom: 1.1rem;
  font-size: 0.95rem;
  color: var(--nuit);
  text-transform: capitalize;
}
/* flex:1 + grid-auto-rows:1fr : à partir de lg, la carte des créneaux
   s'aligne sur la hauteur du calendrier ; les créneaux se répartissent
   dans la hauteur plutôt que de laisser un vide sous la liste. */
.slot-list { display: grid; flex: 1; grid-auto-rows: 1fr; gap: 0.55rem; }
@media (min-width: 480px) and (max-width: 1023px) {
  .slot-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.slot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  width: 100%;
  padding: 0.95rem 1.2rem;
  border-radius: var(--r-md);
  border: 1px solid rgba(12, 27, 43, 0.12);
  background: transparent;
  font-family: inherit;
  font-size: 0.88rem;
  color: var(--nuit);
  text-align: left;
  cursor: pointer;
  transition: background-color 0.35s var(--ease), color 0.35s var(--ease), border-color 0.35s var(--ease);
}
.slot:hover:not(:disabled) { background: var(--nuit); border-color: var(--nuit); color: var(--ivoire); }
.slot .slot-tag { font-size: 0.72rem; color: var(--pierre-2); transition: color 0.35s var(--ease); }
.slot:hover:not(:disabled) .slot-tag { color: rgba(246, 244, 239, 0.7); }
.slot:disabled { border-style: dashed; color: rgba(26, 26, 24, 0.3); cursor: default; }
.slot:disabled .slot-tag { color: rgba(26, 26, 24, 0.3); }

/* État vide : aucun jour choisi, ou jour sans créneau */
.slot-empty {
  display: grid;
  place-items: center;
  flex: 1;
  min-height: 12rem;
  padding: 2rem 1rem;
  border-radius: var(--r-md);
  border: 1px dashed rgba(12, 27, 43, 0.14);
  font-size: 0.85rem;
  line-height: 1.7;
  color: rgba(26, 26, 24, 0.5);
  text-align: center;
}

/* ------------------------------------------------------------
   Fenêtre de confirmation
   ------------------------------------------------------------ */
.mdl {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 1rem;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.4s var(--ease), visibility 0.4s;
}
.mdl.is-open { opacity: 1; visibility: visible; }

.mdl-back {
  position: absolute;
  inset: 0;
  background: rgba(8, 19, 33, 0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.mdl-panel {
  position: relative;
  width: 100%;
  max-width: 30rem;
  max-height: calc(100vh - 2rem);
  overflow-y: auto;
  padding: 1.75rem;
  border-radius: var(--r-lg);
  background: #fff;
  transform: translateY(14px);
  transition: transform 0.5s var(--ease-out);
}
.mdl.is-open .mdl-panel { transform: translateY(0); }
@media (min-width: 768px) { .mdl-panel { padding: 2.5rem; border-radius: var(--r-xl); } }

.mdl-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  display: grid;
  place-items: center;
  width: 2.4rem;
  height: 2.4rem;
  border-radius: 50%;
  border: 1px solid rgba(12, 27, 43, 0.12);
  background: transparent;
  color: var(--nuit);
  cursor: pointer;
  transition: background-color 0.35s var(--ease), color 0.35s var(--ease);
}
.mdl-close:hover { background: var(--nuit); color: var(--ivoire); }
.mdl-close svg { width: 0.85rem; height: 0.85rem; }

.mdl-title {
  margin-bottom: 0.5rem;
  padding-right: 2.5rem;
  font-size: 1.35rem;
  line-height: 1.2;
  letter-spacing: -0.015em;
  color: var(--nuit);
}

/* Rappel du créneau choisi, en tête de la fenêtre */
.mdl-slot {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  margin-bottom: 1.75rem;
  padding: 0.6rem 1.1rem;
  border-radius: var(--r-pill);
  background: var(--ivoire-2);
  font-size: 0.8rem;
  color: var(--nuit);
  text-transform: capitalize;
}
.mdl-slot svg { width: 0.9rem; height: 0.9rem; flex: none; }

.mdl-note { margin-top: 1.25rem; font-size: 0.72rem; line-height: 1.6; color: rgba(26, 26, 24, 0.5); }

/* Message d'erreur d'un champ */
.field-error {
  display: none;
  margin-top: 0.45rem;
  font-size: 0.72rem;
  color: #9B2C2C;
}
.field.is-invalid { border-color: #9B2C2C; }
.field.is-invalid + .field-error { display: block; }

/* Confirmation affichée à la place du formulaire */
.mdl-done { display: none; text-align: center; }
.mdl.is-done .mdl-form { display: none; }
.mdl.is-done .mdl-done { display: block; }
.mdl-done-mark {
  display: grid;
  place-items: center;
  width: 3.25rem;
  height: 3.25rem;
  margin: 0 auto 1.35rem;
  border-radius: 50%;
  background: var(--nuit);
  color: var(--ivoire);
}
.mdl-done-mark svg { width: 1.15rem; height: 1.15rem; }

@media (prefers-reduced-motion: reduce) {
  .mdl, .mdl-panel { transition: none; }
  .mdl-panel { transform: none; }
}
