/* =========================================================
   SIGNUP PAGE - FULL RESPONSIVE LAYOUT
   ========================================================= */

:root {
  --signup-max-width: 760px;
  --signup-horizontal-padding: 24px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  height: auto;
}

body.app.auth-page {
  min-height: 100vh;
  height: auto !important;
  margin: 0;

  /*
   * Allow the browser/page to scroll naturally.
   * The signup form itself will NOT scroll.
   */
  overflow-x: hidden;
  overflow-y: auto;
}

/* =========================================================
   IMPORTANT: OVERRIDE COOLADMIN FIXED HEIGHT
   ========================================================= */

body.app.auth-page .page-wrapper {
  min-height: 100vh;
  height: auto !important;
  overflow: visible !important;
}

body.app.auth-page .page-content--bge5 {
  width: 100%;

  min-height: 100vh;
  height: auto !important;

  display: block;

  overflow: visible !important;

  padding: 0;
}

body.app.auth-page .container {
  width: 100%;
  max-width: none;

  padding: 0;
  margin: 0;
}

/* =========================================================
   MAIN SIGNUP AREA
   ========================================================= */

body.app.auth-page .auth-main {
  width: 100%;
  max-width: var(--signup-max-width);

  /*
   * This gives the form breathing room at the top
   * and bottom without affecting its natural height.
   */
  margin: 10px auto 60px;

  padding-left: var(--signup-horizontal-padding);
  padding-right: var(--signup-horizontal-padding);

  display: block;

  align-items: initial;
  justify-content: initial;
}

/* =========================================================
   AUTH INNER
   ========================================================= */

body.app.auth-page .auth-main-inner {
  width: 100%;
  max-width: 100%;

  margin: 0 auto;

  height: auto !important;
}

body.app.auth-page .login-wrap {
  width: 100%;
  max-width: 100%;

  height: auto !important;
}

body.app.auth-page .login-content {
  width: 100%;
  max-width: 100%;

  margin: 0 auto;

  height: auto !important;
}

/* =========================================================
   SIGNUP CONTENT
   ========================================================= */

.signup-content {
  width: 100%;
  max-width: 100%;

  margin: 0 auto;
}

/*
 * Remove the old <br><br> spacing.
 * CSS controls the spacing instead.
 */
.signup-content>br {
  display: none;
}

/* =========================================================
   HEADING
   ========================================================= */

/* Brand lock-up — matches the sign-in page */
.signup-content .auth-logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  margin-bottom: 10px;
  text-align: center;
}

.signup-content .auth-logo img {
  width: 56px;
  height: 56px;
  object-fit: contain;
  margin-bottom: 4px;
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.12));
}

body.app.auth-page .signup-content .auth-logo .auth-subtitle {
  margin: 0;
  line-height: 1.2;
  color: #4a5568;
}

body.app.auth-page .signup-content .auth-logo .auth-title {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: 0.02em;
}

body.app.auth-page .signup-content>.signup-intro {
  text-align: center;
  margin: 0 0 28px;
}

.signup-content .auth-title {
  margin-top: 0;
  margin-bottom: 8px;
}

.signup-content .auth-subtitle {
  margin-top: 0;
  margin-bottom: 28px;
}


/* =========================================================
   FORM
   ========================================================= */

.signup-form {
  width: 100%;

  margin-top: 0;

  /*
   * CRITICAL FIX:
   * No fixed height.
   * No max-height.
   * No internal scrolling.
   */
  height: auto !important;
  max-height: none !important;

  overflow: visible !important;

  padding: 0;
}

.signup-form form {
  width: 100%;

  height: auto !important;

  margin: 0;
  padding: 0;
}

/* =========================================================
   FORM SECTION TITLES
   ========================================================= */

.form-section-title {
  font-size: 13px;
  font-weight: 600;

  text-transform: uppercase;
  letter-spacing: 0.04em;

  color: #8a94a6;

  margin: 24px 0 12px;
}

.form-section-title:first-of-type {
  margin-top: 0;
}

/* =========================================================
   FORM ROWS
   ========================================================= */

.form-row {
  display: flex;

  width: 100%;

  gap: 16px;

  margin-bottom: 16px;
}

.form-group {
  flex: 1 1 0;
  min-width: 0;

  margin-bottom: 16px;
}

.form-row .form-group {
  margin-bottom: 0;
}

/* =========================================================
   LABELS
   ========================================================= */

.form-group label {
  display: block;

  margin-bottom: 6px;

  font-weight: 500;
}

.required {
  color: #e53e3e;

  margin-left: 3px;
}

/* =========================================================
   INPUTS
   ========================================================= */

.au-input {
  width: 100%;
  max-width: 100%;

  box-sizing: border-box;
}

select.au-input {
  height: 42px;
}

/* =========================================================
   ASYNC FIELD EXISTENCE CHECK (email / mobile)
   ========================================================= */

.field-check-wrapper {
  position: relative;

  width: 100%;
}

.field-check-indicator {
  display: none;

  position: absolute;

  right: 12px;
  top: 50%;

  width: 16px;
  height: 16px;

  transform: translateY(-50%);

  border: 2px solid #d3d9e3;
  border-top-color: #4272d7;
  border-radius: 50%;

  pointer-events: none;

  animation: btn-spin 0.6s linear infinite;
}

.field-check-indicator.show {
  display: block;
}

.field-check-wrapper .au-input {
  padding-right: 34px;
}

/* =========================================================
   VALIDATION
   ========================================================= */

.field-error {
  color: #e53e3e;

  font-size: 12px;
  line-height: 1.4;

  margin-top: 5px;
}

.field-error.client-error,
.field-error.ajax-error {
  display: none;
}

.form-group.is-invalid .client-error {
  display: block;
}

.field-error.ajax-error.show {
  display: block;
}

.form-group.is-invalid .au-input {
  border-color: #e53e3e !important;
}

.form-group.is-valid .au-input {
  border-color: #2f9e44 !important;
}

/* Comes after .is-valid so a "this already exists" result always wins
   the border color over a merely well-formatted value. */
.form-group.has-exists-error .au-input {
  border-color: #e53e3e !important;
}

/* =========================================================
   PASSWORD LABEL
   ========================================================= */

.password-label-row {
  display: flex;

  align-items: center;

  gap: 6px;

  margin-bottom: 6px;
}

.password-label-row label {
  margin-bottom: 0;
}

.password-info-wrapper {
  position: relative;

  display: inline-flex;
}

.password-info-btn {
  display: inline-flex;

  align-items: center;
  justify-content: center;

  width: 16px;
  height: 16px;

  border: 0;

  background: transparent;

  padding: 0;

  cursor: pointer;

  color: #8a94a6;

  font-size: 13px;
}

.password-info-btn:hover,
.password-info-btn:focus-visible {
  color: #4a5568;
}

/* =========================================================
   PASSWORD RULES
   ========================================================= */

.password-rules {
  position: absolute;

  top: calc(100% + 8px);
  left: 0;

  margin: 0;

  padding: 10px 12px;

  list-style: none;

  display: none;

  grid-template-columns: 1fr 1fr;

  gap: 4px 12px;

  width: max-content;

  max-width: min(310px,
      calc(100vw - 32px));

  background: #fff;

  border: 1px solid #e2e8f0;

  border-radius: 8px;

  box-shadow:
    0 6px 16px rgba(0, 0, 0, 0.1);

  z-index: 100;

  font-size: 12px;

  line-height: 1.4;

  white-space: nowrap;
}

.password-info-wrapper:hover .password-rules,
.password-info-wrapper:focus-within .password-rules,
.password-rules.show {
  display: grid;
}

.password-rules li {
  color: #8a94a6;
}

.password-rules li.valid {
  color: #2f9e44;
}

.password-rules li::before {
  content: "○";

  margin-right: 6px;
}

.password-rules li.valid::before {
  content: "✓";
}

/* =========================================================
   PASSWORD INPUT
   ========================================================= */

.password-wrapper {
  position: relative;

  width: 100%;
}

.password-wrapper .au-input {
  padding-right: 42px;
}

.password-toggle {
  position: absolute;

  right: 12px;
  top: 50%;

  transform: translateY(-50%);

  border: 0;

  background: transparent;

  padding: 0;

  cursor: pointer;

  color: #8a94a6;
}

.password-toggle:hover,
.password-toggle:focus-visible {
  color: #4a5568;
}

/* =========================================================
   TERMS
   ========================================================= */

.terms-group {
  margin: 10px 0 20px;
}

.terms-error {
  color: #e53e3e;

  font-size: 12px;

  margin-top: 5px;
}

.terms-error.client-error {
  display: none;
}

.terms-error.client-error.show {
  display: block;
}

/* =========================================================
   SUMMARY ERROR
   ========================================================= */

.form-summary-error {
  display: none;

  padding: 10px 14px;

  margin-bottom: 16px;

  border-radius: 6px;

  background: #fff1f1;

  border: 1px solid #ffd0d0;

  color: #c53030;

  font-size: 13px;

  line-height: 1.4;
}

.form-summary-error.show {
  display: block;
}

/* =========================================================
   DJANGO MESSAGES (Bootstrap alert, as on the declaration pages)
   ========================================================= */

.signup-content .alert {
  margin-bottom: 16px;

  font-size: 13px;
}

/* =========================================================
   SUBMIT BUTTON
   ========================================================= */

#signupSubmit {
  display: block;

  width: 100%;

  max-width: 345px;

  margin: 24px auto 0;
}

/* =========================================================
   LOGIN LINK
   ========================================================= */

.signup-form .register-link {
  margin-top: 22px;

  text-align: center;
}

.signup-form .register-link p {
  margin-bottom: 0;
}

/* =========================================================
   TABLET
   ========================================================= */

@media (max-width: 768px) {

  :root {
    --signup-horizontal-padding: 20px;
  }

  body.app.auth-page .auth-main {
    margin-top: 45px;
    margin-bottom: 45px;
  }

}

/* =========================================================
   MOBILE
   ========================================================= */

@media (max-width: 575px) {

  :root {
    --signup-horizontal-padding: 16px;
  }

  body.app.auth-page .page-content--bge5 {
    min-height: 100vh;
    height: auto !important;

    display: block;

    overflow: visible !important;
  }

  body.app.auth-page .auth-main {
    width: 100%;
    max-width: none;

    margin-top: 12px;
    margin-bottom: 36px;

    padding-left: var(--signup-horizontal-padding);
    padding-right: var(--signup-horizontal-padding);
  }

  .signup-content .auth-title {
    font-size: 26px;

    line-height: 1.25;

    margin-bottom: 8px;
  }

  .signup-content .auth-subtitle {
    font-size: 14px;

    line-height: 1.5;

    margin-bottom: 24px;
  }

  /* ---------------------------------------------
     Stack fields
     --------------------------------------------- */

  .form-row {
    flex-direction: column;

    gap: 0;

    margin-bottom: 0;
  }

  .form-row .form-group {
    width: 100%;

    margin-bottom: 16px;
  }

  .form-group {
    width: 100%;
  }

  /* ---------------------------------------------
     Section titles
     --------------------------------------------- */

  .form-section-title {
    margin-top: 22px;
    margin-bottom: 12px;
  }

  /* ---------------------------------------------
     Inputs
     --------------------------------------------- */

  .au-input {
    width: 100%;

    min-height: 42px;
  }

  /* ---------------------------------------------
     Terms
     --------------------------------------------- */

  .terms-group {
    margin-top: 8px;
    margin-bottom: 20px;
  }

  .terms-group label {
    display: flex;

    align-items: flex-start;

    gap: 8px;

    line-height: 1.5;
  }

  .terms-group input[type="checkbox"] {
    flex: 0 0 auto;

    margin-top: 4px;
  }

  /* ---------------------------------------------
     Button
     --------------------------------------------- */

  #signupSubmit {
    width: 100%;

    max-width: none;

    min-height: 44px;
  }

  /* ---------------------------------------------
     Password rules
     --------------------------------------------- */

  .password-rules {
    width: min(290px,
        calc(100vw - 48px));

    max-width: calc(100vw - 48px);

    grid-template-columns: 1fr;

    white-space: normal;
  }

  .signup-form .register-link {
    margin-top: 18px;
  }
}

/* =========================================================
   SMALL MOBILE
   ========================================================= */

@media (max-width: 380px) {

  :root {
    --signup-horizontal-padding: 13px;
  }

  body.app.auth-page .auth-main {
    margin-top: 24px;
    margin-bottom: 30px;
  }

  .signup-content .auth-title {
    font-size: 24px;
  }

  .signup-content .auth-subtitle {
    font-size: 13px;
  }

  .form-group label {
    font-size: 14px;
  }

  .au-input {
    font-size: 14px;
  }

  .password-rules {
    width: calc(100vw - 40px);

    max-width: calc(100vw - 40px);
  }
}

/* =========================================================
   SHORT DESKTOP SCREENS
   ========================================================= */

@media (max-height: 700px) and (min-width: 576px) {

  body.app.auth-page .auth-main {
    margin-top: 35px;
    margin-bottom: 40px;
  }
}

/* Submit button loading state */
#signupSubmit[disabled] {
  opacity: 0.75;
  cursor: not-allowed;
}

/* =========================================================
   TERMS SCROLL HINT
   ========================================================= */

.terms-scroll-hint {
  margin: 10px 0 0;
  text-align: center;
  font-size: 12px;
  color: #8a94a6;
}

.terms-scroll-hint a {
  color: #4272d7;
  text-decoration: underline;
  cursor: pointer;
}

/* =========================================================
   TERMS & PRIVACY MODAL
   ========================================================= */

.terms-modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1000;

  align-items: center;
  justify-content: center;

  padding: 20px;

  background: rgba(15, 20, 30, 0.55);
}

.terms-modal-overlay.show {
  display: flex;
}

.terms-modal {
  width: 100%;
  max-width: 1100px;
  height: 92vh;
  max-height: 92vh;

  display: flex;
  flex-direction: column;

  background: #fff;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
}

.terms-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;

  padding: 16px 20px;

  border-bottom: 1px solid #e6eaf0;
}

.terms-modal-header h2 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 700;
}

.terms-modal-close {
  border: 0;
  background: transparent;

  font-size: 22px;
  line-height: 1;

  color: #647084;
  cursor: pointer;

  padding: 4px 8px;
}

.terms-modal-close:hover,
.terms-modal-close:focus-visible {
  color: #202938;
}

.terms-modal-body {
  flex: 1;
  min-height: 0;

  overflow: hidden;
}

.terms-modal-body iframe {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}

.terms-modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;

  padding: 14px 20px;

  border-top: 1px solid #e6eaf0;
  background: #f7f9fc;
}

.terms-modal-hint {
  margin: 0;
  font-size: 12.5px;
  color: #647084;
}

.terms-modal-footer #termsModalDoneBtn {
  width: auto;
  margin: 0;
  padding: 8px 22px;
}

.terms-modal-footer #termsModalDoneBtn[disabled] {
  opacity: 0.6;
  cursor: not-allowed;
}

@media (max-width: 575px) {
  .terms-modal-overlay {
    padding: 10px;
  }

  .terms-modal {
    height: 95vh;
    max-height: 95vh;
  }

  .terms-modal-footer {
    flex-direction: column;
    align-items: stretch;
    text-align: center;
  }

  .terms-modal-footer #termsModalDoneBtn {
    width: 100%;
  }
}

.btn-spinner {
  display: inline-block;
  width: 1rem;
  height: 1rem;
  margin-right: 0.5rem;
  vertical-align: -0.15rem;
  border: 2px solid rgba(255, 255, 255, 0.45);
  border-top-color: #fff;
  border-radius: 50%;
  animation: btn-spin 0.6s linear infinite;
}

@keyframes btn-spin {
  to {
    transform: rotate(360deg);
  }
}
