/* ─── Matrix Modal overlay ─────────────────────────────────────────────────── */

/**
 * Full-screen backdrop + centred box.
 * The element is hidden by default (display:none via inline style) and
 * switched to flex by JS when opened.
 */
.matrixModal {
  position: fixed;
  inset: 0;
  z-index: 9000;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.55);
}

/* Prevent body scroll while a modal is open */
body.matrixModalOpen {
  overflow: hidden;
}

/* ─── Modal box ────────────────────────────────────────────────────────────── */

.matrixModalBox {
  position: relative;
  background: var(--color-background-2);
  border-radius: var(--border-radius);
  box-shadow: var(--box-shadow-heavy);
  width: 96vw;
  max-width: 1380px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  /* overflow:visible lets fixed-position dropdowns escape the box boundary */
  overflow: visible;
  padding:10px;
}

/* ─── Header ───────────────────────────────────────────────────────────────── */

.matrixModalHeader {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px 14px;
  background: var(--color-background-2);
  border-bottom: 1px solid var(--color-background-4);
  flex-shrink: 0;
}

.matrixModalTitle {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text-color);
}

.matrixModalClose {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--color-neutral-text-faded);
  font-size: 1.1rem;
  line-height: 1;
  padding: 2px 6px;
  border-radius: var(--border-radius-small);
  transition: color 0.15s, background 0.15s;
}

.matrixModalClose:hover {
  color: var(--text-color);
  background: var(--color-background-4);
}

/* ─── Body ─────────────────────────────────────────────────────────────────── */

.matrixModalBody {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 0;
}

/* The form rendered inside the modal body */
.matrixModalForm {
  padding: 0 4px;
}

/* ─── Footer ───────────────────────────────────────────────────────────────── */

/**
 * Sticky footer that lives outside the scrollable body.
 * Only gains visible layout when it contains the left/right button wrappers.
 */
.matrixModalFooter {
  flex-shrink: 0;
}

.matrixModalFooter:has(.matrixModalFooterLeft, .matrixModalFooterRight) {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-top: 1px solid var(--color-background-4);
  background: var(--color-background-2);
  border-radius: 0 0 var(--border-radius) var(--border-radius);
}

.matrixModalFooterLeft,
.matrixModalFooterRight {
  display: flex;
  align-items: center;
}

/* Compact submit buttons inside the modal footer */
.matrixModalFooter .boxFormSubmit input,
.matrixModalFooter .boxFormSubmit button {
  display: inline-block;
  margin: 0;
  padding: 0 24px;
  width: auto;
}

.matrixModalFooter .boxFormSubmitGreen button,
.matrixModalFooter .boxFormSubmitGreen input {
  background: var(--color-success-3) !important;
}

.matrixModalFooter .boxFormSubmitGreen button:hover,
.matrixModalFooter .boxFormSubmitGreen input:hover {
  background: var(--color-success-4) !important;
}

/* ─── Body ─────────────────────────────────────────────────────────────────── */

/* Loading spinner shown while AJAX content is being fetched */
.matrixModalLoading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px 0;
  font-size: 1.8rem;
  color: var(--color-neutral-text-faded);
}
