/* Unified popup system for DLE-generated dialogs and template-owned modals. */

.ui-widget-overlay {
  position: fixed !important;
  inset: 0 !important;
  width: 100% !important;
  height: 100% !important;
  background: rgba(5, 8, 10, .68) !important;
  backdrop-filter: blur(4px);
  opacity: 1 !important;
  z-index: 10010 !important;
}

.ui-dialog {
  position: fixed !important;
  top: 50% !important;
  left: 50% !important;
  width: min(520px, calc(100vw - 32px)) !important;
  height: auto !important;
  min-height: 0 !important;
  max-height: calc(100dvh - 32px);
  margin: 0 !important;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--wd-line-strong);
  border-radius: var(--wd-radius);
  background: var(--wd-paper-strong);
  color: var(--wd-ink);
  font-family: var(--wd-font-sans);
  font-size: var(--wd-text-base);
  line-height: 1.5;
  box-shadow: var(--wd-shadow);
  transform: translate(-50%, -50%) !important;
  z-index: 10020 !important;
}

.ui-dialog:is(.dle-popup-allvotes, .dle-popup-mediaupload, .dle-popup-quickedit, .dle-popup-replycomments, .dle-popup-userprofileadmin, .dle-popup-imageinsert, .dle-popup-urlinsert) {
  width: min(720px, calc(100vw - 32px)) !important;
}

.ui-dialog .ui-dialog-titlebar {
  position: relative;
  display: flex;
  min-height: 56px;
  height: auto;
  padding: 17px 60px 16px 22px;
  align-items: center;
  overflow: hidden;
  border: 0;
  border-bottom: 1px solid var(--wd-line);
  background: linear-gradient(135deg, var(--wd-night-soft), var(--wd-teal-dark));
  line-height: 1.25;
  cursor: move;
}

.ui-dialog .ui-dialog-title {
  display: block;
  float: none;
  margin: 0;
  overflow: hidden;
  color: var(--wd-gold-pale);
  font-family: var(--wd-font-sans);
  font-weight: 800;
  font-size: var(--wd-text-lg);
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ui-dialog .ui-dialog-titlebar-close,
.ui-dialog .ui-dialog-titlebar-close.ui-button {
  position: absolute;
  top: 10px;
  right: 12px;
  display: grid;
  width: 36px;
  height: 36px;
  min-height: 0;
  margin: 0 !important;
  padding: 0;
  place-items: center;
  overflow: hidden;
  border: 1px solid rgba(241, 213, 126, .28);
  border-radius: 50%;
  background: rgba(255, 249, 238, .08);
  box-shadow: none;
  color: var(--wd-gold-pale);
  font-size: 0;
  line-height: 1;
  text-indent: -999px;
  cursor: pointer;
}

.ui-dialog .ui-dialog-titlebar-close::before,
.ui-dialog .ui-dialog-titlebar-close.ui-button::before {
  content: "×";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--wd-gold-pale);
  font-weight: 800;
  font-size: 1.45rem;
  line-height: 1;
  text-indent: 0;
}

.ui-dialog .ui-dialog-titlebar-close:hover,
.ui-dialog .ui-dialog-titlebar-close.ui-button:hover {
  border-color: rgba(241, 213, 126, .56);
  background: rgba(255, 249, 238, .14);
}

.ui-dialog .ui-button-icon,
.ui-dialog .ui-button-icon-space {
  display: none;
}

.ui-dialog .ui-dialog-content {
  position: relative;
  width: auto !important;
  height: auto !important;
  min-height: 0 !important;
  max-height: min(62dvh, 520px) !important;
  padding: 24px;
  overflow: auto;
  border: 0;
  background: var(--wd-paper-strong);
  color: var(--wd-ink);
  font-family: var(--wd-font-sans);
  font-size: .95rem;
  line-height: 1.55;
}

.ui-dialog .ui-dialog-content :is(input:not([type="checkbox"]):not([type="radio"]), select, textarea) {
  max-width: 100%;
  border: 1px solid var(--wd-input-border);
  border-radius: 10px;
  background: var(--wd-input-bg);
  color: var(--wd-ink);
  font: inherit;
}

.ui-dialog .ui-dialog-content :is(input:not([type="checkbox"]):not([type="radio"]), select) {
  min-height: 40px;
  padding: 8px 11px;
}

.ui-dialog .ui-dialog-content textarea {
  min-height: 110px;
  padding: 10px 11px;
  resize: vertical;
}

.ui-dialog .ui-dialog-content :is(input, select, textarea):focus {
  border-color: var(--wd-input-border-focus);
  outline: 0;
  box-shadow: var(--wd-input-focus-ring);
}

.ui-dialog .ui-dialog-content :is(a, b, strong) {
  color: var(--wd-teal-deep);
}

.ui-dialog .ui-dialog-buttonpane {
  margin: 0;
  padding: 14px 18px 16px;
  border: 0;
  border-top: 1px solid var(--wd-line);
  background: var(--wd-paper-soft);
  text-align: initial;
}

.ui-dialog .ui-dialog-buttonset {
  display: flex;
  float: none;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.ui-dialog .ui-button:not(.ui-dialog-titlebar-close) {
  min-height: 40px;
  margin: 0 !important;
  padding: 9px 16px;
  border: 1px solid var(--wd-btn-border-gold-soft);
  border-radius: 999px;
  background: var(--wd-btn-bg-lapis);
  color: var(--wd-on-dark);
  font-family: var(--wd-font-sans);
  font-weight: 800;
  font-size: var(--wd-text-sm);
  line-height: 1;
  box-shadow: var(--wd-btn-shadow);
  cursor: pointer;
}

.ui-dialog .ui-button:not(.ui-dialog-titlebar-close):hover {
  background: var(--wd-btn-bg-lapis-hover);
}

.ui-dialog .ui-state-error,
.ui-dialog.dle-popup-alert .ui-dialog-content {
  border-color: rgba(140, 44, 45, .42) !important;
  background: rgba(199, 122, 86, .10) !important;
  color: var(--wd-alert-dark) !important;
}

:root[data-wd-theme="dark"] .ui-dialog .ui-dialog-content :is(a, b, strong) {
  color: var(--wd-teal-light);
}

:root[data-wd-theme="dark"] .ui-dialog .ui-state-error,
:root[data-wd-theme="dark"] .ui-dialog.dle-popup-alert .ui-dialog-content {
  color: #F3C4AC !important;
}

/* DLE share popup. */
body #share-popup {
  width: min(414px, calc(100vw - 24px));
  padding: 16px;
  overflow: hidden;
  border: 1px solid var(--wd-line-strong);
  border-radius: 16px;
  background: var(--wd-paper-strong);
  color: var(--wd-ink);
  box-shadow: var(--wd-shadow);
  font-family: var(--wd-font-sans);
  z-index: 10020;
}

body #share-popup .social,
body #share-popup .link {
  height: auto;
  margin: 0;
  padding: 10px 0;
  border-color: var(--wd-line);
}

body #share-popup :is(p, a, span) {
  color: var(--wd-ink);
}

/* DLE toast notifications. */
body .DLEPush {
  top: 20px;
  right: 20px;
  width: min(360px, calc(100vw - 40px));
  z-index: 10040;
}

body .DLEPush-notification.wrapper {
  overflow: hidden;
  border: 1px solid var(--wd-line-strong);
  border-left: 4px solid var(--wd-teal);
  border-radius: 14px;
  background: var(--wd-paper-strong);
  color: var(--wd-ink);
  box-shadow: var(--wd-shadow);
  font-family: var(--wd-font-sans);
}

body .DLEPush-notification.wrapper.push-warning {
  border-left-color: var(--wd-gold);
  background: var(--wd-paper-strong);
}

body .DLEPush-notification.wrapper.push-error {
  border-left-color: var(--wd-alert-soft);
  background: var(--wd-paper-strong);
}

body .DLEPush-notification :is(.DLEPush-header, .DLEPush-message, .DLEPush-close) {
  color: var(--wd-ink);
}

/* AvatarSelect module: template override without changing the engine module. */
body .ava-modal {
  padding: 24px;
  align-items: center;
  justify-content: center;
  background: rgba(5, 8, 10, .72);
  backdrop-filter: blur(4px);
  color: var(--wd-ink);
  font: var(--wd-text-base)/1.5 var(--wd-font-sans);
  z-index: 10030;
}

body .ava-modal[style*="display: block"] {
  display: flex !important;
}

body .ava-modal-window {
  width: min(720px, calc(100vw - 32px));
  max-width: 720px;
  max-height: calc(100dvh - 48px);
  margin: auto;
  overflow: hidden;
  border: 1px solid var(--wd-line-strong);
  border-radius: var(--wd-radius);
  background: var(--wd-paper-strong);
  box-shadow: var(--wd-shadow);
}

body .ava-modal-title {
  min-height: 64px;
  padding: 18px 60px 16px 70px;
  border-bottom: 1px solid var(--wd-line);
  background: linear-gradient(135deg, var(--wd-night-soft), var(--wd-teal-dark));
  color: var(--wd-gold-pale);
  font-weight: 800;
  font-size: var(--wd-text-lg);
  line-height: 1.3;
  text-transform: none;
}

body .ava-modal-title-img {
  top: 10px;
  left: 14px;
  width: 44px;
  height: 44px;
  border: 1px solid rgba(241, 213, 126, .38);
}

body .ava-modal-title a.ava-modal-close {
  top: 13px;
  right: 14px;
  width: 36px;
  height: 36px;
  margin: 0;
  border: 1px solid rgba(241, 213, 126, .28);
  border-radius: 50%;
  background: rgba(255, 249, 238, .08);
  opacity: 1;
}

body .ava-modal-title a.ava-modal-close::before {
  content: "×";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--wd-gold-pale);
  font-weight: 800;
  font-size: 1.45rem;
}

body .ava-modal-content {
  height: min(570px, calc(100dvh - 190px));
  padding: 20px;
  background: var(--wd-paper-strong);
}

body .ava-modal-content-list li img {
  border: 1px solid var(--wd-line);
  border-radius: 12px;
  background: var(--wd-paper-soft);
}

body .ava-modal-content-list li.current img,
body .ava-modal-content-list li img:hover {
  border-color: var(--wd-teal);
  background: rgba(43, 179, 177, .18);
  box-shadow: 0 0 0 3px rgba(43, 179, 177, .12);
}

body .ava-modal-content-list li.active img {
  border-color: var(--wd-gold);
  background: rgba(201, 168, 91, .18);
}

body .ava-modal-footer {
  display: flex;
  padding: 14px 18px 16px;
  justify-content: flex-end;
  gap: 10px;
  border-top: 1px solid var(--wd-line);
  background: var(--wd-paper-soft);
}

body .ava-modal-footer button {
  float: none;
  min-height: 40px;
  height: auto;
  margin: 0;
  padding: 9px 16px;
  border: 1px solid var(--wd-btn-border-gold-soft);
  border-radius: 999px;
  background: var(--wd-btn-bg-lapis);
  color: var(--wd-on-dark);
  font: 800 var(--wd-text-sm)/1 var(--wd-font-sans);
  letter-spacing: 0;
  text-transform: none;
  opacity: 1;
}

body .ava-modal-footer button:hover {
  background: var(--wd-btn-bg-lapis-hover);
}

/* Horoscope module: template-owned wide content modal. */
body #popup-horoscope {
  inset: 0;
  height: 100dvh;
  padding: 24px;
  justify-content: center;
  background: rgba(5, 8, 10, .72);
  backdrop-filter: blur(4px);
  color: var(--wd-ink);
  font-family: var(--wd-font-sans);
  z-index: 10030;
}

body .popup-horoscope {
  width: min(770px, calc(100vw - 32px));
  max-width: 770px;
  max-height: calc(100dvh - 48px);
  margin: 0;
  overflow: auto;
  border: 1px solid var(--wd-line-strong);
  border-radius: var(--wd-radius);
  background: var(--wd-paper-strong);
  color: var(--wd-ink);
  box-shadow: var(--wd-shadow);
}

/* Dialog shells use soft depth instead of a visible one-pixel outline. */
:is(
  .ui-dialog,
  body #share-popup,
  body .DLEPush-notification.wrapper,
  body .ava-modal-window,
  body .popup-horoscope
) {
  border: 0;
  box-shadow: var(--wd-surface-shadow);
}

body .popup-horoscope-top {
  min-height: 150px;
  padding: 18px 56px 18px 18px;
  gap: 20px;
  align-items: center;
  border-radius: 0;
  background-color: var(--wd-teal-dark);
  color: var(--wd-on-dark);
}

body .popup-horoscope-top-left img {
  display: block;
  width: 120px;
  max-width: 28vw;
  height: auto;
}

body .popup-horoscope-title {
  padding: 0;
  color: var(--wd-gold-pale);
  font-family: var(--wd-font-sans);
  font-size: var(--wd-text-2xl);
  line-height: 1.2;
}

body .popup-horoscope-forecast {
  margin-top: 0;
  color: var(--wd-on-dark-muted);
  opacity: 1;
}

body #close-popup-horoscope {
  top: 12px;
  right: 12px;
  width: 36px;
  height: 36px;
  margin: 0;
  padding: 9px;
  border: 1px solid rgba(241, 213, 126, .28);
  border-radius: 50%;
  background: rgba(255, 249, 238, .08);
  opacity: 1;
}

body .popup-horoscope-sort {
  margin: 12px 0 0;
  gap: 8px;
}

body .popup-horoscope-sort > button {
  height: auto;
  min-height: 36px;
  margin: 0;
  padding: 8px 12px;
  border: 1px solid rgba(241, 213, 126, .24);
  border-radius: 999px;
  color: var(--wd-on-dark);
  font: 700 var(--wd-text-sm)/1 var(--wd-font-sans);
  text-decoration: none;
}

body .popup-horoscope-sort > button:hover,
body .popup-horoscope-sort > button.active {
  border-color: var(--wd-teal-light);
  background: rgba(43, 179, 177, .24);
}

body #popup-horoscope-text {
  padding: 24px;
  background: var(--wd-paper-strong);
  color: var(--wd-ink);
}

body #popup-horoscope-text > p {
  margin: 0 0 1em;
  font-size: var(--wd-text-base);
  line-height: var(--wd-leading-normal);
}

@media (max-width: 600px) {
  .ui-dialog {
    width: min(440px, calc(100vw - 20px)) !important;
    max-height: calc(100dvh - 20px);
  }

  .ui-dialog .ui-dialog-content {
    max-height: calc(100dvh - 146px) !important;
    padding: 20px 18px;
  }

  .ui-dialog .ui-dialog-buttonset {
    display: grid;
    grid-template-columns: 1fr;
  }

  .ui-dialog .ui-button:not(.ui-dialog-titlebar-close) {
    width: 100%;
  }

  body .ava-modal,
  body #popup-horoscope {
    padding: 10px;
  }

  body .ava-modal-window,
  body .popup-horoscope {
    width: calc(100vw - 20px);
    max-height: calc(100dvh - 20px);
  }

  body .ava-modal-content-list li {
    width: 50%;
  }

  body .ava-modal-footer {
    display: grid;
    grid-template-columns: 1fr;
  }

  body .ava-modal-footer button {
    width: 100%;
  }

  body .popup-horoscope-top {
    flex-direction: column;
    padding: 54px 18px 18px;
    text-align: center;
  }

  body .popup-horoscope-top-right {
    display: flex;
    flex-direction: column;
    align-items: center;
  }

  body .popup-horoscope-sort {
    justify-content: center;
  }

  body #popup-horoscope-text {
    padding: 20px 18px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .ui-dialog,
  body .DLEPush-notification.wrapper,
  body .ava-modal,
  body #popup-horoscope {
    animation: none !important;
    transition: none !important;
  }
}
