/* Custom styles for the CTA jQuery UI Dialog */
@keyframes fadeInDialog {
  from { opacity: 0; }
  to { opacity: 1; }
}

.ui-dialog:has(.cta-popup-inner) {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  max-width: 100vw !important;
  max-height: 100vh !important;
  background-color: #9DB075 !important;
  border: none !important;
  border-radius: 0 !important;
  padding: 0 !important;
  margin: 0 !important;
  z-index: 10000 !important;
  box-sizing: border-box;
  animation: fadeInDialog 0.3s ease-in-out;
  overflow-y: auto !important;
  -webkit-overflow-scrolling: touch;
}

.ui-dialog:has(.cta-popup-inner) .ui-dialog-titlebar {
  display: none !important;
}

.ui-dialog:has(.cta-popup-inner) .ui-dialog-content {
  width: 100% !important;
  height: 100% !important;
  min-height: 100vh !important;
  padding: 0 !important;
  overflow: visible !important;
  display: flex !important;
  align-items: stretch !important;
  justify-content: center !important;
}

/* Inner structure */
.cta-popup-inner {
  width: 100%;
  max-width: 1400px;
  height: 100%;
  min-height: 100vh;
  margin: 0 auto;
  padding: 60px 50px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-sizing: border-box;
}

/* Ensure Webform AJAX wrappers stretch to fill the dialog */
#webform-submission-cta-popup-form-form-ajax-content,
.webform-ajax-form-wrapper {
  width: 100%;
  height: 100%;
  min-height: 100%;
  display: flex;
  flex-direction: column;
}

.cta-popup-header {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  width: 100%;
}

.cta-popup-close-btn {
  display: inline-flex !important;
  align-items: center !important;
  gap: 12px !important;
  text-decoration: none !important;
  cursor: pointer !important;
  background: transparent !important;
  border: none !important;
  outline: none !important;
  box-shadow: none !important;
  padding: 0 !important;
  color: #ffffff !important;
  -webkit-tap-highlight-color: transparent;
}

.cta-popup-close-btn::before {
  content: '' !important;
  display: inline-block !important;
  width: 19px !important;
  height: 14px !important;
  min-width: 19px !important;
  background-image: url("data:image/svg+xml,%3Csvg width='19' height='14' viewBox='0 0 19 14' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M7.5 1L1 7L7.5 13M1 7H18.5' stroke='%23ffffff' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") !important;
  background-repeat: no-repeat !important;
  background-position: center !important;
  background-size: contain !important;
  flex-shrink: 0 !important;
  transition: opacity 0.3s ease, transform 0.2s ease;
}

.cta-popup-close-btn:focus,
.cta-popup-close-btn:focus-visible,
.cta-popup-close-btn:active {
  outline: none !important;
  box-shadow: none !important;
  border: none !important;
}

.cta-popup-close-btn span {
  font-family: 'Onest', 'Roboto', sans-serif !important;
  font-size: 20px !important;
  font-weight: 400 !important;
  color: #ffffff !important;
  transition: opacity 0.3s ease;
  line-height: 1.2;
}

.cta-popup-close-btn:hover span,
.cta-popup-close-btn:hover::before {
  opacity: 0.8 !important;
}

.cta-popup-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 50px;
  width: 100%;
  margin: 30px 0;
}

.cta-popup-title {
  font-family: 'Onest', sans-serif;
  font-weight: 700;
  font-size: 48px;
  line-height: 1.1;
  color: #ffffff;
  text-align: center;
  max-width: 650px;
  margin: 0;
}

/* Form Styles */
.webform-submission-cta-popup-form-add-form {
  width: 100%;
  height: 100%;
  min-height: 100%;
  display: flex;
  flex-direction: column;
}

.cta-form-row {
  display: flex;
  flex-direction: row;
  justify-content: center;
  align-items: center;
  gap: 30px;
  width: 100%;
}

.cta-form-row > div {
  flex: 1;
  display: flex !important; /* Override dialog.ajax.js hiding .form-actions */
  margin: 0 !important;
}

.ui-dialog:has(.cta-popup-inner) .ui-dialog-buttonpane {
  display: none !important; /* Hide the fake buttons created by dialog.ajax.js */
}

.cta-form-row .form-item-name input,
.cta-form-row .form-item-email input,
.cta-form-row .form-item-phone input {
  height: 67px;
  font-family: 'Onest', 'Roboto', sans-serif;
  font-size: 18px;
  color: #151313;
  width: 100%;
  border-radius: 90px;
  border: none;
  background: #FFFFFF;
  padding: 0 35px;
  box-sizing: border-box;
}

.cta-form-row input:-webkit-autofill,
.cta-form-row input:-webkit-autofill:hover,
.cta-form-row input:-webkit-autofill:focus,
.cta-form-row input:-webkit-autofill:active {
  -webkit-box-shadow: 0 0 0 1000px white inset !important;
  -webkit-text-fill-color: #151313 !important;
  transition: background-color 5000s ease-in-out 0s;
  border-radius: 90px;
}

.cta-form-row input::placeholder {
  color: #A2A2A2;
  font-family: 'Onest', 'Roboto', sans-serif;
  font-size: 18px;
}

.cta-form-row input:focus {
  outline: none;
}

.cta-form-row .form-actions {
  flex: 1;
}

.cta-form-row .form-submit {
  display: inline-flex !important; /* Override inline display:none from dialog.ajax.js */
  justify-content: center;
  align-items: center;
  height: 67px;
  width: 100%;
  border-radius: 100px;
  background: #151313;
  color: #ffffff;
  font-family: 'Onest', 'Roboto', sans-serif;
  font-size: 20px;
  font-weight: 500;
  border: none;
  padding: 0 20px;
  cursor: pointer;
  transition: background 0.3s ease, transform 0.2s ease;
  white-space: nowrap;
}

.cta-form-row .form-submit:hover {
  background: #333333;
}

.cta-popup-footer {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
}

.cta-phone,
.cta-popup-footer a,
.cta-popup-footer .cta-phone {
  font-family: 'Onest', sans-serif !important;
  font-weight: 400 !important;
  font-size: 26px !important;
  color: #ffffff !important;
  text-decoration: none !important;
  transition: opacity 0.2s ease;
  display: inline-block !important;
}

.cta-phone:hover,
.cta-popup-footer a:hover,
.cta-popup-footer .cta-phone:hover {
  opacity: 0.85 !important;
}

/* Success / Submitted state */
.cta-popup-success {
  height: 100%;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.cta-popup-success .cta-popup-content {
  margin: auto 0;
  gap: 0;
}

.cta-popup-success .cta-popup-title {
  max-width: 750px;
  color: #ffffff;
}

/* Mobile Responsiveness (Figma nodes 447:3806 & 447:3809) */
@media (max-width: 768px) {
  .ui-dialog:has(.cta-popup-inner) {
    overflow-y: auto !important;
  }

  .ui-dialog:has(.cta-popup-inner) .ui-dialog-content {
    display: block !important;
    height: auto !important;
    min-height: 100vh !important;
  }

  .cta-popup-inner {
    padding: 80px 20px 40px 20px;
    min-height: 100vh;
    height: auto;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    box-sizing: border-box;
  }

  .cta-popup-header {
    justify-content: flex-start;
    margin-bottom: 30px;
  }

  .cta-popup-close-btn span {
    font-size: 20px !important;
  }

  .cta-popup-content {
    gap: 40px;
    align-items: stretch;
    justify-content: center;
    margin: 20px 0;
  }

  .cta-popup-title {
    font-size: 26px;
    line-height: 30px;
    font-weight: 700;
    text-align: left;
    max-width: 100%;
    color: #ffffff;
  }

  .cta-form-row {
    flex-direction: column;
    align-items: stretch;
    gap: 20px;
  }

  .cta-form-row > div {
    width: 100%;
    flex: none;
  }

  .cta-form-row .form-item-name,
  .cta-form-row .form-item-email,
  .cta-form-row .form-item-phone,
  .cta-form-row .form-actions {
    width: 100%;
    box-sizing: border-box;
  }

  .cta-form-row .form-item-name input,
  .cta-form-row .form-item-email input,
  .cta-form-row .form-item-phone input {
    height: 67px;
    padding: 0 30px;
    font-size: 18px;
    border-radius: 90px;
  }

  .cta-form-row .form-submit {
    height: 67px;
    font-size: 20px;
    border-radius: 100px;
    width: 100%;
  }

  .cta-popup-footer {
    justify-content: flex-start;
    margin-top: 30px;
  }

  .cta-phone,
  .cta-popup-footer a,
  .cta-popup-footer .cta-phone {
    font-size: 20px !important;
    line-height: 26px !important;
    color: #ffffff !important;
    text-align: left !important;
  }

  /* Submitted popup mobile */
  .cta-popup-success .cta-popup-header {
    justify-content: flex-start;
  }

  .cta-popup-success .cta-popup-content {
    align-items: flex-start;
  }

  .cta-popup-success .cta-popup-title {
    font-size: 26px;
    line-height: 30px;
    text-align: left;
    max-width: 100%;
    color: #ffffff;
  }

  .cta-popup-success .cta-popup-footer {
    justify-content: flex-start;
  }
}
