/* ─── Página agendar ─── */
.agendar-page {
  padding: calc(var(--header-height, 76px) + 2rem) 0 4rem;
  background: linear-gradient(180deg, #e8f0f8 0%, var(--light) 35%, var(--light) 100%);
  min-height: 100vh;
}

.agendar-page .section-title h2 {
  color: var(--blue);
}

/* ─── Layout 50/50 ─── */
.agendar-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  align-items: stretch;
  min-height: 640px;
}

.agendar-calendar-panel,
.agendar-form-panel {
  position: relative;
  background: var(--white);
  border-radius: 20px;
  padding: 1.75rem;
  box-shadow: 0 16px 48px rgba(24, 86, 138, 0.12);
  border: 1px solid rgba(24, 86, 138, 0.08);
  display: flex;
  flex-direction: column;
  min-height: 640px;
  overflow: hidden;
}

.agendar-calendar-panel::before,
.agendar-form-panel::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--blue), #2a7ab8);
}

.panel-step {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--white);
  background: var(--blue);
  padding: 0.3rem 0.65rem;
  border-radius: 999px;
  margin-bottom: 0.5rem;
  width: fit-content;
}

.agendar-calendar-panel h3,
.agendar-form-panel h3 {
  margin: 0 0 1.25rem;
  color: var(--gray);
  font-size: 1.35rem;
  font-weight: 700;
}

/* ─── Tarjeta del calendario ─── */
.picker-calendar {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.calendar-card {
  flex: 1;
  display: flex;
  flex-direction: column;
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid rgba(24, 86, 138, 0.12);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
  background: #fafcfe;
}

.calendar-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 1rem 1.1rem;
  background: linear-gradient(135deg, var(--blue) 0%, #1e6a9e 100%);
  color: var(--white);
}

.calendar-toolbar-center {
  text-align: center;
  flex: 1;
}

.calendar-toolbar-label {
  display: block;
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  opacity: 0.85;
  margin-bottom: 0.15rem;
}

.calendar-toolbar h4 {
  margin: 0;
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--white);
  text-transform: capitalize;
  line-height: 1.2;
}

.calendar-nav {
  width: 42px;
  height: 42px;
  flex-shrink: 0;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.12);
  color: var(--white);
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, border-color 0.2s, transform 0.15s;
}

.calendar-nav:hover {
  background: var(--white);
  color: var(--blue);
  border-color: var(--white);
  transform: scale(1.05);
}

.calendar-nav:active {
  transform: scale(0.96);
}

.calendar-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 0.85rem 0.75rem 0.75rem;
  min-height: 0;
}

.calendar-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  margin-bottom: 8px;
}

.calendar-weekday {
  text-align: center;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--white);
  background: var(--gray);
  padding: 0.5rem 0;
  border-radius: 8px;
}

.calendar-weekday:nth-child(6) {
  background: #5a6270;
}

.calendar-weekday:nth-child(7) {
  background: #6b7280;
  opacity: 0.85;
}

.calendar-days {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  grid-template-rows: repeat(6, 1fr);
  gap: 6px;
  flex: 1;
  min-height: 300px;
}

.calendar-day {
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  font-size: 1.05rem;
  font-weight: 700;
  min-height: 48px;
  position: relative;
}

.calendar-day--empty {
  pointer-events: none;
  background: transparent;
}

.calendar-day--btn {
  border: none;
  background: var(--white);
  color: var(--gray);
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(24, 86, 138, 0.08);
  transition:
    background 0.2s,
    color 0.2s,
    box-shadow 0.2s,
    transform 0.15s;
}

.calendar-day--btn:hover:not(.calendar-day--disabled):not(.calendar-day--selected) {
  background: #e8f4fc;
  color: var(--blue);
  box-shadow: 0 4px 14px rgba(24, 86, 138, 0.2);
  transform: translateY(-2px);
}

.calendar-day--today:not(.calendar-day--selected) {
  background: linear-gradient(145deg, #fff 0%, #e8f4fc 100%);
  color: var(--blue);
  box-shadow: 0 0 0 2px var(--blue), 0 4px 12px rgba(24, 86, 138, 0.15);
}

.calendar-day--today:not(.calendar-day--selected)::after {
  content: "";
  position: absolute;
  bottom: 6px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--blue);
}

.calendar-day--selected {
  background: linear-gradient(145deg, var(--blue) 0%, #1a5f94 100%) !important;
  color: var(--white) !important;
  box-shadow: 0 6px 20px rgba(24, 86, 138, 0.45) !important;
  transform: scale(1.06);
  z-index: 1;
}

.calendar-day--disabled {
  background: #f3f4f5 !important;
  color: #c5c8cb !important;
  box-shadow: none !important;
  cursor: not-allowed;
  opacity: 1;
}

.calendar-day--full {
  background: #fde8e8 !important;
  color: #b42318 !important;
  box-shadow: none !important;
  cursor: not-allowed;
}

/* ─── Leyenda ─── */
.calendar-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem 1rem;
  list-style: none;
  margin: 1rem 0 0;
  padding: 0;
  font-size: 0.78rem;
  color: var(--gray);
}

.calendar-legend li {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.legend-dot--available {
  background: var(--white);
  box-shadow: 0 0 0 2px rgba(24, 86, 138, 0.25);
}

.legend-dot--today {
  background: var(--blue);
  box-shadow: 0 0 0 2px rgba(24, 86, 138, 0.3);
}

.legend-dot--selected {
  background: var(--blue);
}

.legend-dot--disabled {
  background: #e0e2e5;
}

.legend-dot--full {
  background: #f5b4b4;
  box-shadow: 0 0 0 2px rgba(180, 35, 24, 0.2);
}

/* ─── Fecha seleccionada ─── */
.selected-date-label {
  margin-top: 1rem;
  padding: 1rem 1.1rem;
  background: linear-gradient(135deg, #f0f6fb 0%, #e8f0f8 100%);
  border-radius: 14px;
  border: 1px solid rgba(24, 86, 138, 0.15);
  display: flex;
  align-items: center;
  gap: 1rem;
}

.selected-date-icon {
  font-size: 1.75rem;
  line-height: 1;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--white);
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(24, 86, 138, 0.1);
}

.selected-date-title {
  display: block;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--gray);
  opacity: 0.85;
  margin-bottom: 0.2rem;
}

.selected-date-label strong {
  color: var(--blue);
  display: block;
  font-size: 1rem;
  font-weight: 700;
  text-transform: capitalize;
  line-height: 1.3;
}

/* ─── Formulario ─── */
.agendar-form-panel form {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  min-height: 0;
}

.form-time-block {
  padding: 1rem;
  background: linear-gradient(135deg, #f8fafc 0%, #f0f6fb 100%);
  border-radius: 14px;
  border: 1px solid rgba(24, 86, 138, 0.1);
  margin-bottom: 0.25rem;
}

.form-time-block h4 {
  margin: 0 0 0.5rem;
  font-size: 1rem;
  color: var(--blue);
  font-weight: 700;
}

#dayStatus {
  font-size: 0.85rem;
  color: var(--gray);
  margin: 0 0 0.65rem;
}

.slots-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
  gap: 0.5rem;
  max-height: 180px;
  overflow-y: auto;
  padding-right: 4px;
}

.slots-grid::-webkit-scrollbar {
  width: 6px;
}

.slots-grid::-webkit-scrollbar-thumb {
  background: rgba(24, 86, 138, 0.25);
  border-radius: 4px;
}

.slots-placeholder {
  grid-column: 1 / -1;
  margin: 0;
  font-size: 0.9rem;
  color: var(--gray);
  text-align: center;
  padding: 1.25rem 0;
  font-style: italic;
}

.slot-btn {
  padding: 0.7rem 0.35rem;
  border: 2px solid rgba(24, 86, 138, 0.2);
  border-radius: 10px;
  background: var(--white);
  cursor: pointer;
  font-weight: 700;
  font-size: 0.88rem;
  color: var(--blue);
  transition: all 0.15s;
}

.slot-btn:hover:not(:disabled) {
  background: var(--blue);
  color: var(--white);
  border-color: var(--blue);
  transform: translateY(-1px);
}

.slot-btn.selected {
  background: var(--blue);
  color: var(--white);
  border-color: var(--blue);
  box-shadow: 0 4px 12px rgba(24, 86, 138, 0.35);
}

.slot-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  text-decoration: line-through;
  background: #f5f5f5;
}

.form-service-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.85rem;
  flex: 0 0 auto;
}

.form-service-field {
  flex: 0 0 auto;
  min-width: 0;
}

.form-service-field label {
  font-size: 0.88rem;
  margin-bottom: 0.35rem;
  display: block;
}

.form-service-field select {
  width: 100%;
}

.form-fields-block {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  overflow-y: auto;
  padding-right: 4px;
}

.form-fields-block label {
  font-size: 0.88rem;
  margin-bottom: -0.35rem;
}

.form-captcha {
  margin: 0.5rem 0 0.25rem;
}

.agendar-form-panel .btn-primary {
  margin-top: auto;
  width: 100%;
  padding: 0.95rem;
  font-size: 1.05rem;
}

/* ─── Modal éxito ─── */
.agendar-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
}

.agendar-modal[hidden] {
  display: none !important;
}

body.agendar-modal-open {
  overflow: hidden;
}

.agendar-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(68, 73, 77, 0.55);
  backdrop-filter: blur(4px);
}

.agendar-modal-dialog {
  position: relative;
  z-index: 1;
  width: min(420px, 100%);
  background: var(--white);
  border-radius: 20px;
  padding: 2rem 1.75rem 1.75rem;
  text-align: center;
  box-shadow: 0 24px 64px rgba(24, 86, 138, 0.28);
  border: 1px solid rgba(24, 86, 138, 0.12);
  animation: agendarModalIn 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes agendarModalIn {
  from {
    opacity: 0;
    transform: translateY(16px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.agendar-modal-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto 1rem;
  border-radius: 50%;
  background: linear-gradient(145deg, #18568a, #2a7ab8);
  color: var(--white);
  font-size: 2rem;
  font-weight: 700;
  line-height: 64px;
}

.agendar-modal-dialog h3 {
  margin: 0 0 0.75rem;
  color: var(--blue);
  font-size: 1.45rem;
}

.agendar-modal-dialog p {
  margin: 0 0 1.5rem;
  color: var(--gray);
  line-height: 1.55;
  font-size: 0.98rem;
}

.agendar-modal-btn {
  width: 100%;
  max-width: 220px;
}

/* ─── Responsive ─── */
@media (max-width: 960px) {
  .agendar-layout {
    grid-template-columns: 1fr;
    min-height: auto;
  }

  .agendar-calendar-panel,
  .agendar-form-panel {
    min-height: auto;
  }

  .calendar-days {
    min-height: 260px;
  }

  .calendar-day {
    min-height: 42px;
    font-size: 0.92rem;
    border-radius: 10px;
  }

  .calendar-legend {
    justify-content: center;
  }

  .form-service-row {
    grid-template-columns: 1fr;
  }
}
