/**
 * Filipa Novais - Terapias Integrativas
 * Estilos do Modal Frontend de Agendamento em 3 Passos (Totalmente Responsivo & Sem Scroll Horizontal)
 */

:root {
  --fn-modal-terracotta: #B45309;
  --fn-modal-terracotta-hover: #9A4308;
  --fn-modal-terracotta-light: #FEF3C7;
  --fn-modal-gold: #D97706;
  --fn-modal-dark: #1E293B;
  --fn-modal-muted: #64748B;
  --fn-modal-border: #E2E8F0;
  --fn-modal-bg-subtle: #F8FAFC;
  --fn-modal-surface: #FFFFFF;
}

/* Escopo do Modal */
.fn-modal-overlay,
.fn-modal-overlay * {
  box-sizing: border-box;
}

/* Overlay & Backdrop */
.fn-modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(15, 23, 42, 0.75);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 999999;
  align-items: center;
  justify-content: center;
  padding: 12px;
  opacity: 0;
  overflow-x: hidden;
  overflow-y: auto;
  transition: opacity 0.25s ease;
}

.fn-modal-overlay.is-visible {
  display: flex;
  opacity: 1;
}

/* Dialog Container */
.fn-modal-dialog {
  width: 100%;
  max-width: 960px;
  background-color: var(--fn-modal-surface);
  border-radius: 12px;
  box-shadow: 0 20px 45px -10px rgba(0, 0, 0, 0.35);
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 24px);
  margin: auto;
  overflow: hidden;
  transition: max-width 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  animation: fnModalScaleIn 0.28s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.fn-modal-dialog.step-compact {
  max-width: 580px;
}

@keyframes fnModalScaleIn {
  from {
    opacity: 0;
    transform: scale(0.96) translateY(6px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

/* Header */
.fn-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  background-color: var(--fn-modal-terracotta);
  color: #FFFFFF;
  flex-shrink: 0;
}

.fn-modal-header-title {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.3px;
  line-height: 1.3;
  color: #FFFFFF;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.fn-modal-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background-color: rgba(255, 255, 255, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: #FFFFFF;
  font-size: 20px;
  cursor: pointer;
  line-height: 1;
  flex-shrink: 0;
  transition: background-color 0.2s ease, transform 0.15s ease;
}

.fn-modal-close:hover {
  background-color: rgba(255, 255, 255, 0.3);
  transform: scale(1.05);
}

/* Steps Navigation */
.fn-modal-steps-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px 16px;
  gap: 8px;
  background-color: var(--fn-modal-bg-subtle);
  border-bottom: 1px solid var(--fn-modal-border);
  flex-shrink: 0;
}

.fn-step-nav-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.fn-step-circle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background-color: var(--fn-modal-border);
  color: var(--fn-modal-muted);
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
  transition: all 0.2s ease;
}

.fn-step-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--fn-modal-muted);
  white-space: nowrap;
}

.fn-step-divider {
  width: 24px;
  height: 1px;
  background-color: var(--fn-modal-border);
  flex-shrink: 1;
}

/* Active and Completed Step States */
.fn-step-nav-item.is-active .fn-step-circle {
  background-color: var(--fn-modal-terracotta);
  color: #FFFFFF;
}

.fn-step-nav-item.is-active .fn-step-label {
  color: var(--fn-modal-terracotta);
  font-weight: 700;
}

.fn-step-nav-item.is-completed .fn-step-circle {
  background-color: var(--fn-modal-gold);
  color: #FFFFFF;
}

.fn-step-nav-item.is-completed .fn-step-label {
  color: var(--fn-modal-gold);
}

/* Modal Body */
.fn-modal-body {
  padding: 20px;
  overflow-y: auto;
  overflow-x: hidden;
  flex: 1;
}

.fn-modal-step-pane {
  display: none;
  width: 100%;
}

.fn-modal-step-pane.is-visible {
  display: block;
}

/* ==========================================================================
   Passo 1: Layout com Informações à Esquerda
   ========================================================================== */
.fn-step1-main-layout {
  display: grid;
  grid-template-columns: 310px minmax(0, 1fr);
  gap: 24px;
  align-items: start;
  width: 100%;
}

@media (max-width: 860px) {
  .fn-step1-main-layout {
    grid-template-columns: 1fr;
    gap: 20px;
  }
}

/* Sidebar de Instruções */
.fn-step1-info-sidebar {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.fn-info-sidebar-title {
  font-size: 17px;
  font-weight: 700;
  color: #0F2851;
  margin: 0 0 4px 0;
  line-height: 1.3;
}

.fn-info-card {
  background-color: #F8FAFC;
  border-radius: 8px;
  border-left: 3px solid #0F2851;
  padding: 12px 14px;
}

.fn-info-card-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: #0F2851;
  margin-bottom: 6px;
}

.fn-info-card-text {
  margin: 0 0 4px 0;
  font-size: 12px;
  color: #334155;
  line-height: 1.45;
}

.fn-info-card-text:last-child {
  margin-bottom: 0;
}

.fn-info-card-subtext {
  margin: 4px 0 0 0;
  font-size: 11px;
  color: #64748B;
  line-height: 1.35;
}

.fn-info-status-icon {
  display: inline-block;
  margin-right: 4px;
}

.fn-color-red {
  color: #DC2626;
}

.fn-color-green {
  color: #16A34A;
}

.fn-info-steps-list {
  margin: 6px 0 0 16px;
  padding: 0;
  font-size: 12px;
  color: #334155;
  line-height: 1.55;
}

/* Área Interativa da Direita */
.fn-step1-interaction-area {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.fn-step1-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
  gap: 14px;
  width: 100%;
}

@media (max-width: 600px) {
  .fn-step1-grid {
    grid-template-columns: 1fr;
  }
}

.fn-step-calendar-card {
  border: 1px solid var(--fn-modal-border);
  border-radius: 8px;
  overflow: hidden;
  background-color: #FFFFFF;
}

.fn-step-calendar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background-color: var(--fn-modal-terracotta);
  color: #FFFFFF;
}

.fn-step-cal-arrow {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 4px;
  background-color: rgba(255, 255, 255, 0.2);
  border: none;
  color: #FFFFFF;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.fn-step-cal-arrow:hover {
  background-color: rgba(255, 255, 255, 0.35);
}

.fn-step-cal-month {
  font-size: 13px;
  font-weight: 700;
  text-transform: capitalize;
}

.fn-step-cal-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  padding: 6px 0;
  background-color: var(--fn-modal-bg-subtle);
  border-bottom: 1px solid var(--fn-modal-border);
  text-align: center;
  font-size: 10px;
  font-weight: 700;
  color: var(--fn-modal-muted);
}

.fn-step-cal-days {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  padding: 6px;
  gap: 3px;
}

.fn-step-cal-day {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}

/* Dias com vagas disponíveis (Verde Suave) */
.fn-step-cal-day.is-available {
  background-color: #ECFDF5;
  color: #065F46;
  border: 1px solid #A7F3D0;
}

.fn-step-cal-day.is-available:hover {
  background-color: #10B981;
  color: #FFFFFF;
  border-color: #10B981;
}

/* Dias sem vagas / fechados / passados (Vermelho Suave) */
.fn-step-cal-day.is-disabled {
  background-color: #FEF2F2;
  color: #991B1B;
  border: 1px solid #FECACA;
  cursor: not-allowed;
  opacity: 0.75;
}

.fn-step-cal-day.is-selected {
  background-color: #059669 !important;
  color: #FFFFFF !important;
  border-color: #059669 !important;
  font-weight: 700;
  box-shadow: 0 4px 10px rgba(5, 150, 105, 0.35);
}

.fn-step-cal-day.is-other-month {
  opacity: 0.15;
  background-color: transparent !important;
  border: none !important;
  pointer-events: none;
}

.fn-step-cal-day.is-today {
  box-shadow: inset 0 0 0 2px #059669;
  font-weight: 700;
}

/* Slots de Horário */
.fn-step-slots-card {
  border: 1px solid var(--fn-modal-border);
  border-radius: 8px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  background-color: #FFFFFF;
}

.fn-step-slots-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--fn-modal-dark);
  margin-bottom: 10px;
}

.fn-step-slots-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(78px, 1fr));
  gap: 8px;
  overflow-y: auto;
  max-height: 220px;
  padding-right: 2px;
}

/* Chip de Horário: Disponível (Verde) */
.fn-slot-chip {
  width: 100%;
  padding: 8px 4px;
  border-radius: 6px;
  background-color: #ECFDF5;
  color: #065F46;
  font-size: 12px;
  font-weight: 700;
  text-align: center;
  cursor: pointer;
  border: 1px solid #A7F3D0;
  transition: all 0.15s ease;
}

.fn-slot-chip:hover:not(.is-disabled) {
  background-color: #10B981;
  color: #FFFFFF;
  border-color: #10B981;
  transform: translateY(-1px);
}

.fn-slot-chip.is-selected {
  background-color: #059669 !important;
  color: #FFFFFF !important;
  border-color: #059669 !important;
  box-shadow: 0 4px 10px rgba(5, 150, 105, 0.35);
}

/* Chip de Horário: Indisponível / Ocupado (Vermelho) */
.fn-slot-chip.is-disabled {
  cursor: not-allowed;
  background-color: #FEF2F2;
  color: #DC2626;
  border: 1px solid #FECACA;
  text-decoration: line-through;
  opacity: 0.7;
}

.fn-step-slots-placeholder {
  font-size: 12px;
  color: var(--fn-modal-muted);
  text-align: center;
  margin: 24px auto;
  line-height: 1.5;
  grid-column: 1 / -1;
}

/* ==========================================================================
   Passo 2: Seus Dados
   ========================================================================== */
.fn-step2-summary-badge {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  padding: 10px 14px;
  border-radius: 8px;
  background-color: var(--fn-modal-bg-subtle);
  border: 1px solid var(--fn-modal-border);
  margin-bottom: 14px;
  gap: 8px;
  font-size: 12px;
  color: var(--fn-modal-dark);
}

.fn-step2-summary-badge strong {
  color: var(--fn-modal-terracotta);
}

.fn-step2-fields {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
}

.fn-field-group {
  display: flex;
  flex-direction: column;
  width: 100%;
}

.fn-field-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  color: var(--fn-modal-dark);
  margin-bottom: 5px;
}

.fn-field-input, .fn-field-textarea {
  width: 100%;
  padding: 9px 12px;
  border-radius: 6px;
  border: 1px solid var(--fn-modal-border);
  background-color: #FFFFFF;
  font-size: 13px;
  color: var(--fn-modal-dark);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.fn-field-input:focus, .fn-field-textarea:focus {
  outline: none;
  border-color: var(--fn-modal-terracotta);
  box-shadow: 0 0 0 2px rgba(180, 83, 9, 0.2);
}

.fn-field-textarea {
  resize: vertical;
}

.fn-field-error {
  margin-top: 3px;
  font-size: 11px;
  color: #EF4444;
}

/* ==========================================================================
   Passo 3: Conclusão
   ========================================================================== */
.fn-step3-content {
  padding: 16px 8px;
  text-align: center;
  width: 100%;
}

.fn-step3-success-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background-color: var(--fn-modal-terracotta-light);
  border: 2px solid var(--fn-modal-gold);
  color: var(--fn-modal-gold);
  font-size: 28px;
  margin-bottom: 12px;
}

.fn-step3-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--fn-modal-gold);
  margin: 0 0 6px 0;
}

.fn-step3-desc {
  font-size: 13px;
  color: var(--fn-modal-muted);
  max-width: 420px;
  margin: 0 auto 16px auto;
  line-height: 1.5;
}

.fn-step3-summary-card {
  max-width: 440px;
  margin: 0 auto 20px auto;
  padding: 14px 16px;
  border-radius: 8px;
  background-color: var(--fn-modal-bg-subtle);
  border: 1px solid var(--fn-modal-border);
  text-align: left;
  font-size: 13px;
  line-height: 1.6;
  color: var(--fn-modal-dark);
  word-break: break-word;
}

.fn-step3-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
}

/* Botões do Modal */
.fn-modal-footer {
  margin-top: 16px;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-shrink: 0;
}

.fn-modal-footer-split {
  justify-content: space-between;
}

.fn-modal-btn-next, .fn-modal-btn-confirm, .fn-modal-btn-close-final {
  padding: 9px 20px;
  border-radius: 6px;
  background-color: var(--fn-modal-terracotta);
  color: #FFFFFF;
  font-size: 13px;
  font-weight: 700;
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
}

.fn-modal-btn-next:hover:not(:disabled),
.fn-modal-btn-confirm:hover:not(:disabled),
.fn-modal-btn-close-final:hover {
  background-color: var(--fn-modal-terracotta-hover);
}

.fn-modal-btn-next:disabled, .fn-modal-btn-confirm:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.fn-modal-btn-back, .fn-modal-btn-new {
  padding: 9px 16px;
  border-radius: 6px;
  background-color: #FFFFFF;
  border: 1px solid var(--fn-modal-border);
  color: var(--fn-modal-dark);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.fn-modal-btn-back:hover, .fn-modal-btn-new:hover {
  background-color: var(--fn-modal-bg-subtle);
}

/* ==========================================================================
   Media Queries de Responsividade do Modal
   ========================================================================== */
@media (max-width: 520px) {
  .fn-modal-dialog {
    max-height: calc(100vh - 16px);
  }

  .fn-modal-header {
    padding: 12px 16px;
  }

  .fn-modal-body {
    padding: 14px 14px;
  }

  .fn-modal-steps-nav {
    padding: 10px 10px;
    gap: 4px;
  }

  .fn-step-label {
    font-size: 11px;
  }

  .fn-step-circle {
    width: 20px;
    height: 20px;
    font-size: 10px;
  }

  .fn-step-divider {
    width: 14px;
  }

  .fn-modal-footer-split {
    flex-direction: column-reverse;
    gap: 8px;
  }

  .fn-modal-footer-split button {
    width: 100%;
    text-align: center;
  }

  .fn-step3-actions {
    flex-direction: column;
  }

  .fn-step3-actions button {
    width: 100%;
  }
}
