/*
 * Minimal Bootstrap 5 ".modal" base rules.
 *
 * The expose-hm template loads Bootstrap's JS (media/vendor/bootstrap/js/*)
 * but never loaded Bootstrap's CSS, so components that render Bootstrap
 * modal markup (e.g. com_attachments' "Add attachment" dialog) were never
 * hidden by default and rendered inline as a large empty block (their
 * .modal-body got an explicit height via jviewport-height80).
 *
 * This file supplies just the base show/hide behaviour Bootstrap's JS
 * expects, without pulling in the full bootstrap.css (which would clash
 * with the template's old 960gs-based grid).
 */

.modal {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 1055;
  display: none;
  width: 100%;
  height: 100%;
  overflow-x: hidden;
  overflow-y: auto;
  outline: 0;
}

.modal.show {
  display: block;
  /* template.css (legacy Bootstrap 2 from the expose framework) defines
     .fade{opacity:0} and .fade.in{opacity:1} - Bootstrap 5 toggles
     .show instead of .in, so that legacy rule never gets countered
     and the modal would stay invisible. Override it here explicitly. */
  opacity: 1;
}

.modal.fade .modal-dialog {
  transition: transform 0.3s ease-out;
  transform: translate(0, -50px);
}

.modal.show .modal-dialog {
  transform: none;
}

.modal-dialog {
  position: relative;
  width: auto;
  margin: 1.75rem auto;
  pointer-events: none;
}

.modal-content {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  pointer-events: auto;
  background-color: #fff;
  background-clip: padding-box;
  border: 1px solid rgba(0, 0, 0, 0.2);
  border-radius: 0.3rem;
  outline: 0;
}

.modal-header,
.modal-footer {
  display: flex;
  align-items: center;
  padding: 1rem;
}

.modal-header {
  justify-content: space-between;
  border-bottom: 1px solid #dee2e6;
}

.modal-footer {
  justify-content: flex-end;
  border-top: 1px solid #dee2e6;
}

.modal-body {
  position: relative;
  flex: 1 1 auto;
  padding: 1rem;
}

.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 1050;
  width: 100vw;
  height: 100vh;
  background-color: #000;
}

.modal-backdrop.fade {
  opacity: 0;
}

.modal-backdrop.show {
  opacity: 0.5;
}

/* com_attachments' attachments_list.css sets a FIXED height (80vh) on
   .jviewport-height80, no matter how little content the dialog actually
   has (e.g. the small "Add attachment" upload box). That leaves a lot of
   empty space in the dialog and, combined with the modal-dialog's
   top/bottom margin, pushes the total height a few pixels past the
   viewport - triggering an unnecessary scrollbar. Cap it with max-height
   instead of forcing a fixed height, so the dialog shrinks to fit small
   content but still scrolls internally for genuinely tall content. Loaded
   after attachments_list.css, so this wins at equal specificity. */
.modal-body.jviewport-height80 {
  height: auto;
  max-height: 80vh;
  overflow-y: auto;
}

/* com_attachments builds its upload iframe with height="60vh" as an HTML
   *attribute* (not CSS) - "60vh" is not a valid HTML height attribute
   value, so the browser reads only the leading "60" as pixels. The
   iframe ends up ~60px tall, far too short for the upload form inside,
   which then needs its own internal scrollbar. Give it a sane height via
   CSS, which overrides the presentational HTML attribute. */
.modal-body iframe.iframe {
  height: 320px;
  min-height: 320px;
}
