﻿.ui-modal {
  position: fixed;
  inset: 0;
  z-index: 220;
  display: grid;
  place-items: center;
}

.ui-modal[hidden] {
  display: none;
}

.ui-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(9, 14, 12, 0.72);
  backdrop-filter: blur(2px);
}

.ui-modal-dialog {
  position: relative;
  z-index: 1;
  width: min(900px, calc(100vw - 24px));
  max-height: calc(100vh - 28px);
  border: 1px solid var(--line-soft);
  border-radius: 18px;
  background: linear-gradient(170deg, rgba(30, 43, 37, 0.98), rgba(21, 31, 26, 0.98));
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: uiModalIn 160ms ease-out;
}

.ui-modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 4;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  background: rgba(17, 24, 20, 0.82);
  color: #f4f8ff;
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
}

.ui-modal-close:hover {
  border-color: rgba(62, 207, 142, 0.56);
  color: #f4f8ff;
}

.ui-modal-body {
  padding: 20px;
}

.image-modal-body {
  position: relative;
  min-height: 320px;
  max-height: calc(100vh - 80px);
  display: grid;
  place-items: center;
  padding-inline: 56px;
}

.image-modal-body img {
  max-width: 100%;
  max-height: calc(100vh - 130px);
  object-fit: contain;
  border-radius: 14px;
  border: 1px solid var(--line-soft);
  background: #ffffff;
}

.image-modal-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 42px;
  height: 42px;
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  background: rgba(17, 24, 20, 0.82);
  color: #f4f8ff;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
  z-index: 2;
}

.image-modal-nav:hover {
  border-color: rgba(62, 207, 142, 0.56);
}

.image-modal-nav-prev {
  left: 8px;
}

.image-modal-nav-next {
  right: 8px;
}

.image-modal-counter {
  position: absolute;
  left: 50%;
  bottom: 8px;
  transform: translateX(-50%);
  min-width: 72px;
  min-height: 32px;
  padding: 0 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  border: 1px solid var(--line-soft);
  background: rgba(17, 24, 20, 0.82);
  color: #f4f8ff;
  font-size: 13px;
  font-weight: 700;
}

@keyframes uiModalIn {
  from {
    opacity: 0;
    transform: translateY(6px) scale(0.985);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}


:root[data-theme="light"] .ui-modal-backdrop {
  background: rgba(148, 163, 184, 0.28);
}

:root[data-theme="light"] .ui-modal-dialog {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.99), rgba(247, 250, 252, 0.96));
  box-shadow: 0 20px 44px rgba(28, 45, 64, 0.16);
}

:root[data-theme="light"] .ui-modal-close {
  background: rgba(21, 32, 43, 0.04);
  color: var(--text-soft);
}

:root[data-theme="light"] .ui-modal-close:hover {
  color: var(--text);
}

:root[data-theme="light"] .image-modal-nav,
:root[data-theme="light"] .image-modal-counter {
  background: rgba(255, 255, 255, 0.92);
  color: var(--text);
}

@media (max-width: 640px) {
  .image-modal-body {
    padding-inline: 16px;
    padding-bottom: 52px;
  }

  .image-modal-nav {
    top: auto;
    bottom: 8px;
    transform: none;
  }

  .image-modal-nav-prev {
    left: 16px;
  }

  .image-modal-nav-next {
    right: 16px;
  }
}
