/* Look for the dialogs that legacy ssajax.js builds (urlDialog / urlFormDialog / showMessage).
   ssajax.js injects Bootstrap-5 modal markup into <body>. This app does NOT load Bootstrap's
   CSS (it would restyle every screen), so these few rules - keyed to the two ids ssajax.js
   uses - are all the styling those dialogs get. Tokens only, so they follow the broker theme
   and light/dark. Plain global file in public/, loaded from index.html. */

:is(#modalBootstrap, #modalmessageBootstrap) {
  position: fixed;
  inset: 0;
  z-index: 1055;
  display: none;            /* Bootstrap's JS flips it to block on show() */
  overflow-y: auto;
  outline: 0;
}

:is(#modalBootstrap, #modalmessageBootstrap) .modal-dialog {
  margin: var(--space-5) auto;
  /* ssajax.js sets an inline width in px; never let it outgrow a phone */
  max-width: calc(100vw - var(--space-4) * 2) !important;
  pointer-events: none;
}

:is(#modalBootstrap, #modalmessageBootstrap) .modal-dialog-centered {
  display: flex;
  align-items: center;
  min-height: calc(100% - var(--space-5) * 2);
  width: 500px;
}

:is(#modalBootstrap, #modalmessageBootstrap) .modal-content {
  width: 100%;
  display: flex;
  flex-direction: column;
  pointer-events: auto;
  background: var(--color-surface);
  color: var(--color-text);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
}

:is(#modalBootstrap, #modalmessageBootstrap) .modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--color-border);
}

:is(#modalBootstrap, #modalmessageBootstrap) .modal-title {
  margin: 0;
}

:is(#modalBootstrap, #modalmessageBootstrap) .modal-body {
  padding: var(--space-4);
}

:is(#modalBootstrap, #modalmessageBootstrap) .modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  border-top: 1px solid var(--color-border);
}

/* the close "x": Bootstrap draws it with a background image; a glyph does the same job here */
:is(#modalBootstrap, #modalmessageBootstrap) .btn-close {
  min-width: 28px;
  min-height: 28px;
  padding: 0;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--color-text-muted);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
}
:is(#modalBootstrap, #modalmessageBootstrap) .btn-close::before {
  content: "\00d7";
}

:is(#modalBootstrap, #modalmessageBootstrap) .btn {
  min-height: 32px;
  padding: var(--space-2) var(--space-4);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font: inherit;
  cursor: pointer;
}
:is(#modalBootstrap, #modalmessageBootstrap) .btn-primary {
  background: var(--color-primary);
  color: var(--color-primary-contrast);
}
:is(#modalBootstrap, #modalmessageBootstrap) .btn-primary:hover {
  background: var(--color-primary-hover);
}
:is(#modalBootstrap, #modalmessageBootstrap) .btn:focus-visible,
:is(#modalBootstrap, #modalmessageBootstrap) .btn-close:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

/* the dimmed layer Bootstrap's JS appends to <body> while a modal is open */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1050;
  background: color-mix(in srgb, var(--color-text) 50%, transparent);
}
