/* Visor / carrusel de imagenes (comentarios, gafete, tarjetas, incidencias). */

:root {
  --imgbox-z-backdrop: 140000;
  --imgbox-z-wrap: 140001;
  --imgbox-z-controls: 140002;
  --imgbox-nav-chevron: url("data:image/svg+xml;utf8,<svg viewBox='0 0 17 17' xmlns='http://www.w3.org/2000/svg'><path d='M2.16,6.246 C2.385,6.246 2.61,6.308 2.81,6.442 L9.039,10.598 L15.076,6.401 C15.617,6.042 16.346,6.188 16.705,6.729 C17.065,7.268 16.92,8 16.38,8.359 L9.692,12.989 C9.298,13.253 8.784,13.254 8.388,12.991 L1.508,8.402 C0.966,8.042 0.82,7.31 1.179,6.77 C1.407,6.429 1.78,6.246 2.16,6.246 Z' fill='%23000'/></svg>");
}

body.imgbox-open {
  overflow: hidden;
  overscroll-behavior: none;
}

html.imgbox-open {
  overflow: hidden;
  overscroll-behavior: none;
}

body.imgbox-open #toastRoot.toast-wrap {
  position: fixed !important;
  z-index: 2147483647 !important;
}

body.imgbox-open .has-transform-context {
  transform: none !important;
  filter: none !important;
  perspective: none !important;
  will-change: auto !important;
}

.activity-backdrop.imgbox {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.62);
  z-index: var(--imgbox-z-backdrop);
  padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right))
    max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
}

.imgbox-wrap {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  margin: 0;
  inline-size: min(94vw, 1080px);
  block-size: min(88dvh, 860px);
  touch-action: none;
  max-block-size: min(88dvh, 860px);
  background: #111;
  color: #fff;
  border-radius: 14px;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.45);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 0;
  padding: 0;
  overflow: hidden;
  z-index: var(--imgbox-z-wrap);
}

.imgbox-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 48px;
  padding: 8px 10px 8px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  flex-shrink: 0;
}

.imgbox-counter {
  font-size: 13px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
  opacity: 0.88;
  min-width: 0;
}

.imgbox-x {
  position: static;
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.12s ease, border-color 0.12s ease, transform 0.12s ease;
}

.imgbox-x:hover {
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(255, 255, 255, 0.28);
}

.imgbox-x:active {
  transform: scale(0.96);
}

.imgbox-x .icon-plain svg {
  width: 18px;
  height: 18px;
  display: block;
}

.imgbox-stage {
  min-height: 0;
  height: 100%;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  position: relative;
  padding: 12px 8px;
  background: linear-gradient(180deg, rgba(15, 23, 42, 0.35), rgba(15, 23, 42, 0.12));
  overflow: hidden;
  touch-action: none;
}

.imgbox-media {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.imgbox-img {
  display: block;
  object-fit: contain;
  max-inline-size: 100%;
  max-block-size: 100%;
  width: auto;
  height: auto;
  border-radius: 8px;
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.35);
  transition: opacity 0.18s ease;
  user-select: none;
  -webkit-user-drag: none;
}

.imgbox-error {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 18px 20px;
  max-width: min(100%, 280px);
  border-radius: 12px;
  border: 1px dashed rgba(255, 255, 255, 0.22);
  background: rgba(255, 255, 255, 0.04);
  color: rgba(255, 255, 255, 0.82);
  text-align: center;
}

.imgbox-error-icon svg {
  width: 40px;
  height: 40px;
  display: block;
  opacity: 0.72;
}

.imgbox-error-text {
  font-size: 13px;
  font-weight: 600;
  line-height: 1.4;
}

.imgbox-wrap.is-error .imgbox-img {
  display: none;
}

.imgbox-wrap.is-error .imgbox-error {
  display: flex;
}

.imgbox-prev,
.imgbox-next {
  position: static;
  top: auto;
  transform: none;
  z-index: var(--imgbox-z-controls);
  background: rgba(15, 18, 22, 0.58);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.22);
  width: 44px;
  height: 44px;
  padding: 0;
  cursor: pointer;
  border-radius: 999px;
  font-size: 0;
  line-height: 0;
  display: grid;
  place-items: center;
  box-shadow: 0 12px 22px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(8px);
  transition: transform 0.12s ease, background 0.12s ease, box-shadow 0.12s ease, opacity 0.12s ease, border-color 0.12s ease;
}

.imgbox-prev::before,
.imgbox-next::before {
  content: "";
  width: 18px;
  height: 18px;
  display: block;
  background-color: currentColor;
  -webkit-mask-image: var(--imgbox-nav-chevron);
  mask-image: var(--imgbox-nav-chevron);
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-position: center;
  mask-position: center;
  -webkit-mask-size: contain;
  mask-size: contain;
  transition: transform 0.12s ease, opacity 0.12s ease;
}

.imgbox-prev::before {
  transform: rotate(90deg);
}

.imgbox-next::before {
  transform: rotate(-90deg);
}

.imgbox-prev:hover,
.imgbox-next:hover {
  transform: scale(1.05);
  background: rgba(255, 255, 255, 0.18);
  border-color: rgba(255, 255, 255, 0.35);
}

.imgbox-prev:active,
.imgbox-next:active {
  transform: scale(0.97);
}

.imgbox-prev[disabled],
.imgbox-next[disabled] {
  opacity: 0.32;
  cursor: default;
  box-shadow: none;
  pointer-events: none;
}

.imgbox-prev {
  justify-self: start;
  margin-left: 4px;
}

.imgbox-next {
  justify-self: end;
  margin-right: 4px;
}

.imgbox-footer {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 10px 12px max(12px, env(safe-area-inset-bottom));
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  flex-shrink: 0;
  min-width: 0;
}

.imgbox-thumbs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  padding: 2px 2px 4px;
  scrollbar-gutter: stable;
  justify-content: flex-start;
  scroll-snap-type: x proximity;
  -webkit-overflow-scrolling: touch;
}

.imgbox-thumbs.is-hidden {
  display: none;
}

.imgbox-thumbs::-webkit-scrollbar {
  height: 6px;
}

.imgbox-thumbs::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.22);
  border-radius: 999px;
}

.imgbox-thumb {
  border: 2px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  width: 52px;
  height: 52px;
  padding: 0;
  overflow: hidden;
  cursor: pointer;
  flex: 0 0 auto;
  scroll-snap-align: center;
  transition: border-color 0.12s ease, box-shadow 0.12s ease, transform 0.12s ease;
}

.imgbox-thumb:hover {
  border-color: rgba(255, 255, 255, 0.42);
}

.imgbox-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.imgbox-thumb.is-active {
  border-color: rgba(255, 255, 255, 0.82);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.25), 0 8px 18px rgba(0, 0, 0, 0.35);
  transform: translateY(-1px);
}

.imgbox-wrap.is-loading .imgbox-img {
  opacity: 0;
}

.imgbox-wrap.is-loading .imgbox-skel {
  opacity: 1;
}

.imgbox-wrap.is-hidden {
  opacity: 0;
  pointer-events: none;
}

.imgbox-loading {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  gap: 10px;
  color: #e5e7eb;
  font-weight: 700;
  z-index: var(--imgbox-z-backdrop);
  pointer-events: none;
}

.imgbox-loading-skel {
  width: min(68vw, 520px);
  height: min(46vh, 320px);
  border-radius: 16px;
  background: linear-gradient(90deg, rgba(148, 163, 184, 0.12), rgba(148, 163, 184, 0.28), rgba(148, 163, 184, 0.12));
  background-size: 200% 100%;
  animation: imgbox-shimmer 1.1s linear infinite;
}

.imgbox-loading-text {
  font-size: 13px;
  opacity: 0.85;
}

.imgbox-skel {
  position: absolute;
  inset: 0;
  border-radius: 12px;
  background: linear-gradient(90deg, rgba(148, 163, 184, 0.12), rgba(148, 163, 184, 0.28), rgba(148, 163, 184, 0.12));
  background-size: 200% 100%;
  animation: imgbox-shimmer 1.1s linear infinite;
  opacity: 0;
  pointer-events: none;
}

@keyframes imgbox-shimmer {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

:root[data-theme="light"] .imgbox-loading {
  color: #1f2937;
}

:root[data-theme="light"] .activity-backdrop.imgbox {
  background: rgba(15, 23, 42, 0.42);
}

:root[data-theme="light"] .imgbox-wrap {
  background: #f8fafc;
  color: #0f172a;
  box-shadow: 0 16px 44px rgba(15, 23, 42, 0.2);
}

:root[data-theme="light"] .imgbox-toolbar,
:root[data-theme="light"] .imgbox-footer {
  border-color: rgba(15, 23, 42, 0.1);
}

:root[data-theme="light"] .imgbox-stage {
  background: linear-gradient(180deg, rgba(15, 23, 42, 0.06), rgba(15, 23, 42, 0.02));
}

:root[data-theme="light"] .imgbox-x {
  color: #0f172a;
  background: rgba(15, 23, 42, 0.05);
  border-color: rgba(15, 23, 42, 0.12);
}

:root[data-theme="light"] .imgbox-x:hover {
  background: rgba(15, 23, 42, 0.08);
  border-color: rgba(15, 23, 42, 0.2);
}

:root[data-theme="light"] .imgbox-counter {
  color: #475569;
}

:root[data-theme="light"] .imgbox-prev,
:root[data-theme="light"] .imgbox-next {
  background: rgba(255, 255, 255, 0.92);
  color: #0f172a;
  border-color: rgba(15, 23, 42, 0.12);
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.16), inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

:root[data-theme="light"] .imgbox-prev:hover,
:root[data-theme="light"] .imgbox-next:hover {
  background: #fff;
  border-color: rgba(15, 23, 42, 0.22);
}

:root[data-theme="light"] .imgbox-thumb {
  border-color: rgba(15, 23, 42, 0.16);
  background: #f1f5f9;
}

:root[data-theme="light"] .imgbox-thumb.is-active {
  border-color: rgba(15, 23, 42, 0.5);
  box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.12), 0 8px 18px rgba(15, 23, 42, 0.14);
}

:root[data-theme="light"] .imgbox-error {
  border-color: rgba(15, 23, 42, 0.16);
  background: rgba(15, 23, 42, 0.04);
  color: #475569;
}

:root[data-theme="light"] .imgbox-skel {
  background: linear-gradient(90deg, rgba(148, 163, 184, 0.18), rgba(148, 163, 184, 0.35), rgba(148, 163, 184, 0.18));
}

:root[data-theme="dark"] .activity-backdrop.imgbox {
  background: rgba(0, 0, 0, 0.72);
}

:root[data-theme="dark"] .imgbox-wrap {
  background: #0b0f14;
  color: #e5e7eb;
  box-shadow: 0 20px 56px rgba(0, 0, 0, 0.65);
}

@media (max-width: 900px) {
  .imgbox-wrap {
    inline-size: min(96vw, 900px);
    block-size: min(86dvh, 820px);
    max-block-size: min(86dvh, 820px);
  }

  .imgbox-stage {
    padding: 10px 4px;
  }

  .imgbox-skel {
    inset: 0;
  }
}

@media (max-width: 640px) {
  .activity-backdrop.imgbox {
    padding: 0;
    place-items: stretch;
  }

  .imgbox-wrap {
    left: 0;
    top: 0;
    right: 0;
    bottom: 0;
    transform: none;
    inline-size: 100%;
    block-size: 100%;
    max-block-size: none;
    border-radius: 0;
    box-shadow: none;
  }

  .imgbox-toolbar {
    min-height: 52px;
    padding-top: max(10px, env(safe-area-inset-top));
    padding-inline: 12px;
  }

  .imgbox-stage {
    padding: 8px 4px;
  }

  .imgbox-prev {
    margin-left: 2px;
  }

  .imgbox-next {
    margin-right: 2px;
  }

  .imgbox-prev,
  .imgbox-next {
    width: 40px;
    height: 40px;
  }

  .imgbox-thumb {
    width: 44px;
    height: 44px;
  }

  .imgbox-footer {
    padding-inline: 10px;
  }
}

@media (max-width: 420px) {
  .imgbox-stage {
    padding: 6px 2px;
  }

  .imgbox-prev,
  .imgbox-next {
    width: 36px;
    height: 36px;
  }

  .imgbox-prev::before,
  .imgbox-next::before {
    width: 16px;
    height: 16px;
  }

  .imgbox-thumb {
    width: 40px;
    height: 40px;
  }

  .imgbox-counter {
    font-size: 12px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .imgbox-img,
  .imgbox-prev,
  .imgbox-next,
  .imgbox-x,
  .imgbox-thumb,
  .imgbox-loading-skel,
  .imgbox-skel {
    transition: none;
    animation: none;
  }
}
