/* Widget de reservas Anuubis. Los tokens permiten integrarlo con el tema sin añadir fuentes ni
   dependencias y los valores estáticos mantienen un resultado legible en navegadores antiguos. */
.anuubis-booking {
  --ab-accent: #1f6f6b;
  --ab-accent-strong: #175653;
  --ab-accent-contrast: #ffffff;
  --ab-accent-soft: rgba(31, 111, 107, 0.12);
  --ab-fg: #1f2933;
  --ab-muted: #5a6672;
  --ab-disabled: #9aa5b1;
  /* 3,17:1 sobre blanco: el borde identifica el control (WCAG 1.4.11); el separador queda más tenue. */
  --ab-border: #87929d;
  --ab-divider: #d5dde3;
  --ab-surface: #ffffff;
  /* Foco independiente del acento configurable: un acento claro no puede dejar el contorno invisible. */
  --ab-focus: #005fcc;
  --ab-today: #b26a00;
  --ab-error: #b3261e;
  --ab-error-soft: #fdf1f0;
  --ab-radius: 8px;
  --ab-radius-sm: 8px;
  --ab-button-radius: 8px;
  --ab-button-width: 100%;
  --ab-space-1: 4px;
  --ab-space-2: 8px;
  --ab-space-3: 16px;
  --ab-space-4: 24px;

  box-sizing: border-box;
  width: 100%;
  max-width: 440px;
  margin-inline: auto;
  padding: var(--ab-space-3);
  border: 1px solid var(--ab-divider);
  border-radius: var(--ab-radius);
  background: var(--ab-surface);
  color: var(--ab-fg);
  box-shadow: none;
  font-family: inherit;
  font-size: 1rem;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

@supports (color: color-mix(in srgb, #000000, #ffffff)) {
  .anuubis-booking {
    --ab-accent-soft: color-mix(in srgb, var(--ab-accent) 12%, transparent);
    --ab-accent-strong: color-mix(in srgb, var(--ab-accent) 88%, #000000);
  }
}

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

.single-product .summary .anuubis-booking {
  max-width: none;
  margin-inline: 0;
}

.anuubis-booking .ab-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--ab-space-2);
  margin-bottom: var(--ab-space-3);
}

.anuubis-booking .ab-month {
  min-width: 0;
  flex: 1;
  font-weight: 700;
  font-size: 1.05rem;
  line-height: 1.3;
  text-align: center;
}

.anuubis-booking .ab-prev,
.anuubis-booking .ab-next,
.anuubis-booking .ab-day,
.anuubis-booking .ab-slot,
.anuubis-booking .ab-book {
  margin: 0;
  font-family: inherit;
  text-transform: none;
  letter-spacing: normal;
  appearance: none;
  -webkit-appearance: none;
}

.anuubis-booking .ab-prev,
.anuubis-booking .ab-next {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid var(--ab-border);
  background: var(--ab-surface);
  color: var(--ab-fg);
  border-radius: 50%;
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.anuubis-booking .ab-prev:hover:not([disabled]),
.anuubis-booking .ab-next:hover:not([disabled]) {
  background: var(--ab-accent-soft);
  border-color: var(--ab-accent);
}

.anuubis-booking .ab-prev[disabled],
.anuubis-booking .ab-next[disabled] {
  color: var(--ab-disabled);
  opacity: 0.45;
  cursor: not-allowed;
}

.anuubis-booking .ab-calendar {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: var(--ab-space-1);
}

.anuubis-booking .ab-weekday {
  padding: var(--ab-space-1) 0 var(--ab-space-2);
  color: var(--ab-muted);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-align: center;
  text-transform: uppercase;
}

.anuubis-booking .ab-day,
.anuubis-booking .ab-empty {
  height: clamp(44px, 8vw, 52px);
  min-height: 44px;
}

.anuubis-booking .ab-day {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  padding: 0;
  border: 1px solid transparent;
  border-radius: var(--ab-radius-sm);
  background: transparent;
  color: var(--ab-disabled);
  font-size: 0.95rem;
  cursor: default;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.anuubis-booking .ab-empty {
  visibility: hidden;
}

/* La disponibilidad usa borde y peso además del color para conservar una señal inequívoca. */
.anuubis-booking .ab-day--available {
  color: var(--ab-fg);
  border-color: var(--ab-border);
  font-weight: 600;
  cursor: pointer;
}

.anuubis-booking .ab-day--available:hover {
  background: var(--ab-accent-soft);
  border-color: var(--ab-accent);
}

.anuubis-booking .ab-day[disabled] {
  color: var(--ab-disabled);
  cursor: not-allowed;
}

/* Hoy se marca dentro de la celda: un punto suelto bajo el número se leía como una mota. */
.anuubis-booking .ab-day--today {
  border-color: var(--ab-muted);
  border-style: dashed;
}

.anuubis-booking .ab-day--selected,
.anuubis-booking .ab-day--selected:hover {
  background: var(--ab-accent);
  border-color: var(--ab-accent);
  border-style: solid;
  color: var(--ab-accent-contrast);
}

/* Mientras se envía, el tema no debe atenuar lo elegido: el cliente tiene que seguir viendo su cita. */
.anuubis-booking .ab-day--selected[disabled],
.anuubis-booking .ab-slot--selected[disabled],
.anuubis-booking .ab-book[aria-busy="true"] {
  opacity: 1;
  cursor: progress;
}

.anuubis-booking .ab-message {
  min-height: 1.45em;
  margin: var(--ab-space-3) 0 0;
  color: var(--ab-muted);
  font-size: 0.9rem;
}

/* El resumen es lo que el cliente va a pagar: pesa más que la instrucción y que la nota de zona. */
.anuubis-booking .ab-message--summary {
  color: var(--ab-fg);
  font-size: 1rem;
  font-weight: 600;
}

.anuubis-booking .ab-message--error {
  padding: var(--ab-space-2) var(--ab-space-3);
  border-inline-start: 3px solid var(--ab-error);
  background: var(--ab-error-soft);
  color: var(--ab-error);
  font-weight: 600;
}

.anuubis-booking .ab-slots {
  display: flex;
  flex-wrap: wrap;
  gap: var(--ab-space-2);
  margin: var(--ab-space-2) 0 0;
}

.anuubis-booking .ab-slot {
  flex: 0 1 auto;
  min-height: 44px;
  padding: var(--ab-space-2) var(--ab-space-3);
  border: 1px solid var(--ab-border);
  border-radius: 999px;
  background: var(--ab-surface);
  color: var(--ab-fg);
  font-size: 0.92rem;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.anuubis-booking .ab-slot:hover:not([disabled]) {
  background: var(--ab-accent-soft);
  border-color: var(--ab-accent);
}

.anuubis-booking .ab-slot[disabled] {
  color: var(--ab-disabled);
  cursor: not-allowed;
}

.anuubis-booking .ab-slot--selected,
.anuubis-booking .ab-slot--selected:hover {
  background: var(--ab-accent);
  border-color: var(--ab-accent);
  color: var(--ab-accent-contrast);
}

.anuubis-booking .ab-tz {
  margin: var(--ab-space-1) 0 0;
  color: var(--ab-muted);
  font-size: 0.78rem;
}

.anuubis-booking .ab-book {
  display: block;
  width: var(--ab-button-width);
  min-height: 48px;
  margin-top: var(--ab-space-3);
  padding: var(--ab-space-2) var(--ab-space-3);
  border: 1px solid var(--ab-accent);
  border-radius: var(--ab-button-radius);
  background: var(--ab-accent);
  color: var(--ab-accent-contrast);
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.2;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.anuubis-booking .ab-book:hover:not([disabled]) {
  background: var(--ab-accent-strong);
  border-color: var(--ab-accent-strong);
}

.anuubis-booking .ab-book[disabled] {
  border-color: #aeb8c2;
  background: #eef1f4;
  color: #5a6672;
  cursor: not-allowed;
}

.anuubis-booking .ab-book[aria-busy="true"][disabled] {
  border-color: var(--ab-accent);
  background: var(--ab-accent);
  color: var(--ab-accent-contrast);
}

/* El foco se reserva para teclado y no compite con el relleno sólido de la selección. */
.anuubis-booking :focus-visible {
  outline: 2px solid var(--ab-focus);
  outline-offset: 2px;
}

.anuubis-booking [aria-busy="true"] {
  position: relative;
  pointer-events: none;
}

.anuubis-booking [aria-busy="true"]::after {
  content: "";
  position: absolute;
  z-index: 1;
  top: 50%;
  left: 50%;
  width: 28px;
  height: 28px;
  border: 3px solid var(--ab-accent-soft);
  border-top-color: var(--ab-accent);
  border-radius: 50%;
  /* El halo despeja el número que quede debajo: el anillo cae sobre la retícula, no sobre vacío. */
  background: var(--ab-surface);
  box-shadow: 0 0 0 8px var(--ab-surface);
  pointer-events: none;
  transform: translate(-50%, -50%);
  animation: ab-girar 0.8s linear infinite;
}

.anuubis-booking .ab-slots[aria-busy="true"] {
  min-height: 44px;
}

/* Sin atenuar, los números seguían negros mientras no respondían al clic. */
.anuubis-booking [aria-busy="true"] .ab-day:not(.ab-day--selected),
.anuubis-booking [aria-busy="true"] .ab-slot:not(.ab-slot--selected) {
  opacity: 0.5;
}

@keyframes ab-girar {
  to {
    transform: translate(-50%, -50%) rotate(1turn);
  }
}

@media (max-width: 480px) {
  .anuubis-booking {
    max-width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  .anuubis-booking * {
    transition: none !important;
  }

  .anuubis-booking [aria-busy="true"]::after {
    border-color: var(--ab-accent);
    animation: none;
  }
}

/* En alto contraste se delegan los colores al sistema y se conserva la selección. */
@media (forced-colors: active) {
  .anuubis-booking .ab-day--available,
  .anuubis-booking .ab-slot,
  .anuubis-booking .ab-prev,
  .anuubis-booking .ab-next,
  .anuubis-booking .ab-book {
    border: 1px solid ButtonBorder;
  }

  .anuubis-booking .ab-day--selected,
  .anuubis-booking .ab-slot--selected {
    background: Highlight;
    color: HighlightText;
    forced-color-adjust: none;
  }

  .anuubis-booking [aria-busy="true"]::after {
    border-color: CanvasText;
  }

  .anuubis-booking :focus-visible {
    outline-color: Highlight;
  }
}

/* Elementor centra el widget «Añadir al carrito» como elemento flex y lo encoge a su contenido:
   en móvil el calendario quedaba en 147 px. Con el calendario dentro, el widget ocupa el ancho. */
.elementor-widget:has(.anuubis-product-calendar) {
  width: 100% !important; /* la plantilla fija el ancho del widget con más especificidad */
  max-width: 100%;
  align-self: stretch;
}
