/*
 * MessagePad pop-ups: the small question boxes (bootbox confirm, alert,
 * prompt and dialog) on every staff page, Emails included.
 *
 * Centred on the screen with rounded corners and no grey header or footer
 * strips. Confirms and alerts are centred inside too and their buttons share
 * the width. A confirm with a red button shows a warning sign, or a bin when
 * the button has a bin or cross icon. Button colours still come from the
 * theme and the account's branding. Loaded after messagepad-ui.css; the dark
 * theme's !important header and footer colours are overridden at the end.
 */

.bootbox.modal {
  --bb-surface: var(--mp-white, #ffffff);
  --bb-text: var(--mp-text, #17233c);
  --bb-text-2: #344054;
  --bb-muted: var(--mp-muted, #667085);
  --bb-border: var(--mp-border, #e4e9f0);
  --bb-hover: #f4f7fb;
  --bb-warn: #d92d20;
  --bb-warn-soft: #fee4e2;
}

body.mp-dark .bootbox.modal {
  --bb-text-2: var(--dk-text-2, #c4cbd6);
  --bb-hover: var(--dk-surface-3, #252e3d);
  --bb-warn: #f5877a;
  --bb-warn-soft: var(--dk-red-soft, #3a1a1a);
}

/* ---------- position: the middle of the screen ---------- */
.bootbox.modal .modal-dialog {
  display: flex;
  align-items: center;
  min-height: calc(100% - 32px);
  margin: 16px auto;
  pointer-events: none;
}

.bootbox-confirm.modal .modal-dialog,
.bootbox-alert.modal .modal-dialog,
.bootbox-prompt.modal .modal-dialog {
  width: min(420px, calc(100vw - 32px));
}

@media (max-width: 767px) {
  .bootbox.modal .modal-dialog {
    width: calc(100vw - 32px);
  }
}

.bootbox.modal.fade .modal-dialog {
  opacity: 0;
  transform: translateY(12px) scale(.97);
  transition: transform .18s ease-out, opacity .18s ease-out;
}

.bootbox.modal.in .modal-dialog {
  opacity: 1;
  transform: none;
}

.bootbox.in + .modal-backdrop.in {
  background: #0c111d;
  opacity: .45;
}

/* ---------- the box ---------- */
.bootbox.modal .modal-content {
  position: relative;
  width: 100%;
  overflow: hidden;
  background: var(--bb-surface);
  border: 0;
  border-radius: 16px;
  box-shadow: 0 0 0 1px rgba(16, 24, 40, .06), 0 24px 48px -12px rgba(16, 24, 40, .3);
  color: var(--bb-text);
  pointer-events: auto;
}

.bootbox.modal .modal-header {
  padding: 26px 56px 4px 26px;
  background: transparent;
  border: 0;
  border-radius: 0;
}

.bootbox.modal .modal-header .modal-title {
  color: var(--bb-text);
  font-size: 18px;
  font-weight: 700;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.bootbox.modal .bootbox-close-button.close {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 2;
  width: 32px;
  height: 32px;
  margin: 0 !important;
  padding: 0;
  border-radius: 8px;
  color: var(--bb-muted);
  font-size: 22px;
  font-weight: 400;
  line-height: 32px;
  text-align: center;
  text-shadow: none;
  opacity: 1;
}

.bootbox.modal .bootbox-close-button.close:hover,
.bootbox.modal .bootbox-close-button.close:focus-visible {
  background: var(--bb-hover);
  color: var(--bb-text);
  outline: none;
}

.bootbox.modal .modal-body {
  padding: 6px 26px 4px;
  color: var(--bb-text-2);
  font-size: 14.5px;
  line-height: 1.55;
}

/* A question with no title: the question itself is the heading. */
.bootbox.modal .modal-body:first-child {
  padding: 28px 56px 6px 26px;
  color: var(--bb-text);
  font-size: 16px;
  font-weight: 600;
}

.bootbox.modal .bootbox-input {
  height: 40px;
  margin-top: 6px;
  border-radius: 9px;
}

/* ---------- buttons ---------- */
.bootbox.modal .modal-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
  padding: 20px 26px 24px;
  background: transparent;
  border: 0;
  border-radius: 0;
}

.bootbox.modal .modal-footer .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 100px;
  height: 42px;
  margin: 0 !important;
  padding: 0 18px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  box-shadow: none;
}

.bootbox.modal .modal-footer .btn-default {
  background: var(--bb-surface);
  border: 1px solid var(--bb-border);
  color: var(--bb-text-2);
}

.bootbox.modal .modal-footer .btn-default:hover,
.bootbox.modal .modal-footer .btn-default:focus {
  background: var(--bb-hover);
  border-color: var(--bb-border);
  color: var(--bb-text);
}

.bootbox.modal .modal-footer .btn-danger {
  background: #d92d20;
  border: 1px solid #d92d20;
  color: #ffffff;
}

.bootbox.modal .modal-footer .btn-danger:hover,
.bootbox.modal .modal-footer .btn-danger:focus {
  background: #b42318;
  border-color: #b42318;
  color: #ffffff;
}

.bootbox.modal .modal-footer .btn:focus-visible {
  outline: 3px solid rgba(49, 88, 184, .35);
  outline-offset: 2px;
}

/* ---------- confirms and alerts: centred, buttons share the width ---------- */
.bootbox-confirm.modal .modal-header,
.bootbox-alert.modal .modal-header {
  padding: 30px 26px 4px;
  text-align: center;
}

.bootbox-confirm.modal .modal-body,
.bootbox-alert.modal .modal-body {
  text-align: center;
}

.bootbox-confirm.modal .modal-body:first-child,
.bootbox-alert.modal .modal-body:first-child {
  padding: 40px 48px 6px;
}

.bootbox-confirm.modal .modal-footer .btn,
.bootbox-alert.modal .modal-footer .btn {
  flex: 1 1 0;
}

/* ---------- a confirm with a red button: warning sign (or a bin) ---------- */
.bootbox-confirm.modal:has(.modal-footer .btn-danger) .modal-header::before,
.bootbox-confirm.modal:has(.modal-footer .btn-danger) .modal-body:first-child::before {
  content: "\f071";
  display: flex;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 52px;
  margin: 0 auto 18px;
  background: var(--bb-warn-soft);
  border-radius: 50%;
  box-shadow: 0 0 0 8px rgba(217, 45, 32, .06);
  color: var(--bb-warn);
  font: normal 22px/1 FontAwesome;
}

.bootbox-confirm.modal:has(.btn-danger .fa-trash, .btn-danger .fa-trash-o, .btn-danger .fa-times) .modal-header::before,
.bootbox-confirm.modal:has(.btn-danger .fa-trash, .btn-danger .fa-trash-o, .btn-danger .fa-times) .modal-body:first-child::before {
  content: "\f1f8";
}

/* ---------- dark mode ---------- */
body.mp-dark .bootbox.modal .modal-content {
  box-shadow: 0 0 0 1px var(--dk-border, #2e3848), 0 24px 48px -12px rgba(0, 0, 0, .6);
}

body.mp-dark .bootbox.in + .modal-backdrop.in {
  opacity: .6;
}

/* The dark theme paints modal headers and footers with !important. */
body.mp-dark .bootbox.modal .modal-header,
body.mp-dark .bootbox.modal .modal-footer {
  background: transparent !important;
  border-color: transparent !important;
}

/* ---------- pages without Bootstrap (public pages and the like) ---------- */
/* mp-dialogs.js draws the same pop-up itself there; these supply what
   Bootstrap normally would. */
.bootbox.mpd-plain {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 1050;
  display: block;
  overflow-x: hidden;
  overflow-y: auto;
  outline: 0;
  font-size: 14px;
  line-height: 1.45;
}

.bootbox.mpd-plain,
.bootbox.mpd-plain * {
  box-sizing: border-box;
}

.mpd-plain-backdrop {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 1040;
  background: #0c111d;
  opacity: .45;
}

.bootbox.mpd-plain .modal-dialog {
  position: relative;
}

.bootbox.mpd-plain .modal-title {
  margin: 0;
}

.bootbox.mpd-plain .bootbox-close-button.close {
  float: none;
  background: transparent;
  border: 0;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}

.bootbox.mpd-plain .modal-footer .btn {
  border: 1px solid transparent;
  font-family: inherit;
  line-height: 1.2;
  cursor: pointer;
}

.bootbox.mpd-plain .modal-footer .btn-default {
  border-color: var(--bb-border);
}

.bootbox.mpd-plain .modal-footer .btn-primary {
  background: var(--mp-blue, #2a5db0);
  border-color: var(--mp-blue, #2a5db0);
  color: #ffffff;
}

.bootbox.mpd-plain .modal-footer .btn-primary:hover,
.bootbox.mpd-plain .modal-footer .btn-primary:focus {
  filter: brightness(.92);
}

.bootbox.mpd-plain .bootbox-input {
  display: block;
  width: 100%;
  height: 40px;
  padding: 8px 12px;
  background: #ffffff;
  border: 1px solid #d0d5dd;
  border-radius: 9px;
  color: var(--bb-text);
  font: inherit;
}

.bootbox.mpd-plain .bootbox-input:focus {
  border-color: var(--mp-blue, #2a5db0);
  outline: 3px solid rgba(42, 93, 176, .18);
}

/* No icon font on the page: no round icon either. */
.bootbox.mpd-plain.mpd-nofa .modal-header::before,
.bootbox.mpd-plain.mpd-nofa .modal-body::before {
  display: none !important;
}

/* ---------- the × says "Close" too (mp-dialogs.js adds the word) ---------- */
body .modal .close.mp-close {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  float: right;
  width: auto;
  height: 32px;
  margin: -6px -8px 0 12px;
  padding: 0 8px 0 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--mp-muted, #667085);
  font-size: 13px;
  font-weight: 600;
  line-height: 1;
  text-shadow: none;
  white-space: nowrap;
  opacity: 1;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}

.modal .close.mp-close .mp-close-x {
  margin-top: -2px;
  font-size: 21px;
  font-weight: 400;
  line-height: 1;
}

body .modal .close.mp-close:hover,
body .modal .close.mp-close:focus-visible {
  background: #f4f7fb;
  color: var(--mp-text, #17233c);
  opacity: 1;
  outline: none;
}

.bootbox.modal .bootbox-close-button.close.mp-close {
  width: auto;
  margin: 0 !important;
  padding: 0 8px 0 10px;
  font-size: 13px;
  line-height: 1;
}

.bootbox.modal .modal-header,
.bootbox.modal .modal-body:first-child {
  padding-right: 100px;
}

/* Centred confirms and alerts: the words start below Close, so they stay centred. */
.bootbox-confirm.modal .modal-header,
.bootbox-alert.modal .modal-header {
  padding: 54px 26px 4px;
}

.bootbox-confirm.modal .modal-body:first-child,
.bootbox-alert.modal .modal-body:first-child {
  padding: 58px 48px 6px;
}

body.mp-dark .modal .close.mp-close {
  color: #c4cbd6;
}

body.mp-dark .modal .close.mp-close:hover,
body.mp-dark .modal .close.mp-close:focus-visible {
  background: rgba(255, 255, 255, .08);
  color: #fff;
}
