.cpf-popup-overlay {
  display: flex;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  align-items: center;
  justify-content: center;
  z-index: 9999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease-in-out;
  padding: 16px;
  box-sizing: border-box;
}

.cpf-popup-overlay.active { opacity: 1; pointer-events: auto; }

.cpf-popup-content {
  background: #fff;
  padding: 22px 26px;
  border-radius: 14px;
  text-align: left;
  max-width: 520px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 10px 35px rgba(0,0,0,0.25);
  box-sizing: border-box;
}

.cpf-popup-title {
  font-size: 20px;
  font-weight: 700;
  text-align: center;
  margin-bottom: 4px;
  line-height: 1.3;
}

.cpf-popup-subheading {
  text-align: center;
  font-size: 12.5px;
  margin-bottom: 14px;
  color: #666;
}

/* ==================== Form Layout ==================== */
.cpf-form {
  display: flex;
  flex-direction: column;
}

.cpf-field-full {
  width: 100%;
  margin-bottom: 6px;
}

/* Grid for Email / Age / Height / Weight — 2 columns on large screens */
.cpf-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 14px;
  margin-bottom: 4px;
}

.cpf-field {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.cpf-form label {
  display: block;
  font-size: 13px;
  color: #333;
  font-weight: 500;
  margin: 6px 0 4px;
}

.required { color: #e63946; }

.cpf-form input,
.cpf-form select {
  width: 100%;
  box-sizing: border-box;
  padding: 9px 10px;
  border: 1px solid #d5d5d5;
  border-radius: 8px;
  font-size: 13.5px;
  background: #fafafa;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.cpf-form input:focus,
.cpf-form select:focus {
  outline: none;
  border-color: #00a093;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(0, 160, 147, 0.12);
}

.cpf-form input::placeholder { color: #9a9a9a; }

/* ==================== Phone Field ==================== */
.cpf-phone-wrapper {
  display: flex;
  gap: 8px;
  align-items: flex-start;
}

.cpf-country-select { flex: 0 0 40%; max-width: 40%; }

#cpfCountryCode {
  width: 100%;
  padding: 9px 10px;
  border: 1px solid #d5d5d5;
  border-radius: 8px;
  font-size: 12.5px;
}

#cpfCustomCode {
  width: 100%;
  margin-top: 5px;
  padding: 9px 10px;
  border: 1px solid #d5d5d5;
  border-radius: 8px;
  font-size: 13px;
  display: none; /* Hidden until "Other" is selected */
}

.cpf-phone-wrapper input[type="tel"] { flex: 1 1 60%; }

/* ==================== Gender ==================== */
.cpf-gender-inline {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.cpf-gender-label { margin: 0 !important; }

.cpf-gender-inline label {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 13.5px;
  font-weight: 400;
  cursor: pointer;
}

.cpf-gender-inline input[type="radio"] {
  width: auto;
  margin: 0;
  accent-color: #00a093;
}

/* ==================== Submit Button ==================== */
.cpf-submit {
  background: #00a093;
  color: #fff;
  padding: 11px 14px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  width: 100%;
  font-weight: 600;
  font-size: 14.5px;
  margin-top: 12px;
  transition: background 0.25s ease, transform 0.1s ease;
}

.cpf-submit:hover { background: #007a70; }
.cpf-submit:active { transform: scale(0.98); }

.cpf-popup-close {
  margin-top: 12px;
  text-align: center;
  cursor: pointer;
  font-size: 13px;
  color: #666;
  transition: color 0.2s ease;
}

.cpf-popup-close:hover { color: #222; }

/* ==================== Spinner ==================== */
.cpf-spinner,
.spinner {
  border: 2px solid #f3f3f3;
  border-top: 2px solid #00a093;
  border-radius: 50%;
  width: 16px;
  height: 16px;
  margin: 0 auto;
  display: inline-block;
  vertical-align: middle;
  animation: cpf-spin 0.8s linear infinite;
}

@keyframes cpf-spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.cpf-popup-success {
  display: none;
  color: #1a8f4c;
  font-weight: 500;
  font-size: 13.5px;
  margin-top: 8px;
}

/* ==================== Responsive Breakpoints ==================== */

/* Tablets and small laptops: keep 2 columns but tighten spacing */
@media (max-width: 600px) {
  .cpf-popup-content {
    padding: 18px 18px;
    border-radius: 12px;
  }

  .cpf-popup-title { font-size: 17px; }

  .cpf-form-grid { gap: 0 10px; }
}

/* Phones: collapse to a single column for Email/Age/Height/Weight */
@media (max-width: 480px) {
  .cpf-form-grid {
    grid-template-columns: 1fr;
    gap: 0;
  }

  .cpf-phone-wrapper {
    flex-direction: column;
  }

  .cpf-country-select {
    flex: 1 1 100%;
    max-width: 100%;
  }

  .cpf-phone-wrapper input[type="tel"] {
    flex: 1 1 100%;
  }

  .cpf-popup-content {
    padding: 16px;
  }

  .cpf-form input,
  .cpf-form select {
    font-size: 14px; /* avoids iOS zoom-on-focus */
  }
}

/* Very small screens */
@media (max-width: 340px) {
  .cpf-popup-title { font-size: 16px; }
  .cpf-popup-subheading { font-size: 11.5px; }
}