/**
 * @file
 * Styles for jQuery UI dialog modals.
 *
 * core.css (which provides position:fixed for .ui-widget-overlay) is NOT
 * included in drupal.dialog. We restore the essential viewport-covering rules
 * here and set z-indexes consistent with the Drupal ecosystem (Olivero pattern:
 * overlay 1259, dialog 1260).
 */

/* Backdrop: fixed full-viewport overlay.
 * !important required: jQuery UI sets position/top/left as inline styles. */
.ui-widget-overlay {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  width: 100% !important;
  height: 100% !important;
  background: #000 !important;
  opacity: 0.7 !important;
  z-index: 1259 !important;
}

/* Dialog wrapper: sits above backdrop.
 * !important required on position/z-index: jQuery UI inline styles override. */
.ui-dialog {
  position: fixed !important;
  z-index: 1260 !important;
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
  border-radius: 4px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.28);
}

/* Media library specific: generous size, centered */
.ui-dialog.media-library-widget-modal {
  width: min(960px, 92vw) !important;
  height: auto !important;
  max-height: 88vh !important;
  top: 50% !important;
  left: 50% !important;
  transform: translate(-50%, -50%) !important;
  overflow: hidden;
}

.ui-dialog.media-library-widget-modal .ui-dialog-content {
  max-height: calc(88vh - 140px);
  overflow-y: auto;
}

/* Generic dialog chrome: entity delete confirmations and any other plain
 * confirm/modal form. Previously only the media-library variant above had
 * an actual box (background, width, centering, structured header/footer)
 * — every other .ui-dialog rendered with no background and no layout.
 *
 * core's misc/dialog.css and jquery.ui's base theme.css are disabled for
 * this theme (see tailwindcss.info.yml libraries-override), but
 * core/drupal.dialog *also* pulls in
 * assets/vendor/jquery.ui/themes/base/dialog.css directly as one of its
 * own CSS components — a separate, still-active file that overrides that
 * disables. It sets `.ui-dialog-title` to float+nowrap+ellipsis and
 * `.ui-dialog-titlebar-close` to an old absolute-position hack tuned for
 * its own (disabled) padding — both fought the layout below. Every
 * property that file also sets is re-declared here with !important.
 */
.ui-dialog:not(.media-library-widget-modal) {
  top: 50% !important;
  left: 50% !important;
  transform: translate(-50%, -50%) !important;
  width: min(600px, 92vw) !important;
  max-height: 85vh !important;
  padding: 0 !important;
  background: #fff !important;
  overflow: hidden !important;
  display: flex !important;
  flex-direction: column !important;
}

.ui-dialog:not(.media-library-widget-modal) .ui-dialog-titlebar {
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  position: relative !important;
  gap: 12px;
  padding: 16px 48px 16px 20px !important;
  background: #0f172a !important;
  color: #fff !important;
  flex: 0 0 auto;
}

.ui-dialog:not(.media-library-widget-modal) .ui-dialog-title {
  float: none !important;
  width: auto !important;
  white-space: normal !important;
  overflow: visible !important;
  text-overflow: clip !important;
  margin: 0 !important;
  font-weight: 650;
  font-size: 1.05rem;
  color: #fff;
}

.ui-dialog:not(.media-library-widget-modal) .ui-dialog-titlebar-close {
  position: absolute !important;
  top: 50% !important;
  right: 12px !important;
  transform: translateY(-50%) !important;
  width: 28px !important;
  height: 28px !important;
  margin: 0 !important;
  padding: 0 !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  background: transparent !important;
  border: 0 !important;
  color: #fff;
  cursor: pointer;
  font-size: 1.2rem;
  line-height: 1;
  border-radius: 4px;
}

.ui-dialog:not(.media-library-widget-modal) .ui-dialog-titlebar-close:hover {
  background: rgba(255, 255, 255, 0.15) !important;
}

.ui-dialog:not(.media-library-widget-modal) .ui-dialog-content {
  padding: 20px !important;
  overflow-y: auto;
  background: #fff !important;
  color: #111;
  flex: 1 1 auto;
  width: auto !important;
}

.ui-dialog:not(.media-library-widget-modal) .ui-dialog-buttonpane {
  display: flex !important;
  justify-content: flex-end !important;
  align-items: center;
  text-align: right !important;
  gap: 8px;
  padding: 16px 20px !important;
  margin: 0 !important;
  border-width: 1px 0 0 0;
  border-style: solid;
  border-color: #e5e7eb;
  background: #fff !important;
}

.ui-dialog:not(.media-library-widget-modal) .ui-dialog-buttonpane .ui-dialog-buttonset {
  display: flex !important;
  float: none !important;
  gap: 8px;
}

.ui-dialog:not(.media-library-widget-modal) .ui-dialog-buttonpane button {
  margin: 0 !important;
}

.ui-dialog input,
.ui-dialog select,
.ui-dialog textarea {
  font-size: 0.9em;
}

.ui-dialog .button {
  /*background-color: #fff;*/
  /*background-image: linear-gradient(to bottom, #f3f3f3, #e8e8e8);*/
  border: 1px solid #e4e4e4;
  border-bottom-color: #b4b4b4;
  border-left-color: #d2d2d2;
  border-right-color: #d2d2d2;
  color: #3a3a3a;
  cursor: pointer;
  font-size: 0.929em;
  font-weight: normal;
  text-align: center;
  padding: 0.250em 1.063em;
  border-radius: 1em;
}
