/* ==========================================================
   BOOKING · UX REFINADA
========================================================== */

.booking-modal-open {
  overflow: hidden;
}

.booking-modal-overlay,
.booking-success-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: grid;
  place-items: center;
  padding: 1rem;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: rgba(10, 12, 18, 0.64);
  backdrop-filter: blur(5px);
}

.booking-modal-overlay[hidden],
.booking-success-overlay[hidden] {
  display: none;
}

.booking-modal {
  width: min(760px, 100%);
  max-height: min(88vh, 820px);
  overflow-y: auto;
  overflow-x: hidden;
  border:
    1px solid rgba(127, 127, 127, 0.18);
  border-radius: 1.25rem;
  background: var(--color-background, #fff);
  color: var(--color-text, #111);
  box-shadow:
    0 28px 80px rgba(0, 0, 0, 0.28);
}

.booking-modal-header {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.4rem 1.5rem 1.1rem;
  border-bottom:
    1px solid rgba(127, 127, 127, 0.16);
  background: var(--color-background, #fff);
}

.booking-modal-header h2 {
  margin: 0.2rem 0 0;
  font-size: clamp(1.35rem, 3vw, 1.75rem);
}

.booking-modal-header p {
  margin-bottom: 0;
}

.booking-modal-close {
  display: grid;
  width: 2.4rem;
  height: 2.4rem;
  flex: 0 0 auto;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background:
    rgba(127, 127, 127, 0.1);
  color: inherit;
  font-size: 1.5rem;
  cursor: pointer;
}

.booking-step {
  padding: 1.35rem 1.5rem 1.5rem;
}

.booking-events-toolbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.booking-resource-filter {
  display: grid;
  min-width: 210px;
  gap: 0.35rem;
}

.booking-resource-filter[hidden] {
  display: none;
}

.booking-resource-filter label {
  font-size: 0.76rem;
  font-weight: 700;
}

.booking-resource-filter select {
  width: 100%;
  min-height: 40px;
  padding: 0.65rem 2.25rem 0.65rem 0.75rem;
  border:
    1px solid rgba(127, 127, 127, 0.35);
  border-radius: 0.65rem;
  background: var(--color-background, #fff);
  color: inherit;
  font: inherit;
  cursor: pointer;
}

.booking-events-toolbar strong {
  display: block;
  margin-bottom: 0.2rem;
  font-size: 1rem;
}

.booking-events-toolbar p {
  margin: 0;
  opacity: 0.66;
  font-size: 0.86rem;
}

.booking-events-list {
  display: grid;
  gap: 1.6rem;
}

.booking-week {
  display: grid;
  gap: 0.85rem;
}

.booking-week-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.booking-week-eyebrow {
  display: block;
  margin-bottom: 0.12rem;
  opacity: 0.58;
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.booking-week-header h3 {
  margin: 0;
  font-size: 1rem;
}

.booking-days-list {
  display: grid;
  gap: 0.8rem;
}

.booking-day-group {
  display: grid;
  grid-template-columns:
    minmax(110px, 0.34fr)
    minmax(0, 1fr);
  align-items: start;
  gap: 1rem;
  padding: 0.9rem 0;
  border-top:
    1px solid rgba(127, 127, 127, 0.14);
}

.booking-day-group:first-child {
  border-top: 0;
}

.booking-day-label {
  display: grid;
  gap: 0.12rem;
}

.booking-day-label strong {
  font-size: 0.92rem;
}

.booking-day-label span {
  opacity: 0.58;
  font-size: 0.78rem;
}

.booking-day-times {
  display: grid;
  grid-template-columns:
    repeat(2, minmax(0, 1fr));
  gap: 0.55rem;
}

.booking-time-option {
  position: relative;
  display: grid;
  grid-template-columns:
    minmax(0, 1fr) auto;
  grid-template-areas:
    "main check"
    "end check"
    "spots check";
  gap: 0.1rem 0.6rem;
  min-width: 0;
  padding: 0.8rem 0.85rem;
  border:
    1px solid rgba(127, 127, 127, 0.26);
  border-radius: 0.75rem;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
  transition:
    border-color 160ms ease,
    background-color 160ms ease,
    transform 160ms ease;
}

.booking-time-option:hover {
  transform: translateY(-1px);
  border-color:
    rgba(127, 127, 127, 0.58);
}

.booking-time-option.is-selected {
  border-color: currentColor;
  background:
    color-mix(
      in srgb,
      currentColor 7%,
      transparent
    );
}

.booking-time-main {
  grid-area: main;
  font-size: 1rem;
  font-weight: 800;
}

.booking-time-end {
  grid-area: end;
  opacity: 0.58;
  font-size: 0.74rem;
}

.booking-time-spots {
  grid-area: spots;
  margin-top: 0.22rem;
  opacity: 0.7;
  font-size: 0.74rem;
}

.booking-time-check {
  display: grid;
  width: 1.45rem;
  height: 1.45rem;
  grid-area: check;
  align-self: center;
  place-items: center;
  border:
    1px solid rgba(127, 127, 127, 0.45);
  border-radius: 0.4rem;
  font-size: 0.8rem;
  font-weight: 800;
}

.booking-time-option.is-selected
.booking-time-check {
  border-color: currentColor;
}

.booking-selection-bar {
  position: sticky;
  bottom: -1px;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin: 1.25rem -1.5rem -1.5rem;
  padding: 1rem 1.5rem;
  border-top:
    1px solid rgba(127, 127, 127, 0.18);
  background: var(--color-background, #fff);
  box-shadow:
    0 -12px 32px rgba(0, 0, 0, 0.08);
}

.booking-selection-summary {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.booking-selection-badge {
  display: grid;
  width: 2.25rem;
  height: 2.25rem;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 50%;
  background: currentColor;
}

.booking-selection-badge span {
  color: var(--color-background, #fff);
  font-weight: 800;
}

.booking-selection-summary > div {
  display: grid;
  gap: 0.1rem;
}

.booking-selection-summary small {
  opacity: 0.58;
  font-size: 0.74rem;
}

.booking-back-button {
  margin-bottom: 0.85rem;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.booking-selected-event {
  display: grid;
  gap: 0.25rem;
  margin-bottom: 1.25rem;
  padding: 1rem;
  border:
    1px solid rgba(127, 127, 127, 0.18);
  border-radius: 0.85rem;
  background:
    rgba(127, 127, 127, 0.07);
}

.booking-selected-count {
  opacity: 0.62;
  font-size: 0.82rem;
}

.booking-selected-list {
  display: grid;
  gap: 0.45rem;
  margin-top: 0.75rem;
}

.booking-selected-list span {
  padding: 0.55rem 0.7rem;
  border-radius: 0.55rem;
  background:
    rgba(127, 127, 127, 0.08);
  font-size: 0.84rem;
}

.booking-form-grid {
  display: grid;
  grid-template-columns:
    repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.booking-field {
  display: grid;
  gap: 0.4rem;
}

.booking-field label {
  font-size: 0.86rem;
  font-weight: 700;
}

.booking-field label span {
  opacity: 0.58;
  font-weight: 500;
}

.booking-field-hint {
  display: block;
  margin-top: 6px;
  color: var(--text-muted, #6b7280);
  font-size: 0.82rem;
  line-height: 1.4;
}

.booking-field input,
.booking-field textarea {
  width: 100%;
  height: 46px;
  min-height: 46px;
  box-sizing: border-box;
  padding: 0.82rem 0.9rem;
  border:
    1px solid rgba(127, 127, 127, 0.35);
  border-radius: 0.65rem;
  background: transparent;
  color: inherit;
  font: inherit;
}

.booking-field textarea {
  resize: vertical;
  overflow-y: auto;
  line-height: 1.35;
}

.booking-field input:focus,
.booking-field textarea:focus {
  outline: 2px solid currentColor;
  outline-offset: 2px;
}

.booking-remember-field {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-top: 1rem;
  color: var(--text-muted, #6b7280);
  font-size: 0.86rem;
  line-height: 1.4;
  cursor: pointer;
}

.booking-remember-field input {
  width: auto;
  height: auto;
  min-height: 0;
  margin: 0;
  flex-shrink: 0;
}

.booking-partial-warning {
  color: var(--warning, #b45309);
  font-size: 0.9rem;
}

.booking-retry-slot {
  margin-top: 0.5rem;
}

.booking-status {
  min-height: 1.5rem;
  margin: 1rem 0 0;
  font-size: 0.92rem;
  line-height: 1.45;
}

.booking-status:not(:empty) {
  display: flex;
  align-items: center;
  gap: 0.65rem;

  padding: 0.85rem 1rem;

  border: 1px solid rgba(180, 40, 40, 0.22);
  border-left: 4px solid #d14343;

  border-radius: 0.75rem;

  background: rgba(180, 40, 40, 0.08);

  color: #a12626;

  font-weight: 500;
}

.booking-status:not(:empty)::before {
  content: "⚠";
  flex: 0 0 auto;
  font-size: 1rem;
  font-weight: 700;
}

.booking-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  margin-top: 1rem;
}

.booking-loading,
.booking-empty {
  padding: 1.5rem;
  text-align: center;
}

/* SUCCESS */

.booking-success-overlay {
  z-index: 10050;
}

.booking-success-popup {
  width: min(520px, 100%);
  max-height: calc(100vh - 2rem);
  overflow-y: auto;
  padding: 1.75rem;
  border-radius: 1.15rem;
  background: var(--color-background, #fff);
  color: var(--color-text, #111);
  text-align: center;
  box-shadow:
    0 28px 80px rgba(0, 0, 0, 0.28);
}

.booking-success-icon {
  display: grid;
  width: 3.5rem;
  height: 3.5rem;
  margin: 0 auto 1rem;
  place-items: center;
  border: 2px solid currentColor;
  border-radius: 50%;
  font-size: 1.4rem;
}

.booking-result-list {
  display: grid;
  gap: 0.6rem;
  margin: 1.25rem 0;
  text-align: left;
}

.booking-result-item {
  display: grid;
  grid-template-columns:
    auto minmax(0, 1fr);
  gap: 0.75rem;
  padding: 0.8rem;
  border-radius: 0.7rem;
  background:
    rgba(127, 127, 127, 0.08);
}

.booking-result-item > span {
  font-weight: 800;
}

.booking-result-item div {
  display: grid;
  gap: 0.15rem;
}

.booking-result-item small {
  opacity: 0.66;
}

.booking-result-item.is-error {
  outline:
    1px solid rgba(180, 40, 40, 0.42);
}

@media (max-width: 680px) {
  .booking-modal-overlay {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding:
      max(20px, 5dvh)
      16px
      16px;
  }

    .booking-events-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .booking-resource-filter {
    width: 100%;
    min-width: 0;
  }

  .booking-modal {
    width: min(100%, 560px);
    max-height:
      calc(100dvh - max(40px, 10dvh));
    margin: 0;
    border-radius: 1.15rem;
  }

  .booking-modal-header {
    padding: 1.15rem 1.05rem 0.95rem;
  }

  .booking-step {
    padding: 1rem 1.05rem 1.05rem;
  }

  .booking-day-group {
    grid-template-columns: 1fr;
    gap: 0.55rem;
  }

  .booking-day-times {
    grid-template-columns:
      repeat(2, minmax(0, 1fr));
  }

  .booking-selection-bar {
    margin: 1rem -1.05rem -1.05rem;
    padding: 0.9rem 1.05rem;
  }

  .booking-form-grid {
    grid-template-columns: 1fr;
  }

  .booking-success-overlay {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
  }

  .booking-success-popup {
    width: min(100%, 520px);
    max-height: calc(100dvh - 2rem);
    border-radius: 1.15rem;
  }
}

@media (max-width: 430px) {
  .booking-modal-overlay {
    align-items: flex-start;
    padding:
      18px
      12px
      12px;
  }

  .booking-modal {
    width: 100%;
    max-height: calc(100dvh - 30px);
    border-radius: 1rem;
  }

  .booking-success-overlay {
    align-items: center;
    padding: 12px;
  }

  .booking-success-popup {
    width: 100%;
    max-height: calc(100dvh - 24px);
    border-radius: 1rem;
  }

  .booking-day-times {
    grid-template-columns: 1fr;
  }

  .booking-selection-bar {
    align-items: stretch;
    flex-direction: column;
  }

  .booking-selection-bar .btn,
  .booking-modal-actions .btn {
    width: 100%;
  }

  .booking-modal-actions {
    flex-direction: column-reverse;
  }
}

@media (prefers-reduced-motion: reduce) {
  .booking-time-option {
    transition: none;
  }

  .booking-time-option:hover {
    transform: none;
  }
}


/* Profesional asignado en turnos individuales */
.booking-time-spots {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.booking-time-option[data-booking-event-id^="slot:"] {
  border-style: solid;
}


/* ==========================================================
   BOOKING · SCROLL SIN DESBORDE MÍNIMO
========================================================== */

@media (min-width: 681px) {
  .booking-modal {
    max-height: none;
    overflow: visible;
  }

  .booking-modal-header {
    position: static;
  }
}

.booking-modal-overlay {
  align-items: start;
}

.booking-modal {
  margin-block: auto;
}

.booking-email-notice {
  display: grid;
  gap: 0.35rem;
  margin: 1rem 0;
  padding: 0.9rem 1rem;
  border: 1px solid rgba(127, 127, 127, 0.24);
  border-radius: 0.8rem;
  background: rgba(127, 127, 127, 0.07);
  text-align: left;
}

.booking-email-notice strong {
  font-size: 0.96rem;
}

.booking-email-notice span {
  font-size: 0.9rem;
  line-height: 1.45;
  opacity: 0.78;
}

.booking-email-notice.is-sent {
  border-color: rgba(34, 130, 76, 0.3);
  background: rgba(34, 130, 76, 0.08);
}

.booking-email-notice.is-test {
  border-color: rgba(173, 126, 16, 0.32);
  background: rgba(220, 173, 45, 0.1);
}

.booking-email-notice.is-warning {
  border-color: rgba(180, 86, 40, 0.3);
  background: rgba(180, 86, 40, 0.08);
}
