/*
 * Agenda en la vitrina (1.1.9.0): lo que el cromo del núcleo no trae. Agendar una cita, sus tarjetas para elegir
 * (sucursal, horario) y el formulario compacto. Botones, campos, paneles y el segmento de dos opciones son los del núcleo
 * (`iw-brand-btn`, `iw-sf-input`, `iw-sf-panel`, `iw-sf-segment`); aquí solo se colocan. Colores solo con los tokens de la
 * vitrina (`--iw-sf-*`), así un tema de marca los pinta sin copiar la vista. Los selectores van dentro de :where()
 * (especificidad cero) y el archivo no usa @layer: cualquier regla de la hoja de marca del tema (`public/css/themes/`,
 * sin capas) gana sin pelear. Se carga solo en las páginas de Agenda.
 */

/* Formulario: bloques separados por una línea, sin una caja por paso. */
:where(.iw-cita-form) {
    counter-reset: iw-cita-step;
    padding: 1rem;
}
@media (min-width: 640px) {
    :where(.iw-cita-form) {
        padding: 1.5rem;
    }
}
:where(.iw-cita-block) {
    padding: 1rem 0;
    border-top: 1px solid var(--iw-sf-divider);
}
:where(.iw-cita-form) > :where(.iw-cita-block:first-of-type) {
    padding-top: 0;
    border-top: 0;
}

/* Título del paso, numerado solo: un paso oculto (x-show) no cuenta. */
:where(.iw-cita-block__head) {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem 1rem;
    margin-bottom: 0.75rem;
}
:where(.iw-cita-block__title) {
    margin: 0;
    font-size: 0.9375rem;
    font-weight: 600;
    line-height: 1.35;
    color: var(--iw-sf-text);
}
:where(.iw-cita-block__title)::before {
    counter-increment: iw-cita-step;
    content: counter(iw-cita-step) " · ";
    color: var(--iw-sf-muted);
}
:where(.iw-cita-block__head) > :where(.iw-cita-block__title) {
    margin: 0;
}
:where(.iw-cita-block) > :where(.iw-cita-block__title) {
    margin-bottom: 0.75rem;
}
:where(.iw-cita-optional) {
    font-weight: 400;
    color: var(--iw-sf-muted);
}

/* El segmento del núcleo a lo ancho en el celular y a su medida en pantallas grandes. */
:where(.iw-cita-segment) {
    width: 100%;
}
@media (min-width: 640px) {
    :where(.iw-cita-segment) {
        width: auto;
        min-width: 20rem;
        max-width: 28rem;
    }
}
:where(.iw-cita-segment--small) {
    min-width: 0;
    width: auto;
}
:where(.iw-cita-segment) > :where(.iw-sf-segment__btn) {
    white-space: nowrap;
}
@media (max-width: 380px) {
    :where(.iw-cita-segment) > :where(.iw-sf-segment__btn) {
        padding-inline: 0.5rem;
        font-size: 0.8125rem;
    }
}
:where(.iw-cita-segment) > :where(a.iw-sf-segment__btn) {
    display: block;
    text-align: center;
    text-decoration: none;
}

/* Tarjetas para elegir (sucursal): dos por fila en el celular si caben, tres en pantallas grandes. */
:where(.iw-cita-choices) {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 12rem), 1fr));
    gap: 0.5rem;
}
:where(.iw-cita-choice) {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
    width: 100%;
    margin: 0;
    padding: 0.625rem 0.875rem;
    text-align: left;
    background: transparent;
    border: 1px solid var(--iw-sf-box);
    border-radius: 0.75rem;
    color: var(--iw-sf-body);
    cursor: pointer;
    transition: border-color var(--iw-motion-fast, 150ms) ease-out, background-color var(--iw-motion-fast, 150ms) ease-out;
}
:where(.iw-cita-choice):hover {
    border-color: var(--iw-sf-accent);
}
:where(.iw-cita-choice.is-on) {
    border-color: var(--iw-sf-accent);
    box-shadow: inset 0 0 0 1px var(--iw-sf-accent);
    background: var(--iw-sf-accent-soft);
}
:where(.iw-cita-choice):focus-visible {
    outline: 2px solid var(--iw-sf-accent);
    outline-offset: 2px;
}
:where(.iw-cita-choice__name) {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--iw-sf-text);
}
:where(.iw-cita-choice__meta) {
    font-size: 0.75rem;
    line-height: 1.4;
    color: var(--iw-sf-muted);
}

/* Fecha y «Ver horarios» en una sola línea. */
:where(.iw-cita-schedule) {
    display: flex;
    align-items: stretch;
    gap: 0.5rem;
}
:where(.iw-cita-schedule) > :where(.iw-sf-input) {
    flex: 1 1 auto;
    min-width: 0;
    max-width: 16rem;
}
:where(.iw-cita-schedule) > :where(button) {
    flex: 0 0 auto;
    white-space: nowrap;
}

/* Horarios: tantos por fila como quepan (cuatro en el celular con 24 h, seis en pantallas grandes). */
:where(.iw-cita-slots) {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(4.5rem, 1fr));
    gap: 0.375rem;
    margin-top: 0.75rem;
}
@media (min-width: 640px) {
    :where(.iw-cita-slots) {
        grid-template-columns: repeat(auto-fill, minmax(6.5rem, 1fr));
    }
}
:where(.iw-cita-slot) {
    margin: 0;
    white-space: nowrap;
    padding: 0.5rem 0.25rem;
    font-size: 0.875rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    color: var(--iw-sf-text);
    background: transparent;
    border: 1px solid var(--iw-sf-box);
    border-radius: 0.625rem;
    cursor: pointer;
    transition: border-color var(--iw-motion-fast, 150ms) ease-out, background-color var(--iw-motion-fast, 150ms) ease-out;
}
:where(.iw-cita-slot):hover {
    border-color: var(--iw-sf-accent);
}
:where(.iw-cita-slot.is-on) {
    border-color: var(--iw-sf-accent);
    box-shadow: inset 0 0 0 1px var(--iw-sf-accent);
    background: var(--iw-sf-accent-soft);
}
:where(.iw-cita-slot):focus-visible {
    outline: 2px solid var(--iw-sf-accent);
    outline-offset: 2px;
}
:where(.iw-cita-empty) {
    margin: 0.75rem 0 0;
    font-size: 0.8125rem;
    color: var(--iw-sf-body);
}

/* Datos: dos columnas en pantallas grandes, una en el celular. */
:where(.iw-cita-grid) {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 0.75rem;
}
@media (min-width: 640px) {
    :where(.iw-cita-grid) {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 0.75rem 1rem;
    }
    :where(.iw-cita-field--full) {
        grid-column: 1 / -1;
    }
}
:where(.iw-cita-field) {
    display: block;
    min-width: 0;
}
:where(.iw-cita-field__label) {
    display: block;
    margin-bottom: 0.25rem;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--iw-sf-body);
}

/* Confirmar: a lo ancho en el celular, a su medida a la derecha en pantallas grandes. */
:where(.iw-cita-submit) {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: 1rem;
}
:where(.iw-cita-submit) > :where(button) {
    width: 100%;
    padding-top: 0.625rem;
    padding-bottom: 0.625rem;
}
@media (min-width: 640px) {
    :where(.iw-cita-submit) {
        flex-direction: row;
        align-items: center;
        justify-content: flex-end;
    }
    :where(.iw-cita-submit) > :where(button) {
        width: auto;
        min-width: 12rem;
    }
}

/* Lo que ya viene elegido (el interés desde una ficha). */
:where(.iw-cita-value) {
    margin: 0;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--iw-sf-text);
}

/* Botones deshabilitados (cargando horarios, faltan datos): se ven apagados y no cambian al pasar el puntero. */
:where(.iw-cita-form) :where(.iw-brand-btn, .iw-brand-btn--outline):disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

/* «Escríbenos por WhatsApp» al registrar la cita: un pulso suave para que se vea; quieto si se pide menos movimiento. */
:where(.iw-write-first--attention) :where(.iw-write-first__button) {
    position: relative;
    animation: iw-write-first-pulse 2.4s ease-in-out infinite;
}

:where(.iw-write-first--attention) :where(.iw-write-first__button):where(:hover, :focus-visible) {
    animation-play-state: paused;
}

@keyframes iw-write-first-pulse {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 transparent;
    }
    50% {
        transform: scale(1.04);
        box-shadow: 0 0 0 10px color-mix(in srgb, var(--iw-sf-accent) 22%, transparent);
    }
}

@media (prefers-reduced-motion: reduce) {
    :where(.iw-write-first--attention) :where(.iw-write-first__button) {
        animation: none;
    }
}
