/* 0. Garantir que o atributo hidden realmente esconda o modal */
.modal[hidden] {
  display: none !important;
}

/* 1. Exibir somente quando o hidden for removido */
.modal:not([hidden]) {
  display: grid;
  place-items: center;
}

/* 2. Seção de cursos (cards com preços) */
.courses-grid {
  display: grid;
  gap: 1.5rem;
  grid-template-columns: repeat(1, 1fr);
}

/* 2.1 Seção de pacotes (cards resumidos) */
.packages-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.5rem;
  padding: 1rem 0;
}

/* Breakpoints responsivos */
@media (max-width: 420px) {
  .courses-grid { grid-template-columns: 1fr; }
  .packages-grid { grid-template-columns: 1fr; }
}
@media (min-width: 421px) and (max-width: 1023px) {
  .courses-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 1024px) and (max-width: 1439px) {
  .courses-grid { grid-template-columns: repeat(5, 1fr); }
}
@media (min-width: 1440px) {
  .courses-grid { grid-template-columns: repeat(5, 1fr); }
}

/* 3. Estilo base dos cards */
.course-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  height: 100%;
  padding-bottom: 1rem;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}
.course-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 8px 20px rgba(0,0,0,0.4);
}
.course-card img {
  width: 64px;
  height: 64px;
  object-fit: cover;
  margin: 1rem auto 0;
}
.course-card h3 {
  font-size: 1rem;
  padding: 0 1rem;
  flex-grow: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-height: 60px;
  color: var(--text-primary);
  line-height: 1.3;
}

/* 3.1 Ajustes visuais quando o card estiver dentro do grid de pacotes */
.packages-grid .course-card {
  padding: 1.5rem 1rem;
  text-align: center;
}
.packages-grid .course-card h3 {
  color: var(--primary-color);
  font-weight: 700;
  font-size: 1.1rem;
  margin-bottom: .5rem;
}
.packages-grid .course-card p {
  font-size: .9rem;
  color: var(--text-secondary);
  margin: 0 .75rem 1rem;
  line-height: 1.4;
}
.packages-grid .course-card .btn-enroll {
  display: inline-block;
  background: var(--primary-color);
  color: var(--bg-dark);
  padding: .6rem 1rem;
  border-radius: 4px;
  font-weight: 600;
  font-size: .9rem;
  text-decoration: none;
  transition: background .3s ease, color .3s ease, border-color .3s ease;
}
.packages-grid .course-card .btn-enroll:hover {
  background: transparent;
  color: var(--secondary-color);
  border: 1px solid var(--secondary-color);
}

/* 4. Layout de preços (cards de cursos com preço) */
.course-pricing {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: 0 1rem;
  margin-bottom: 0.5rem;
}
.course-pricing .original-price {
  font-size: 0.9rem;
  color: var(--text-secondary);
  text-decoration: line-through;
}
.course-pricing .installment-price {
  font-size: 0.9rem;
  color: var(--primary-color);
  margin-top: 0.25rem;
}
.course-pricing .label-upfront {
  font-size: 1rem;
  color: var(--secondary-color);
  margin-top: 0.5rem;
  font-weight: 500;
}
.course-pricing .final-price {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--secondary-color);
  line-height: 1;
}

/* 5. Botão de inscrição (cards de cursos) */
.btn-enroll {
  display: block;
  width: 90%;
  max-width: 220px;
  margin: 0.75rem auto 0 auto;
  padding: 0.5rem 0;
  background: var(--primary-color);
  color: var(--bg-dark);
  text-align: center;
  border-radius: 4px;
  font-size: 0.875rem;
  font-weight: 600;
  transition: background 0.3s ease, color 0.3s ease;
}
.btn-enroll:hover {
  background: transparent;
  color: var(--secondary-color);
}

/* 6. Modal e formulário */
.modal {
  position: fixed;
  inset: 0;
  z-index: 2000;
}
.modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.7);
}
.modal-content {
  position: relative;
  background: var(--bg-card);
  padding: 2rem;
  border-radius: 8px;
  width: 90%;
  max-width: 400px;
  color: var(--text-primary);
  z-index: 2001;
  max-height: 92vh;             /* scroll interno quando necessário */
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
#modal-course-title {
  color: var(--primary-color);
  text-align: center;
  font-weight: 700;
  margin-bottom: 0.75rem;
}
.modal-content h3 + form .form-group { margin-top: 1rem; }
.modal-close {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  background: none;
  border: none;
  color: var(--close-aba);
  font-size: 1.5rem;
  cursor: pointer;
}

.modal-pacote label {
  display: flex;
  align-items: center;
  gap: 8px; /* espaço entre o checkbox e o texto */
  min-height: 24px; /* altura fixa para alinhar com os demais */
  line-height: 1.4;
}

.modal-pacote input[type="checkbox"] {
  flex-shrink: 0;
}
.form-group {
  display: block;
  margin-bottom: 1.25rem;
}

/* ===== AJUSTE DOS INPUTS (maiores) ===== */
.form-group input,
.phone-input input[type="tel"],
.input-container input {
  width: 100%;
  height: 56px;               /* altura aumentada */
  padding: 0 14px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  background: var(--bg-dark);
  color: var(--text-primary);
  font-size: 1rem;
}

/* Linha divisória do modal */
.modal-content hr {
  border: none;
  height: 2px;
  background-color: var(--primary-color);
  margin: 1.5rem 0;
}

/* Select com a mesma altura dos inputs */
.form-group select {
  width: 100%;
  height: 56px;
  padding: 0 14px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  background: var(--bg-dark);
  color: var(--primary-color);
  font-family: var(--font-family);
  font-size: 1rem;
  margin-top: 0.25rem;
}
.form-group select:invalid { color: var(--text-secondary); }

.flag-icon { width: 24px; height: auto; margin-right: 0.5rem; }
.phone-input, .people-name, .email-form { display: flex; align-items: center; }

.input-container { position: relative; display: inline-block; }
.input-container input:focus { outline: none; }
.input-container::before {
  content: "";
  position: absolute;
  top: -2px; left: -2px;
  width: calc(100% + 4px); height: calc(100% + 4px);
  border: 2px solid var(--primary-color);
  border-radius: 4px;
  box-sizing: border-box;
  clip-path: inset(0 100% 100% 0);
  transition: clip-path 0.9s ease;
  z-index: 1;
}
.input-container:hover::before,
.input-container:focus-within::before { clip-path: inset(0); }

.form-note { display: block; margin-top: 0.25rem; font-size: 0.75rem; color: var(--text-secondary); }

/* Especificações do curso/pacote no modal */
.course-spec { margin: .5rem 0 1rem; line-height: 1.5; }
#modal-course-spec {
  max-height: 28vh;
  overflow-y: auto;
  padding-right: .25rem;
}
.course-spec h4 { margin:.75rem 0 .25rem; font-weight:600; }
.course-spec ul { margin:0; padding-left:1.25rem; }
.course-spec li { margin:.15rem 0; }

/* Centralização do formulário no modal */
#enroll-form {
  display: flex;
  flex-direction: column;
  align-items: center;
}
#enroll-form .form-group {
  width: 100%;
  max-width: 360px;          /* inputs mais largos */
}

/* Builder - Monte seu pacote */
#custom-builder { margin-bottom: 1.5rem; } /* espaço maior após a lista */
#custom-builder .module-list {
  display: grid;
  gap: .6rem;
  max-height: 40vh;
  overflow-y: auto;
  padding-right: .25rem;
}
#custom-builder .module-list label {
  display: flex;
  align-items: center;
  gap: .5rem;
  line-height: 1.35;
}
#custom-builder .module-list input[type="checkbox"] {
  inline-size: 18px;
  block-size: 18px;
}

/* Animação do fechar */
@keyframes spinAnti { from { transform: rotate(0deg); } to { transform: rotate(-360deg); } }
.modal-close.spin { animation: spinAnti 0.4s ease-in-out forwards; }

/* Seleção de texto */
::selection { background-color: var(--primary-color); color: var(--bg-dark); }
::-moz-selection { background-color: var(--primary-color); color: var(--bg-dark); }
input::selection, textarea::selection { background-color: var(--primary-color); color: var(--bg-dark); }

/* ======= MOBILE TUNING ======= */
@media (max-width: 480px){
  .modal-content{
    width: 96%;
    padding: 1rem 1rem 1.25rem;
    border-radius: 10px;
    max-height: 94vh;
  }
  #modal-course-title{
    font-size: 1.1rem;
    margin-bottom: .5rem;
  }
  #modal-course-spec{
    max-height: 24vh;
  }
  #custom-builder .module-list{
    max-height: 46vh;
  }
  .form-group{
    margin-bottom: 1rem;
  }
  #whatsapp-link.btn-enroll{
    width: 100%;
    max-width: none;
  }
}

/* ======= ESTÉTICA OPCIONAL DA BARRA DE ROLAGEM ======= */
#modal-course-spec::-webkit-scrollbar,
#custom-builder .module-list::-webkit-scrollbar{
  width: 8px;
}
#modal-course-spec::-webkit-scrollbar-thumb,
#custom-builder .module-list::-webkit-scrollbar-thumb{
  background: var(--border-color);
  border-radius: 8px;
}

/* ======= Ampliar o modal (desktop/tablet) ======= */
@media (min-width: 640px) {
  .modal-content{
    max-width: 520px;      /* antes ~400px */
    padding: 2rem 2rem;    /* um pouco mais de respiro lateral */
  }
  #enroll-form .form-group{
    max-width: 420px;      /* acompanha a nova largura do modal */
  }
}

/* ainda maior em desktops largos */
@media (min-width: 1024px) {
  .modal-content{
    max-width: 560px;
  }
  #enroll-form .form-group{
    max-width: 460px;
  }
}

/* mantém mobile exatamente como está */
@media (max-width: 480px){
  .modal-content{
    width: 96%;
    padding: 1rem 1rem 1.25rem;
    border-radius: 10px;
    max-height: 94vh;
  }
}
#custom-builder .module-list{ max-height: 44vh; }         /* antes 40vh */
@media (max-width: 480px){
  #custom-builder .module-list{ max-height: 50vh; }        /* antes 46vh */
}