/* Shared dialog treatment for native Learn. Explicit confirmation targets keep
   rich editors, calculators and larger selection dialogs at their intended size.
   New confirmation dialogs can opt in with .hypatia-confirmation. */
body[data-hypatia-design="modern"] .modal:not(.hypatia-tool-panel) .modal-content {
  border: 1px solid var(--ht-line) !important;
  border-radius: 14px !important;
  box-shadow: 0 20px 64px #172f422b;
}
body[data-hypatia-design="modern"] .modal:not(.hypatia-tool-panel) .modal-header {
  align-items: center;
  gap: 16px;
  padding: 20px 24px 12px;
  border-bottom: 0;
  border-radius: 14px 14px 0 0 !important;
}
body[data-hypatia-design="modern"] .modal:not(.hypatia-tool-panel) .modal-title {
  margin: 0;
  color: var(--ht-ink) !important;
  font-size: 19px;
  font-weight: 650;
  line-height: 1.35;
  letter-spacing: -.025em;
  text-transform: none !important;
  overflow-wrap: anywhere;
}
body[data-hypatia-design="modern"] .modal:not(.hypatia-tool-panel) .modal-header .close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 36px;
  width: 36px;
  height: 36px;
  min-height: 36px;
  margin: -4px -8px -4px auto;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ht-muted);
  font-size: 25px;
  font-weight: 400;
  line-height: 1;
  text-shadow: none;
  opacity: 1;
}
body[data-hypatia-design="modern"] .modal:not(.hypatia-tool-panel) .modal-header .close:hover {
  background: var(--ht-soft);
  color: var(--ht-ink);
}
body[data-hypatia-design="modern"] .modal:not(.hypatia-tool-panel) .modal-body {
  padding: 8px 24px 24px;
  color: var(--ht-ink);
  font-size: 15px;
  line-height: 1.6;
  overflow-wrap: anywhere;
}
body[data-hypatia-design="modern"] .modal:not(.hypatia-tool-panel) .modal-body > p {
  margin-bottom: 12px;
}
body[data-hypatia-design="modern"] .modal:not(.hypatia-tool-panel) .modal-body > :last-child {
  margin-bottom: 0;
}
body[data-hypatia-design="modern"] .modal:not(.hypatia-tool-panel) .modal-footer {
  gap: 8px;
  padding: 16px 24px;
  border-top: 1px solid var(--ht-line);
  border-radius: 0 0 14px 14px;
  background: var(--ht-soft);
}
body[data-hypatia-design="modern"] .modal:not(.hypatia-tool-panel) .modal-footer > .btn {
  margin: 0;
  min-height: 40px;
  padding: 9px 16px;
  font-size: 14px;
  white-space: normal;
}
/* Cancel stays quiet; existing action classes/types and event hooks stay intact. */
body[data-hypatia-design="modern"] .modal:not(.hypatia-tool-panel) .modal-footer > .btn:is(
  [type="submit"], .btn-outline-primary, .btn-outline-primary-dark,
  .btn-outline-success, .btn-outline-danger
) {
  background: #146397;
  border-color: #146397;
  color: #fff;
}
body[data-hypatia-design="modern"] .modal:not(.hypatia-tool-panel) .modal-footer > .btn:is(
  [type="submit"], .btn-outline-primary, .btn-outline-primary-dark,
  .btn-outline-success, .btn-outline-danger
):hover:not(:disabled) {
  background: #1b89d1;
  border-color: #1b89d1;
  color: #fff;
}
body[data-hypatia-design="modern"] :is(
  .hypatia-confirmation, #confirmModal, #alertModal, #releaseModal,
  #startGradingModal, #releaseMarksModal, #deleteModal, #deleteAllLinkedModal,
  #unlockModal, #clearAnswersModal, #confirm-add-answers-modal
) > .modal-dialog {
  width: auto;
  max-width: min(480px, calc(100vw - 32px));
  margin-left: auto;
  margin-right: auto;
}
body[data-hypatia-design="modern"] :is(
  .hypatia-confirmation, #confirmModal, #alertModal, #releaseModal,
  #startGradingModal, #releaseMarksModal, #deleteModal, #deleteAllLinkedModal,
  #unlockModal, #clearAnswersModal, #confirm-add-answers-modal
) .modal-body {
  max-height: 60vh;
  overflow-y: auto;
}
/* Keep the broader deletion action secondary to deleting just this question. */
body[data-hypatia-design="modern"] #deleteAllLinkedModal .modal-footer > #deleteAllLinkedQuestionsBtn {
  background: var(--ht-paper);
  border-color: var(--ht-line);
  color: var(--ht-ink);
}
body[data-hypatia-design="modern"] #deleteAllLinkedModal .modal-footer > #deleteAllLinkedQuestionsBtn:hover {
  background: var(--ht-selected);
  border-color: var(--ht-light);
  color: var(--ht-blue);
}
body[data-hypatia-design="modern"] :is(
  .hypatia-confirmation, #confirmModal, #alertModal, #releaseModal,
  #startGradingModal, #releaseMarksModal, #deleteModal, #deleteAllLinkedModal,
  #unlockModal, #clearAnswersModal, #confirm-add-answers-modal
) .modal-content {
  max-height: calc(100vh - 32px);
  max-height: calc(100dvh - 32px);
  overflow: hidden;
}
/* The scrollable body must shrink before either the heading or actions do. */
body[data-hypatia-design="modern"] .modal-dialog-scrollable > .modal-content {
  overflow: hidden;
}
@media (max-width: 575.98px) {
  body[data-hypatia-design="modern"] .modal:not(.hypatia-tool-panel) .modal-header {
    padding: 18px 18px 10px;
  }
  body[data-hypatia-design="modern"] .modal:not(.hypatia-tool-panel) .modal-body {
    padding: 8px 18px 20px;
  }
  body[data-hypatia-design="modern"] .modal:not(.hypatia-tool-panel) .modal-footer {
    padding: 14px 18px;
  }
}
