/**
 * Auto-fill button and the dialogs opened from it.
 *
 * The dialog rules mirror the shared "trinity-popup" look already used by
 * sso_communication, so the verify/alert popups match the rest of the site.
 */

/*
 * Anchor the button to the top-right corner of the form. Pinning it rather than
 * placing it in the flow keeps it out of the field order, and keeps particular
 * forms and webforms consistent regardless of where each one renders it.
 */
form:has(> a.autofill-btn),
form:has(> a.autofill-cancel-btn) {
  position: relative;
}

a.autofill-btn,
a.autofill-cancel-btn,
a.autofill-logout-btn {
  position: absolute;
  top: 0;
  right: 0;
  z-index: 1;
  display: inline-block;
  padding: 10px 20px;
  border: none;
  border-radius: 5px;
  background-color: #d00004;
  color: white;
}

/* Too narrow to sit beside the heading - fall back to the normal flow. */
@media only screen and (max-width: 767px) {
  a.autofill-btn,
  a.autofill-cancel-btn,
  a.autofill-logout-btn {
    position: static;
    display: block;
    margin: 0 0 16px;
    text-align: center;
  }
}

a.autofill-btn:hover,
a.autofill-cancel-btn:hover,
a.autofill-logout-btn:hover {
  border: none;
  background-color: #e03232;
  color: white;
}

/* Dim layer appended by autofill-event.js while a dialog is open. */
.modal-blackout {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.55);
  /* Above the site chrome (sticky header/sidebar), below the dialog. */
  z-index: 9998;
  display: none;
}

/*
 * jQuery UI adds an overlay of its own. Keep it clickable-blocking but
 * transparent so the page is dimmed once, not twice.
 */
.ui-dialog.trinity-popup.sl-verify-password-dialog + .ui-widget-overlay,
.ui-dialog.trinity-popup.autofill-dialog + .ui-widget-overlay {
  background: transparent;
  opacity: 1;
  z-index: 9998;
}

.ui-dialog.trinity-popup.sl-verify-password-dialog,
.ui-dialog.trinity-popup.autofill-dialog {
  z-index: 9999;
  max-width: calc(100% - 32px);
  padding: 0;
  border: none;
  border-radius: 12px;
  overflow: hidden;
  box-sizing: border-box;
  background-color: #f9fafb;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.25);
}

/*
 * The theme lays .ui-dialog out as a wrapping flex row, so titlebar, content
 * and buttonpane shrink to their own content. Make each span the full width.
 */
.ui-dialog.trinity-popup.sl-verify-password-dialog > *,
.ui-dialog.trinity-popup.autofill-dialog > * {
  flex: 0 0 100%;
  max-width: 100%;
}

.ui-dialog.trinity-popup.sl-verify-password-dialog .ui-dialog-titlebar,
.ui-dialog.trinity-popup.autofill-dialog .ui-dialog-titlebar {
  padding: 22px 24px 0;
  border: none;
  border-radius: 0;
  background: none;
  text-align: center;
}

.ui-dialog.trinity-popup.sl-verify-password-dialog .ui-dialog-title,
.ui-dialog.trinity-popup.autofill-dialog .ui-dialog-title {
  float: none;
  margin: 0;
  width: 100%;
  font-size: 22px;
  line-height: 150%;
  letter-spacing: -0.5px;
  color: #212529;
}

/* Both dialogs are dismissed through their own buttons. */
.ui-dialog.trinity-popup.sl-verify-password-dialog .ui-dialog-titlebar-close,
.ui-dialog.trinity-popup.autofill-dialog .ui-dialog-titlebar-close {
  display: none;
}

/*
 * jQuery UI sizes the content box from the content itself and writes an inline
 * width, which leaves it narrower than the dialog. Let it fill the dialog.
 */
.ui-dialog.trinity-popup.sl-verify-password-dialog .ui-dialog-content,
.ui-dialog.trinity-popup.autofill-dialog .ui-dialog-content {
  width: auto !important;
  padding: 8px 24px 0;
  font-size: 16px;
  color: #212529;
  text-align: center;
}

.sl-verify-password-wrapper {
  text-align: left;
}

.sl-verify-password-wrapper label,
.sl-verify-password-wrapper > span {
  display: block;
  margin-bottom: 6px;
}

.sl-verify-password-wrapper input {
  box-sizing: border-box;
  width: 100%;
  height: 44px;
  margin-top: 6px;
  padding: 8px 12px;
  border: 1px solid #d0d5dd;
  border-radius: 8px;
  font-size: 16px;
}

.sl-verify-password-wrapper input:focus {
  border-color: #3b0d18;
  outline: none;
}

.sl-verify-password-wrapper .sl-verify-password-helper {
  margin: 6px 0 0;
  font-size: 14px;
  color: #d00004;
}

.sl-verify-password-wrapper .sl-verify-password-helper a {
  color: #d00004;
  text-decoration: underline;
}

.ui-dialog.trinity-popup.sl-verify-password-dialog .ui-dialog-buttonpane,
.ui-dialog.trinity-popup.autofill-dialog .ui-dialog-buttonpane {
  margin: 0;
  padding: 20px 24px 24px;
  border: none;
  background: none;
}

.ui-dialog.trinity-popup.sl-verify-password-dialog .ui-dialog-buttonset,
.ui-dialog.trinity-popup.autofill-dialog .ui-dialog-buttonset {
  display: flex;
  gap: 12px;
  float: none;
  width: 100%;
}

.ui-dialog.trinity-popup.sl-verify-password-dialog .ui-dialog-buttonset button,
.ui-dialog.trinity-popup.autofill-dialog .ui-dialog-buttonset button {
  flex: 1;
  height: 46px;
  margin: 0;
  padding: 0 16px;
  border: 1px solid #3b0d18;
  border-radius: 12px;
  outline: none;
  background-color: #3b0d18;
  color: #e3dfd5;
  font-size: 16px;
  transition: all 0.25s ease-in-out;
}

.ui-dialog.trinity-popup.sl-verify-password-dialog .ui-dialog-buttonset button:hover,
.ui-dialog.trinity-popup.autofill-dialog .ui-dialog-buttonset button:hover {
  opacity: 0.85;
}

.ui-dialog.trinity-popup.sl-verify-password-dialog .ui-dialog-buttonset button:disabled {
  opacity: 0.5;
}

/* First of the two buttons is "Cancel" - keep it secondary. */
.ui-dialog.trinity-popup.sl-verify-password-dialog .ui-dialog-buttonset button:first-child:not(:only-child) {
  background-color: transparent;
  color: #3b0d18;
}

@media only screen and (max-width: 600px) {
  .ui-dialog.trinity-popup.sl-verify-password-dialog .ui-dialog-title,
  .ui-dialog.trinity-popup.autofill-dialog .ui-dialog-title {
    font-size: 18px;
  }
}
