/* ==============================================================
   RESERVAS-AGENDA.CSS — TuEstilo
   Agenda / Timeline (grid 15 min, bloques, FAB, confirm-modal)
   Extraído de styles.css (Fase 2 — Refactorización CSS)
   ============================================================== */

.timeline-container {
  display: flex;
  position: relative;
  overflow-y: auto;
  background: #fafafa;
  flex: 1;
  min-height: 500px;
}

@media (min-width: 1024px) {
  .main-content-wrap {
    overflow-y: auto;
    min-height: 0;
  }

  /* Sin esto el sticky NUNCA funciona: main tiene overflow-hidden en el HTML y rompe el contexto del sticky */
  main {
    overflow: visible;
  }

  /* Tarjeta blanca y wrap: overflow visible para que el scroll sea .main-content-wrap y el sticky pueda pegarse */
  #reservas-table-container>div.overflow-hidden.rounded-2xl {
    overflow: visible !important;
  }

  #reservas-timeline-wrap {
    flex: 0 0 auto !important;
    overflow-y: visible !important;
    overflow-x: visible !important;
    min-height: 0;
  }

  .timeline-container {
    flex: 0 0 auto;
    overflow: visible;
    min-height: 0;
  }
}

/* Columna izquierda: horas; altura por fila desde JS (--agenda-hour-height) */
.timeline-hours-col {
  width: 60px;
  flex-shrink: 0;
  border-right: 1px solid var(--color-border);
  background: #fafafa;
  position: relative;
}

/* Cada fila ocupa toda la altura de la hora (para alinear con las 4 líneas del grid) */
.timeline-hour-row {
  height: var(--agenda-hour-height, 180px);
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  padding-right: 8px;
  padding-top: 0;
  padding-left: 4px;
  position: relative;
}

/* Etiqueta de hora principal (:00) */
.timeline-hour-label {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--color-text-secondary);
  line-height: 1;
  flex-shrink: 0;
  padding-top: 2px;
  height: calc(var(--agenda-hour-height, 180px) / 4);
  display: flex;
  align-items: center;
}

/* Sub-etiquetas de cuartos: 15, 30, 45 */
.timeline-quarter-label {
  font-size: 0.65rem;
  color: var(--color-text-placeholder);
  line-height: 1;
  flex-shrink: 0;
  height: calc(var(--agenda-hour-height, 180px) / 4);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  width: 100%;
}

/* Columna derecha: área de citas + líneas guía */
.timeline-grid-col {
  flex: 1;
  position: relative;
  min-width: 0;
}

/* Línea de hora en punto: sólida y bien marcada, altura = 1/4 de hourHeight */
.timeline-hour-line {
  position: absolute;
  left: 0;
  right: 0;
  border-top: 1.5px solid #cbd5e1;
  /* Sólida, más visible */
  box-sizing: border-box;
  pointer-events: none;
  z-index: 0;
}

/* Bloques de citas: diseño inteligente (layout estricto, jerarquía de fuentes, sin amontonamiento) */
.reservas-agenda-block,
.timeline-event {
  position: absolute;
  left: 8px;
  width: calc(100% - 16px);
  border-radius: 6px;
  padding: 4px 8px;
  border-left: 4px solid var(--color-primary-light);
  background-color: var(--color-primary-bg-light);
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.06);
  overflow: visible;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  gap: 1px;
  line-height: 1.2;
  transition: box-shadow 0.15s ease;
  z-index: 2;
  overflow: hidden;
}

@media (min-width: 1024px) {

  .reservas-agenda-block,
  .timeline-event {
    left: 8px;
    width: calc(100% - 16px);
    padding: 3px 8px;
    gap: 2px;
  }

  .reservas-agenda-block-time,
  .timeline-event .reservas-agenda-block-time {
    font-size: 0.7rem;
  }

  .reservas-agenda-block-client,
  .timeline-event .reservas-agenda-block-client {
    font-size: 0.8rem;
  }

  .reservas-agenda-block-service,
  .timeline-event .reservas-agenda-block-service {
    font-size: 0.75rem;
  }
}

.reservas-agenda-block:hover,
.timeline-event:hover {
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.06);
}

/* Hora: muy pequeña */
.reservas-agenda-block-time,
.timeline-event .reservas-agenda-block-time {
  font-size: 0.7rem;
  color: var(--color-text-light);
  font-weight: 600;
  flex-shrink: 0;
  line-height: 1.2;
}

/* Nombre del cliente: negrita y legible, ellipsis si es largo */
.reservas-agenda-block-client,
.timeline-event .reservas-agenda-block-client {
  font-size: 0.85rem;
  font-weight: 700;
  color: #1f2937;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex-shrink: 0;
  line-height: 1.2;
}

/* Servicio/precio: siempre visible; solo se oculta cuando hay "Solicitud enviada" para dar espacio al badge */
.reservas-agenda-block-service,
.timeline-event .reservas-agenda-block-service {
  font-size: 0.8rem;
  color: var(--color-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.2;
  flex-shrink: 1;
  min-height: 0;
}

.reservas-agenda-block--short .reservas-agenda-block-service,


/* En bloques cortos la línea de servicio no debe colapsar (flex-shrink: 0 y min-height para que siempre se vea) */
.reservas-agenda-block--short .reservas-agenda-block-service,
.timeline-event.reservas-agenda-block--short .reservas-agenda-block-service {
  flex-shrink: 0;
  min-height: 1.15em;
}

.timeline-event.waiting-confirmation .reservas-agenda-block-service,
.reservas-agenda-block.waiting-confirmation .reservas-agenda-block-service {
  display: none;
}

.reservas-agenda-block-badge {
  margin-top: 2px;
  align-self: flex-start;
  flex-shrink: 0;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  background: var(--color-warning-bg);
  color: var(--color-warning-dark);
  font-size: 0.65rem;
  font-weight: 600;
}

/* Badge "Solicitud enviada": píldora compacta (no desordena el flujo) */
.reservas-agenda-block-waiting-text {
  display: inline-block;
  font-size: 0.65rem;
  padding: 2px 6px;
  border-radius: 4px;
  align-self: flex-start;
  margin-top: 2px;
  background-color: #ffedd5;
  color: #c2410c;
  font-weight: 600;
  line-height: 1.2;
  flex-shrink: 0;
}

/* Estado "Esperando confirmación": borde naranja intermitente + fondo suave */
.timeline-event.waiting-confirmation,
.reservas-agenda-block.waiting-confirmation {
  border: 2px solid #f59e0b !important;
  background-color: #fffbeb !important;
  animation: pulse-border 2s infinite;
}

.reservas-smart-card.waiting-confirmation {
  border: 2px solid #f59e0b !important;
  background-color: #fffbeb !important;
  animation: pulse-border 2s infinite;
}

@keyframes pulse-border {
  0% {
    border-color: #f59e0b;
  }

  50% {
    border-color: #fcd34d;
  }

  100% {
    border-color: #f59e0b;
  }
}

/* Bloques de tiempo bloqueado (ej. almuerzo) - fondo amarillo/ámbar */
.timeline-block {
  position: absolute;
  left: 8px;
  width: calc(100% - 16px);
  border-radius: var(--radius-2xs);
  padding: 2px 10px;
  border-left: 4px solid #f59e0b;
  background-color: var(--color-warning-bg);
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.08);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  justify-content: center;
  white-space: normal;
  word-break: break-word;
  overflow-wrap: break-word;
  transition: box-shadow 0.15s ease;
  z-index: 2;
}

.timeline-block:hover {
  box-shadow: 0 4px 10px rgba(245, 158, 11, 0.2);
}

.timeline-block .reservas-agenda-block-time,
.timeline-block .reservas-agenda-block-client,
.timeline-block .reservas-agenda-block-service {
  color: var(--color-warning-dark);
  font-weight: 600;
  white-space: normal;
  word-break: break-word;
  overflow-wrap: break-word;
  overflow: hidden;
}

.timeline-block .reservas-agenda-block-client {
  font-size: 0.72rem;
  color: #78350f;
}

/* Espacios libres (huecos > 15 min) - gris claro, borde punteado */
.timeline-gap {
  position: absolute;
  background: transparent;
  border: none;
  padding: 0;
  pointer-events: none;
}

.timeline-gap .timeline-gap-label,
.timeline-gap .timeline-gap-time {
  display: none;
}

/* Variante por categoría (uñas = rosa, barbería = azul) */
.reservas-agenda-block--pink {
  border-left-color: #db2777;
  background-color: #fce7f3;
}

.reservas-agenda-block--pink .reservas-agenda-block-client {
  color: #831843;
}

.reservas-agenda-block--pink .reservas-agenda-block-service {
  color: #be185d;
}

.reservas-agenda-block--purple {
  border-left-color: #7c3aed;
  background-color: #ede9fe;
}

.reservas-agenda-block--purple .reservas-agenda-block-client {
  color: #4c1d95;
}

.reservas-agenda-block--purple .reservas-agenda-block-service {
  color: #6d28d9;
}

/* === CUADRÍCULA DE 15 MINUTOS === */

/* Sub-líneas de cuarto de hora: dashed claramente visibles */
.timeline-quarter-line {
  position: absolute;
  left: 0;
  right: 0;
  border-top: 1px dashed var(--color-text-disabled);
  /* Guión claramente visible */
  box-sizing: border-box;
  pointer-events: none;
  z-index: 0;
}

/* Slot vacío: solo muestra botón cuando .modo-bloqueo-activo está en el slot */
.timeline-empty-slot {
  position: absolute;
  left: 0;
  right: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.12s ease;
}

/* Hover solo en modo activo */
.timeline-empty-slot.modo-bloqueo-activo:hover {
  background: rgba(249, 115, 22, 0.05);
}

/* Botón "Bloquear": siempre oculto por defecto */
.timeline-empty-slot-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 12px;
  border-radius: var(--radius-pill);
  border: 1.5px solid #f97316;
  background: #fff7ed;
  color: #c2410c;
  font-size: 0.72rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  line-height: 1;
  min-height: 30px;
  opacity: 0;
  /* Siempre oculto */
  pointer-events: none;
  transition: opacity 0.12s ease, transform 0.1s ease;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

/* Solo mostrar cuando modo-bloqueo-activo está en el slot Y hay hover */
.timeline-empty-slot.modo-bloqueo-activo:hover .timeline-empty-slot-btn,
.timeline-empty-slot.modo-bloqueo-activo:focus-within .timeline-empty-slot-btn {
  opacity: 1;
  pointer-events: auto;
}

.timeline-empty-slot.modo-bloqueo-activo .timeline-empty-slot-btn:hover {
  background: #fed7aa;
  transform: scale(1.04);
}

/* En móvil con modo activo: siempre visible (no depende de hover) */
@media (max-width: 767px) {
  .timeline-empty-slot.modo-bloqueo-activo .timeline-empty-slot-btn {
    opacity: 1;
    pointer-events: auto;
  }
}

.timeline-lock-icon {
  font-size: 0.8rem;
  line-height: 1;
}

@media (max-width: 360px) {
  .timeline-lock-label {
    display: none;
  }
}

/* Variante visual para bloqueos rápidos: borde naranja + fondo ámbar tenue */
.timeline-block--quick-lock {
  border-left-color: #f97316;
  background-color: #fff7ed;
}

.timeline-block--quick-lock .reservas-agenda-block-time,
.timeline-block--quick-lock .reservas-agenda-block-client {
  color: #9a3412;
}

/* === Slot seleccionado (batch bloqueo) === */
.timeline-empty-slot.slot-selected {
  background: rgba(34, 197, 94, 0.12) !important;
  border: 2px solid #22c55e;
  border-radius: 6px;
  box-sizing: border-box;
}
.timeline-empty-slot.slot-selected .timeline-empty-slot-btn {
  opacity: 1 !important;
  pointer-events: auto !important;
  background: #dcfce7;
  border-color: #22c55e;
  color: #15803d;
}
.timeline-empty-slot.slot-selected .timeline-lock-icon::after {
  content: ' ✓';
  font-weight: 900;
}

/* === Botón flotante "Confirmar bloqueos" === */
.batch-bloqueo-confirm-btn {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  padding: 14px 28px;
  border: none;
  border-radius: var(--radius-pill, 999px);
  background: linear-gradient(135deg, #f97316, #ea580c);
  color: #fff;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(249, 115, 22, 0.4);
  transition: background 0.2s, transform 0.15s, box-shadow 0.2s;
  white-space: nowrap;
}
.batch-bloqueo-confirm-btn:hover {
  background: linear-gradient(135deg, #ea580c, #c2410c);
  transform: translateX(-50%) scale(1.03);
  box-shadow: 0 8px 24px rgba(249, 115, 22, 0.5);
}
.batch-bloqueo-confirm-btn:active {
  transform: translateX(-50%) scale(0.97);
}
.batch-bloqueo-confirm-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}
.batch-bloqueo-confirm-btn.hidden {
  display: none !important;
}

/* === FIN CUADRÍCULA 15 MIN === */

/* === FAB MODO BLOQUEO === */
.agenda-fab-bloqueo {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 2px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text-light);
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
  transition: background 0.2s, border-color 0.2s, color 0.2s, box-shadow 0.2s;
  flex-shrink: 0;
}

.agenda-fab-bloqueo:hover {
  background: #fff7ed;
  border-color: #f97316;
  color: #c2410c;
}

.agenda-fab-bloqueo.modo-bloqueo-activo {
  background: #f97316;
  border-color: #ea580c;
  color: var(--color-surface);
  box-shadow: 0 4px 16px rgba(249, 115, 22, 0.4);
}

.agenda-fab-bloqueo-icon {
  width: 22px;
  height: 22px;
}

/* === MODAL DE CONFIRMACIÓN (Estilo tarjeta redondeada) === */
.confirm-modal-card {
  background: var(--color-surface);
  border-radius: var(--radius-xl);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.18);
  padding: 28px 24px 24px;
  max-width: 320px;
  width: 100%;
  text-align: center;
  animation: confirm-modal-in 0.2s ease;
}

@keyframes confirm-modal-in {
  from {
    opacity: 0;
    transform: scale(0.92) translateY(10px);
  }

  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.confirm-modal-icon-wrap {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: #fff7ed;
  border: 2px solid #fed7aa;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
}

.confirm-modal-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  color: #f97316;
}

.confirm-modal-icon svg {
  width: 30px;
  height: 30px;
  stroke: #f97316;
}

.confirm-modal-title {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--color-text);
  margin: 0 0 8px;
  line-height: 1.3;
}

.confirm-modal-desc {
  font-size: 0.875rem;
  color: var(--color-text-light);
  margin: 0 0 22px;
  line-height: 1.5;
}

.confirm-modal-actions {
  display: flex;
  gap: 10px;
}

.confirm-modal-btn {
  flex: 1;
  padding: 11px 0;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  border: none;
  transition: background 0.15s, transform 0.1s;
}

.confirm-modal-btn:active {
  transform: scale(0.97);
}

.confirm-modal-btn--cancel {
  background: var(--color-border-light);
  color: var(--color-text-secondary);
}

.confirm-modal-btn--cancel:hover {
  background: var(--color-border);
}

.confirm-modal-btn--confirm {
  background: #f97316;
  color: var(--color-surface);
  box-shadow: 0 4px 12px rgba(249, 115, 22, 0.35);
}

.confirm-modal-btn--confirm:hover {
  background: #ea580c;
}

/* === FIN NUEVOS ESTILOS === */
.reservas-cat-badge--purple {
  background: #ede9fe;
  color: #5b21b6;
}

.reservas-cat-badge--gray {
  background: var(--color-border-light);
  color: var(--color-text-muted);
}

/* Legacy: mantener clases de acciones compartidas */
.reservas-appointment-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 16px;
  background: var(--color-surface);
  border-bottom: 1px solid #eee;
  min-height: 72px;
}

.reservas-appointment-card--today {
  border-left: 4px solid var(--color-primary);
}

.reservas-appointment-card--past {
  opacity: 0.85;
}

.reservas-card-time {
  width: 60px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.reservas-card-time-value {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--color-primary-deeper);
  line-height: 1.2;
}

.reservas-card-duration {
  font-size: 0.75rem;
  color: var(--color-text-light);
  margin-top: 2px;
}

.reservas-card-details {
  flex: 1;
  min-width: 0;
}

.reservas-card-client {
  font-size: 1rem;
  font-weight: 600;
  color: var(--color-text);
  line-height: 1.3;
}

.reservas-card-service {
  font-size: 0.9rem;
  color: var(--color-text-light);
  margin-top: 2px;
}

.reservas-card-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.reservas-card-wa {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-2xs);
  background: var(--color-success-bg-light);
  color: #16a34a;
  transition: background 0.2s, color 0.2s;
}

.reservas-card-wa:hover {
  background: #bbf7d0;
  color: #15803d;
}

.reservas-wa-icon {
  width: 18px;
  height: 18px;
}

/* Modal Detalles de Cita - ficha tipo ticket */
#cita-detail-valor {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--color-text);
}

.cita-detail-section {
  padding-bottom: 0.5rem;
}

.cita-detail-section:last-of-type {
  padding-bottom: 0;
}

.reservas-card-badge {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.2rem 0.5rem;
  border-radius: 6px;
  white-space: nowrap;
}

.reservas-card-badge--green {
  background: var(--color-success-bg-light);
  color: var(--color-success-dark);
}

.reservas-card-badge--yellow {
  background: var(--color-warning-bg-light);
  color: var(--color-warning-darker);
}

.reservas-card-badge--red {
  background: var(--color-danger-bg);
  color: var(--color-danger-darker);
}

.reservas-card-kebab-wrap {
  position: relative;
}

.reservas-card-kebab {
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: var(--color-text-light);
  font-size: 1.1rem;
  line-height: 1;
  border-radius: var(--radius-2xs);
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

.reservas-card-kebab:hover {
  background: var(--color-border-light);
  color: var(--color-text-secondary);
}

.reservas-card-kebab-menu {
  display: none;
  position: absolute;
  right: 0;
  top: 100%;
  margin-top: 4px;
  min-width: 140px;
  padding: 4px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-2xs);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  z-index: 10;
  flex-direction: column;
}

.reservas-card-kebab-menu.reservas-card-kebab-menu--open {
  display: flex;
}

.reservas-card-kebab-menu button {
  padding: 0.5rem 0.75rem;
  border: none;
  background: transparent;
  font-size: 0.875rem;
  text-align: left;
  color: var(--color-text-secondary);
  cursor: pointer;
  border-radius: 4px;
  transition: background 0.2s;
}

.reservas-card-kebab-menu button:hover {
  background: var(--color-border-light);
}

.reservas-card-kebab-menu .reservas-kebab-cancel {
  color: var(--color-danger);
}

.reservas-card-kebab-menu .reservas-kebab-cancel:hover {
  background: var(--color-danger-bg);
}

/* Dashboard Estadísticas: estilo Stripe/Revolut */
