/* ============================================
   BOOKING MODAL — Shared styles
   Uses CSS variables defined by each tenant.
   ============================================ */

.bm-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: rgba(0,0,0,0.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.bm-overlay.open {
  opacity: 1;
  pointer-events: all;
}

.bm-modal {
  position: relative;
  width: 97vw;
  max-width: 900px;
  max-height: 95vh;
  background: var(--color-fondo, #fff);
  color: var(--color-texto, #333);
  border: 1px solid var(--color-borde, #e5e5e5);
  border-radius: 1rem;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: scale(0.95) translateY(10px);
  transition: transform 0.3s ease;
}

.bm-overlay.open .bm-modal {
  transform: scale(1) translateY(0);
}

/* Close button */
.bm-close {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 20;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  background: var(--color-superficie, rgba(0,0,0,0.05));
  color: var(--color-texto-suave, #888);
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

.bm-close:hover {
  background: var(--color-borde, #ddd);
  color: var(--color-texto, #333);
}

/* Layout: sidebar + content */
.bm-layout {
  display: flex;
  flex: 1;
  min-height: 0;
}

/* Sidebar stepper */
.bm-sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--color-superficie, #f5f5f5);
  border-right: 1px solid var(--color-borde, #e5e5e5);
  padding: 28px 20px;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.bm-sidebar-title {
  font-family: var(--fuente-titulo, inherit);
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--color-texto, #333);
  margin-bottom: 24px;
}

.bm-step-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  cursor: default;
  transition: background 0.2s;
  position: relative;
}

.bm-step-item.clickable {
  cursor: pointer;
}

.bm-step-item.clickable:hover {
  background: color-mix(in srgb, var(--color-acento, #6366f1) 8%, transparent);
}

.bm-step-icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
  border: 2px solid var(--color-borde, #ddd);
  color: var(--color-texto-suave, #888);
  background: transparent;
  transition: all 0.3s ease;
}

.bm-step-item.completed .bm-step-icon {
  background: var(--color-acento, #6366f1);
  border-color: var(--color-acento, #6366f1);
  color: #fff;
}

.bm-step-item.active .bm-step-icon {
  border-color: var(--color-acento, #6366f1);
  color: var(--color-acento, #6366f1);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-acento, #6366f1) 20%, transparent);
}

.bm-step-label {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--color-texto-suave, #888);
  transition: color 0.2s;
}

.bm-step-item.active .bm-step-label,
.bm-step-item.completed .bm-step-label {
  color: var(--color-texto, #333);
}

/* Connector line between steps */
.bm-step-connector {
  width: 2px;
  height: 16px;
  margin-left: 27px;
  background: var(--color-borde, #e5e5e5);
  transition: background 0.3s;
}

.bm-step-connector.done {
  background: var(--color-acento, #6366f1);
}

/* Indicador compacto de progreso — SOLO móvil (oculto en desktop). En móvil
 * reemplaza la fila de 6 pasos que no cabía. Se muestra vía el @media de abajo. */
.bm-progress-mobile { display: none; }
.bm-progress-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 8px;
}
.bm-progress-step {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-texto-suave, #8a7d6f);
  white-space: nowrap;
}
.bm-progress-label {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--color-texto, #1f1812);
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.bm-progress-track {
  height: 4px;
  border-radius: 999px;
  background: var(--color-borde, #e5e5e5);
  overflow: hidden;
}
.bm-progress-fill {
  height: 100%;
  background: var(--color-acento, #6366f1);
  border-radius: 999px;
  transition: width 0.3s ease;
}

/* Content area */
.bm-content {
  flex: 1;
  padding: 32px 28px;
  overflow-y: auto;
  min-height: 0;
}

.bm-content-title {
  font-family: var(--fuente-titulo, inherit);
  font-size: 1.3rem;
  font-weight: 600;
  color: var(--color-texto, #333);
  margin-bottom: 4px;
}

.bm-content-subtitle {
  font-size: 0.85rem;
  color: var(--color-texto-suave, #888);
  margin-bottom: 24px;
}

/* Back button */
.bm-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  color: var(--color-texto-suave, #888);
  background: none;
  border: none;
  cursor: pointer;
  margin-bottom: 16px;
  padding: 4px 0;
  transition: color 0.2s;
}

.bm-back:hover {
  color: var(--color-acento, #6366f1);
}

/* Service/staff/slot list */
.bm-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 50vh;
  overflow-y: auto;
  padding-right: 4px;
}

.bm-list-item {
  width: 100%;
  text-align: left;
  padding: 14px 16px;
  border-radius: 12px;
  border: 1px solid var(--color-borde, #e5e5e5);
  background: var(--color-superficie, #f9f9f9);
  color: inherit;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 14px;
}

.bm-list-item:hover {
  border-color: var(--color-acento, #6366f1);
  transform: translateY(-1px);
  box-shadow: 0 2px 8px color-mix(in srgb, var(--color-acento, #6366f1) 10%, transparent);
}

.bm-list-item:active {
  transform: scale(0.98);
}

/* Avatar */
.bm-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 600;
  color: #fff;
  background: var(--color-acento, #6366f1);
  flex-shrink: 0;
  overflow: hidden;
}

.bm-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Skeleton loading */
.bm-skeleton {
  height: 56px;
  border-radius: 12px;
  background: linear-gradient(90deg,
    var(--color-superficie, #f0f0f0) 25%,
    var(--color-borde, #e5e5e5) 50%,
    var(--color-superficie, #f0f0f0) 75%);
  background-size: 200% 100%;
  animation: bm-shimmer 1.5s infinite;
}

@keyframes bm-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Calendar */
.bm-calendar {
  position: relative;
}

.bm-cal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.bm-cal-month {
  font-family: var(--fuente-titulo, inherit);
  font-size: 1rem;
  font-weight: 600;
  color: var(--color-texto, #333);
  text-transform: capitalize;
}

.bm-cal-nav {
  display: flex;
  gap: 8px;
}

.bm-cal-nav button {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid var(--color-borde, #e5e5e5);
  background: var(--color-superficie, #f9f9f9);
  color: var(--color-texto, #333);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 16px;
  transition: all 0.2s;
}

.bm-cal-nav button:hover {
  border-color: var(--color-acento, #6366f1);
  color: var(--color-acento, #6366f1);
}

.bm-cal-nav button:disabled {
  opacity: 0.3;
  pointer-events: none;
}

.bm-cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}

.bm-cal-weekday {
  text-align: center;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-texto-suave, #888);
  padding: 8px 0;
}

.bm-cal-day {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  font-size: 0.85rem;
  border: none;
  background: transparent;
  color: var(--color-texto, #333);
  cursor: default;
  transition: all 0.2s;
  font-weight: 400;
}

.bm-cal-day.available {
  cursor: pointer;
  font-weight: 500;
}

.bm-cal-day.available:hover {
  background: color-mix(in srgb, var(--color-acento, #6366f1) 15%, transparent);
  color: var(--color-acento, #6366f1);
}

.bm-cal-day.today {
  color: var(--color-acento, #6366f1);
  font-weight: 600;
}

.bm-cal-day.disabled {
  opacity: 0.2;
  text-decoration: line-through;
  pointer-events: none;
}

.bm-cal-day.other-month {
  opacity: 0;
  pointer-events: none;
}

.bm-cal-day.selected {
  background: var(--color-acento, #6366f1);
  color: #fff;
  font-weight: 600;
}

.bm-cal-loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: color-mix(in srgb, var(--color-fondo, #fff) 80%, transparent);
  border-radius: 12px;
  z-index: 5;
}

.bm-spinner {
  width: 24px;
  height: 24px;
  border: 3px solid var(--color-borde, #e5e5e5);
  border-top-color: var(--color-acento, #6366f1);
  border-radius: 50%;
  animation: bm-spin 0.6s linear infinite;
}

@keyframes bm-spin {
  to { transform: rotate(360deg); }
}

/* Slot groups */
.bm-slot-group {
  margin-bottom: 16px;
}

.bm-slot-group-label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-texto-suave, #888);
  margin-bottom: 8px;
}

.bm-slots-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 8px;
}

.bm-slot {
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid var(--color-borde, #e5e5e5);
  background: var(--color-superficie, #f9f9f9);
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 500;
  text-align: center;
  color: var(--color-texto, #333);
  transition: all 0.2s;
}

.bm-slot:hover {
  border-color: var(--color-acento, #6366f1);
  transform: scale(1.02);
  box-shadow: 0 2px 8px color-mix(in srgb, var(--color-acento, #6366f1) 12%, transparent);
}

.bm-slot:active {
  transform: scale(0.98);
}

/* Form fields */
.bm-form-group {
  margin-bottom: 16px;
}

.bm-form-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--color-texto, #333);
  margin-bottom: 6px;
}

.bm-form-label .required {
  color: #ef4444;
  margin-left: 2px;
}

.bm-form-input {
  width: 100%;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid var(--color-borde, #e5e5e5);
  background: var(--color-superficie, #f9f9f9);
  color: var(--color-texto, #333);
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  font-family: var(--fuente-cuerpo, inherit);
}

.bm-form-input:focus {
  border-color: var(--color-acento, #6366f1);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-acento, #6366f1) 12%, transparent);
}

.bm-form-input.error {
  border-color: #ef4444;
}

.bm-form-error {
  font-size: 0.75rem;
  color: #ef4444;
  margin-top: 4px;
}

textarea.bm-form-input {
  resize: vertical;
  min-height: 60px;
}

/* Buttons */
.bm-btn-primary {
  width: 100%;
  padding: 12px 24px;
  border-radius: 12px;
  border: none;
  background: var(--color-acento, #6366f1);
  color: #fff;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  font-family: var(--fuente-cuerpo, inherit);
}

.bm-btn-primary:hover {
  background: var(--color-acento-hover, #4f46e5);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px color-mix(in srgb, var(--color-acento, #6366f1) 30%, transparent);
}

.bm-btn-primary:active {
  transform: scale(0.98);
}

.bm-btn-primary:disabled {
  opacity: 0.4;
  cursor: default;
  transform: none;
  box-shadow: none;
}

.bm-btn-secondary {
  width: 100%;
  padding: 12px 24px;
  border-radius: 12px;
  border: 1px solid var(--color-borde, #e5e5e5);
  background: transparent;
  color: var(--color-texto-suave, #888);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  font-family: var(--fuente-cuerpo, inherit);
}

.bm-btn-secondary:hover {
  border-color: var(--color-texto-suave, #888);
  color: var(--color-texto, #333);
}

/* Summary card (step 6) */
.bm-summary {
  background: var(--color-superficie, #f9f9f9);
  border: 1px solid var(--color-borde, #e5e5e5);
  border-radius: 16px;
  padding: 20px;
  margin-bottom: 24px;
  box-shadow: 0 0 20px color-mix(in srgb, var(--color-acento, #6366f1) 5%, transparent);
}

.bm-summary-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
}

.bm-summary-label {
  font-size: 0.85rem;
  color: var(--color-texto-suave, #888);
}

.bm-summary-value {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-texto, #333);
  text-align: right;
}

.bm-summary-divider {
  height: 1px;
  background: var(--color-borde, #e5e5e5);
  margin: 4px 0;
}

.bm-summary-total .bm-summary-value {
  font-size: 1rem;
  color: var(--color-acento, #6366f1);
}

/* Success screen */
.bm-success {
  text-align: center;
  padding: 20px 0;
}

.bm-success-check {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: var(--color-acento, #6366f1);
  color: #fff;
  font-size: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 20px;
  box-shadow: 0 0 30px color-mix(in srgb, var(--color-acento, #6366f1) 30%, transparent);
  animation: bm-pop 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes bm-pop {
  0% { transform: scale(0); }
  100% { transform: scale(1); }
}

.bm-success h2 {
  font-family: var(--fuente-titulo, inherit);
  font-size: 1.4rem;
  font-weight: 600;
  color: var(--color-texto, #333);
  margin-bottom: 8px;
}

.bm-success .bm-detail {
  font-size: 0.85rem;
  color: var(--color-texto-suave, #888);
  margin-bottom: 8px;
}

.bm-success .bm-info-box {
  background: color-mix(in srgb, var(--color-acento, #6366f1) 8%, var(--color-superficie, #f9f9f9));
  border-radius: 12px;
  padding: 14px 18px;
  font-size: 0.8rem;
  color: var(--color-texto-suave, #888);
  margin: 20px 0;
  line-height: 1.5;
}

.bm-success .bm-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 20px;
}

/* Error alert */
.bm-error {
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.2);
  border-radius: 12px;
  padding: 12px 16px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.8rem;
  color: #ef4444;
}

.bm-error button {
  margin-left: auto;
  padding: 6px 14px;
  border-radius: 8px;
  border: 1px solid rgba(239, 68, 68, 0.3);
  background: transparent;
  color: #ef4444;
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
}

.bm-error button:hover {
  background: rgba(239, 68, 68, 0.08);
}

/* Empty state */
.bm-empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--color-texto-suave, #888);
  font-size: 0.9rem;
}

/* Service meta (price, duration) */
.bm-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 4px;
}

.bm-price {
  font-weight: 700;
  color: var(--color-acento, #6366f1);
  font-size: 0.9rem;
}

.bm-duration {
  font-size: 0.8rem;
  color: var(--color-texto-suave, #888);
}

/* ============================================
   RESPONSIVE — mobile
   ============================================ */
@media (max-width: 768px) {
  .bm-modal {
    width: 100vw;
    /* fallback para Safari <15.4 */
    height: 100vh;
    max-height: 100vh;
    /* dynamic viewport height: respeta barra URL iOS/Safari */
    height: 100dvh;
    max-height: 100dvh;
    border-radius: 0;
    padding-bottom: env(safe-area-inset-bottom, 0);
  }

  .bm-layout {
    flex-direction: column;
  }

  .bm-sidebar {
    width: 100%;
    flex-direction: column;
    overflow-x: visible;
    /* derecha: hueco para que el contenido no quede bajo la X */
    padding: 14px 56px 14px 16px;
    gap: 0;
    border-right: none;
    border-bottom: 1px solid var(--color-borde, #e5e5e5);
  }

  .bm-sidebar-title {
    display: none;
  }

  /* Móvil: fuera la fila de 6 pasos (no cabía, scroll + choque con X);
   * dentro el indicador compacto "Paso N de M · Label" + barra. */
  .bm-step-item,
  .bm-step-connector {
    display: none;
  }
  .bm-progress-mobile {
    display: block;
  }

  .bm-step-item {
    flex-direction: column;
    gap: 4px;
    padding: 6px 10px;
    min-width: fit-content;
  }

  .bm-step-icon {
    width: 28px;
    height: 28px;
    font-size: 12px;
  }

  .bm-step-label {
    font-size: 0.65rem;
    white-space: nowrap;
  }

  .bm-step-connector {
    width: 16px;
    height: 2px;
    margin-left: 0;
    align-self: center;
  }

  .bm-content {
    padding: 20px 16px;
  }

  .bm-content-title {
    font-size: 1.1rem;
  }

  .bm-list {
    max-height: 45vh;
  }

  .bm-slots-grid {
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  }

  /* Prevenir zoom en iOS al enfocar inputs (requiere >= 16px) */
  .bm-form-input,
  .bm-form-select,
  .bm-content input,
  .bm-content select,
  .bm-content textarea {
    font-size: 16px;
  }

  /* Touch targets mínimos (Apple recomienda 44px) */
  .bm-slot {
    padding: 12px 14px;
    min-height: 44px;
  }

  .bm-list-item {
    min-height: 48px;
  }
}
