/* =============================================================================
   Widget de reserva — piel Devesa (Clínica Junquera)
   -----------------------------------------------------------------------------
   El JS de la base (public/js/booking-wizard.js) inyecta el marcado de los
   pasos 2 y 3 (fisioterapeutas, calendario, horarios) con clases de Bootstrap
   (.card, .btn, .col-md-6, .alert, .table…). La web pública de Devesa es
   Tailwind puro y NO carga Bootstrap, así que aquí re-implementamos ESAS clases
   en la paleta teal de la clínica, reutilizando los tokens del sistema
   (var(--color-*)). TODO va scoped a #booking-wizard para no contaminar el
   resto de la web. No se toca la base: este fichero es de la instancia.
   ============================================================================= */

#booking-wizard {
    /* Aliases locales derivados del sistema de diseño de la instancia. */
    --bw-primary: var(--color-primary, #1aa1bc);
    --bw-primary-light: var(--color-primary-light, #28bac4);
    --bw-tint: var(--color-secondary, #e8f6f5);
    --bw-ink: var(--color-dark, #18232f);
    --bw-body: var(--color-body, #444444);
    --bw-muted: var(--color-soft, #727272);
    --bw-border: rgba(24, 35, 47, 0.1);
    --bw-surface: #ffffff;
    --bw-success: #10b981;
    --bw-success-ink: #047857;
    --bw-warning: #f59e0b;
    --bw-danger: #dc2626;
    --bw-radius: 16px;
    --bw-radius-sm: 10px;
    --bw-focus: 0 0 0 3px rgba(0, 156, 166, 0.28);

    color: var(--bw-body);
    font-family: var(--font-sans, "Open Sans", system-ui, sans-serif);
    line-height: 1.6;
}

#booking-wizard *,
#booking-wizard *::before,
#booking-wizard *::after {
    box-sizing: border-box;
}

/* --- Utilidades mínimas que el JS inyecta ------------------------------------ */
#booking-wizard .d-flex { display: flex; }
#booking-wizard .align-items-center { align-items: center; }
#booking-wizard .justify-content-between { justify-content: space-between; }
#booking-wizard .justify-content-center { justify-content: center; }
#booking-wizard .flex-fill { flex: 1 1 auto; min-width: 0; }
#booking-wizard .text-center { text-align: center; }
#booking-wizard .text-end { text-align: right; }
#booking-wizard .text-start { text-align: left; }
#booking-wizard .w-100 { width: 100%; }
#booking-wizard .h-100 { height: 100%; }
#booking-wizard .fw-bold { font-weight: 700; }
#booking-wizard .fs-5 { font-size: 1.2rem; }
#booking-wizard .mb-1 { margin-bottom: 0.25rem; }
#booking-wizard .mb-2 { margin-bottom: 0.5rem; }
#booking-wizard .mb-3 { margin-bottom: 1rem; }
#booking-wizard .mb-4 { margin-bottom: 1.5rem; }
#booking-wizard .mt-3 { margin-top: 1rem; }
#booking-wizard .mt-4 { margin-top: 1.5rem; }
#booking-wizard .pt-4 { padding-top: 1.5rem; }
#booking-wizard .me-2 { margin-right: 0.5rem; }
#booking-wizard .me-3 { margin-right: 0.75rem; }
#booking-wizard .rounded-circle { border-radius: 50%; }
#booking-wizard .list-unstyled { list-style: none; padding-left: 0; margin: 0; }
#booking-wizard .border-top { border-top: 1px solid var(--bw-border); }
#booking-wizard .text-white { color: #fff; }
#booking-wizard .text-muted { color: var(--bw-muted); }
#booking-wizard .text-danger { color: var(--bw-danger); }
#booking-wizard .text-success { color: var(--bw-success-ink); }
#booking-wizard .text-primary { color: var(--bw-primary); }
#booking-wizard .bg-primary { background: var(--bw-primary); }
#booking-wizard .bg-success { background: var(--bw-success); }

#booking-wizard .visually-hidden {
    position: absolute !important;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0, 0, 0, 0);
    white-space: nowrap; border: 0;
}

/* --- Rejilla (el JS usa .row + .col-*). La resolvemos con grid: ignoramos los
       anchos de columna de Bootstrap y dejamos que auto-fill reparta. ---------- */
#booking-wizard .row { display: grid; gap: 0.75rem; }
#booking-wizard .row > [class*="col-"] { min-width: 0; }
#booking-wizard .row > .col-12 { grid-column: 1 / -1; }
#booking-wizard #employees-container.row {
    grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
}
/* Horarios: flexbox (más robusto que grid auto-fill para este caso). */
#booking-wizard .row.g-2 {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}
#booking-wizard .row.g-2 > [class*="col-"] {
    flex: 1 1 104px;
    max-width: 168px;
}

/* --- Tarjetas --------------------------------------------------------------- */
#booking-wizard .card {
    background: var(--bw-surface);
    border: 1px solid var(--bw-border);
    border-radius: var(--bw-radius);
    overflow: hidden;
}
#booking-wizard .card-body { padding: 1.25rem; }
#booking-wizard .card-header {
    padding: 0.85rem 1.25rem;
    background: var(--bw-tint);
    border-bottom: 1px solid var(--bw-border);
}
#booking-wizard .card-header h5 {
    margin: 0;
    font-family: var(--font-display, "Poppins", sans-serif);
    font-size: 1rem;
    font-weight: 600;
    color: var(--bw-ink);
}
#booking-wizard .card-title {
    margin: 0 0 0.35rem;
    font-family: var(--font-display, "Poppins", sans-serif);
    font-weight: 600;
    color: var(--bw-ink);
}

/* --- Botones ---------------------------------------------------------------- */
#booking-wizard .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.62rem 1.35rem;
    border: 1px solid transparent;
    border-radius: 999px;
    font-family: var(--font-display, "Poppins", sans-serif);
    font-size: 0.9rem;
    font-weight: 600;
    line-height: 1.2;
    cursor: pointer;
    transition: background-color 0.2s ease, color 0.2s ease,
        border-color 0.2s ease, box-shadow 0.2s ease, transform 0.05s ease;
    -webkit-appearance: none;
    appearance: none;
    text-decoration: none;
}
#booking-wizard .btn:focus-visible { outline: none; box-shadow: var(--bw-focus); }
#booking-wizard .btn:active { transform: translateY(1px); }
#booking-wizard .btn:disabled,
#booking-wizard .btn[disabled] {
    opacity: 0.45;
    cursor: not-allowed;
    transform: none;
}
#booking-wizard .btn-sm { padding: 0.35rem 0.7rem; font-size: 0.82rem; }

#booking-wizard .btn-primary,
#booking-wizard .btn-primary-fisio {
    background: var(--bw-primary);
    border-color: var(--bw-primary);
    color: #fff;
}
#booking-wizard .btn-primary:hover:not(:disabled),
#booking-wizard .btn-primary-fisio:hover:not(:disabled) {
    background: var(--bw-primary-light);
    border-color: var(--bw-primary-light);
}
#booking-wizard .btn-outline-primary {
    background: transparent;
    border-color: var(--bw-primary);
    color: var(--bw-primary);
}
#booking-wizard .btn-outline-primary:hover:not(:disabled) {
    background: var(--bw-primary);
    color: #fff;
}
#booking-wizard .btn-secondary {
    background: #fff;
    border-color: var(--bw-border);
    color: var(--bw-ink);
}
#booking-wizard .btn-secondary:hover:not(:disabled) { background: var(--bw-tint); }
#booking-wizard .btn-light {
    background: transparent;
    border-color: transparent;
    color: var(--bw-muted);
}
#booking-wizard .btn-warning {
    background: rgba(245, 158, 11, 0.14);
    border-color: rgba(245, 158, 11, 0.4);
    color: #b45309;
}

/* --- Formularios ------------------------------------------------------------ */
#booking-wizard .form-label {
    display: block;
    margin-bottom: 0.35rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--bw-ink);
}
#booking-wizard .form-control {
    display: block;
    width: 100%;
    padding: 0.7rem 0.9rem;
    background: #fff;
    border: 1px solid var(--bw-border);
    border-radius: var(--bw-radius-sm);
    font-family: inherit;
    font-size: 0.95rem;
    color: var(--bw-ink);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
#booking-wizard .form-control::placeholder { color: var(--bw-muted); }
#booking-wizard .form-control:focus {
    outline: none;
    border-color: var(--bw-primary);
    box-shadow: var(--bw-focus);
}
#booking-wizard textarea.form-control { resize: vertical; min-height: 96px; }

/* --- Avisos ----------------------------------------------------------------- */
#booking-wizard .alert {
    padding: 0.85rem 1.1rem;
    border-radius: var(--bw-radius-sm);
    font-size: 0.9rem;
    border: 1px solid transparent;
}
#booking-wizard .alert-warning {
    background: rgba(245, 158, 11, 0.1);
    border-color: rgba(245, 158, 11, 0.35);
    color: #92400e;
}
#booking-wizard .alert-danger {
    background: rgba(220, 38, 38, 0.08);
    border-color: rgba(220, 38, 38, 0.3);
    color: #991b1b;
}
#booking-wizard .alert-info {
    background: var(--bw-tint);
    border-color: rgba(0, 156, 166, 0.25);
    color: var(--bw-ink);
    text-align: left;
}
#booking-wizard .alert-info h6 {
    margin: 0 0 0.5rem;
    font-family: var(--font-display, "Poppins", sans-serif);
    font-weight: 600;
}
#booking-wizard .alert-info li { padding: 0.15rem 0; }

/* --- Riel de pasos ---------------------------------------------------------- */
#booking-wizard .wizard-steps {
    display: flex;
    gap: 0.25rem;
    margin-bottom: 1.75rem;
    padding-bottom: 1.25rem;
    border-bottom: 1px solid var(--bw-border);
}
#booking-wizard .wizard-steps > .col { flex: 1 1 0; }
#booking-wizard .step-indicator {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.45rem;
    text-align: center;
    position: relative;
}
/* conector entre indicadores */
#booking-wizard .step-indicator::before {
    content: "";
    position: absolute;
    top: 18px;
    left: calc(-50% + 18px);
    width: calc(100% - 36px);
    height: 2px;
    background: var(--bw-border);
    z-index: 0;
}
#booking-wizard .wizard-steps > [class*="col-"]:first-child .step-indicator::before {
    display: none;
}
#booking-wizard .step {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #fff;
    border: 2px solid var(--bw-border);
    color: var(--bw-muted);
    font-family: var(--font-display, "Poppins", sans-serif);
    font-weight: 600;
    font-size: 0.9rem;
    transition: background-color 0.25s ease, border-color 0.25s ease, color 0.25s ease;
}
#booking-wizard .step.active {
    background: var(--bw-primary);
    border-color: var(--bw-primary);
    color: #fff;
    box-shadow: 0 4px 12px rgba(0, 156, 166, 0.3);
}
#booking-wizard .step-label {
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    color: var(--bw-muted);
    line-height: 1.25;
}
#booking-wizard .step.active + .step-label { color: var(--bw-ink); }

/* En móvil estrecho el riel muestra solo los números (las etiquetas se
   apretaban y se cortaban). El <h4> de cada paso ya nombra dónde estás. */
@media (max-width: 480px) {
    #booking-wizard .step-label { display: none; }
    #booking-wizard .wizard-steps { gap: 0.15rem; margin-bottom: 1.25rem; }
    #booking-wizard .step { width: 32px; height: 32px; font-size: 0.85rem; }
    #booking-wizard .step-indicator::before { top: 16px; }
}

/* --- Tarjetas seleccionables (servicio / fisioterapeuta) -------------------- */
#booking-wizard .service-card,
#booking-wizard .employee-card {
    height: 100%;
    cursor: pointer;
    transition: border-color 0.18s ease, box-shadow 0.18s ease,
        background-color 0.18s ease, transform 0.05s ease;
}
#booking-wizard .service-card:hover,
#booking-wizard .employee-card:hover {
    border-color: var(--bw-primary-light);
    box-shadow: 0 6px 18px rgba(0, 156, 166, 0.12);
}
#booking-wizard .service-card:focus-visible,
#booking-wizard .employee-card:focus-visible {
    outline: none;
    box-shadow: var(--bw-focus);
}
/* estado seleccionado: el JS añade .border .border-primary */
#booking-wizard .service-card.border-primary,
#booking-wizard .employee-card.border-primary {
    border-color: var(--bw-primary) !important;
    background: var(--bw-tint);
    box-shadow: 0 0 0 1px var(--bw-primary) inset, 0 6px 18px rgba(0, 156, 166, 0.15);
}
#booking-wizard .service-card .card-text {
    font-size: 0.88rem;
    color: var(--bw-muted);
    margin: 0 0 0.75rem;
}
#booking-wizard .employee-card h6 {
    margin: 0 0 0.15rem;
    font-family: var(--font-display, "Poppins", sans-serif);
    font-weight: 600;
    color: var(--bw-ink);
}

/* --- Calendario ------------------------------------------------------------- */
#booking-wizard .table { width: 100%; border-collapse: collapse; }
#booking-wizard .table thead th {
    padding: 0.4rem 0;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--bw-muted);
    text-align: center;
}
#booking-wizard .table td { padding: 3px; text-align: center; }
#booking-wizard #current-month-year {
    margin: 0;
    font-family: var(--font-display, "Poppins", sans-serif);
    font-size: 1rem;
    font-weight: 600;
    color: var(--bw-ink);
}
#booking-wizard #current-month-year::first-letter { text-transform: uppercase; }
#booking-wizard .calendar-day {
    width: 40px;
    height: 40px;
    padding: 0;
    margin: 0 auto;
    border-radius: 10px;
    font-size: 0.9rem;
    font-weight: 600;
    font-family: var(--font-sans, sans-serif);
}
#booking-wizard .calendar-day.btn-light {
    color: var(--bw-muted);
    opacity: 0.5;
    cursor: default;
}
#booking-wizard .calendar-day.btn-outline-primary { font-weight: 700; }
#booking-wizard .calendar-day.btn-primary { box-shadow: 0 4px 12px rgba(0, 156, 166, 0.3); }

/* --- Horarios --------------------------------------------------------------- */
#booking-wizard .time-slot {
    padding: 0.55rem 0.4rem;
    font-size: 0.85rem;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

/* --- Spinner del submit ----------------------------------------------------- */
#booking-wizard .spinner-border {
    display: inline-block;
    width: 1rem; height: 1rem;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: bw-spin 0.7s linear infinite;
}
#booking-wizard .spinner-border-sm { width: 0.9rem; height: 0.9rem; }
@keyframes bw-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
    #booking-wizard .spinner-border { animation-duration: 1.6s; }
    #booking-wizard .btn { transition: none; }
}

/* --- Encabezados internos --------------------------------------------------- */
#booking-wizard .booking-step > h4 {
    font-family: var(--font-display, "Poppins", sans-serif);
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--bw-ink);
    margin: 0 0 1rem;
}
#booking-wizard .booking-step > h4:focus-visible { outline: none; }

/* =============================================================================
   Modal global de reserva (<dialog>). Selectores propios .bm-* (NO scoped bajo
   #booking-wizard, porque el modal lo CONTIENE). Usa los mismos tokens.
   ============================================================================= */
/* Oculto cuando está cerrado. IMPRESCINDIBLE: al fijar display:flex (regla de
   AUTOR) en .bm-dialog anulamos el `dialog:not([open]){display:none}` del
   navegador (el origen autor gana al user-agent sin importar especificidad), así
   que el modal se quedaba visible/fijado siempre. Lo ocultamos a mano. */
.bm-dialog:not([open]) { display: none; }

.bm-dialog {
    /* Centrado por transform: el reset de Tailwind Preflight pone margin:0 en el
       <dialog> y anula el margin:auto del UA, así que centramos a mano. */
    position: fixed;
    inset: auto;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    width: min(920px, 94vw);
    max-width: 94vw;
    max-height: 92vh;
    padding: 0;
    border: none;
    border-radius: 20px;
    background: #fff;
    color: var(--color-body, #444);
    box-shadow: 0 24px 60px rgba(24, 35, 47, 0.28);
    overflow: hidden;
}
.bm-dialog::backdrop {
    background: rgba(24, 35, 47, 0.55);
    backdrop-filter: blur(2px);
}
.bm-head {
    flex: 0 0 auto;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    padding: 1.15rem 1.5rem;
    border-bottom: 1px solid rgba(24, 35, 47, 0.08);
}
.bm-eyebrow {
    display: block;
    font-family: var(--font-display, "Poppins", sans-serif);
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--color-primary, #1aa1bc);
}
.bm-title {
    margin: 0.15rem 0 0;
    font-family: var(--font-display, "Poppins", sans-serif);
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--color-dark, #18232f);
}
.bm-close {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: 1px solid rgba(24, 35, 47, 0.1);
    background: #fff;
    color: var(--color-dark, #18232f);
    cursor: pointer;
    transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}
.bm-close:hover {
    background: var(--color-primary, #1aa1bc);
    border-color: var(--color-primary, #1aa1bc);
    color: #fff;
}
.bm-close:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(0, 156, 166, 0.3);
}
.bm-body {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 1.5rem;
    background: var(--color-secondary, #e8f6f5);
}
/* Dentro del modal el wizard no necesita su propia tarjeta ni doble padding */
.bm-body #booking-wizard > .card {
    border: none;
    box-shadow: none;
}
.bm-body #booking-wizard > .card > .card-body {
    padding: 1.25rem !important;
}
@media (max-width: 640px) {
    .bm-dialog { width: 100vw; max-width: 100vw; max-height: 100vh; height: 100vh; border-radius: 0; }
    .bm-body { padding: 1rem; }
    .bm-body #booking-wizard > .card > .card-body { padding: 0.75rem !important; }
}

