/* ============================================================
   DTHLight Viewer — CSS
   Lightweight, dependency-free lightbox for images / PDF / docs
   Namespaced: every selector is prefixed with dthlight_ to avoid
   collisions with other plugins on the same page.
   ============================================================ */
:root {
  --dthlight-bg: #14161a;
  --dthlight-surface: #1c1f25;
  --dthlight-surface-alt: #23262d;
  --dthlight-border: #33363f;
  --dthlight-text: #f0f1f3;
  --dthlight-text-dim: #9ba1ac;
  --dthlight-accent: #5b8cff;
  --dthlight-accent-hover: #4573e6;
  --dthlight-danger: #ef4d5f;
  --dthlight-success: #22c58b;
  --dthlight-success-hover: #1aa876;
  --dthlight-radius: 10px;
}

/* Prevents the page behind the modal from scrolling while it's open. */
body.dthlight_no-scroll {
  overflow: hidden !important;
}

/* ---------- Overlay ---------- */
.dthlight_modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(6, 7, 10, 0.88);
  justify-content: center;
  align-items: center;
  z-index: 999999;
  padding: 48px 16px;
  box-sizing: border-box;
  backdrop-filter: blur(4px);
}
.dthlight_modal-overlay.dthlight_open { display: flex; }

/* ---------- Centered content box (lightcase-style) ----------
   NOTE: this outer box does NOT clip (no overflow:hidden), so the
   close button can float slightly outside its top-right corner
   without being cut off. Rounding + clipping of the actual image/
   pdf/doc content happens one level down, on .dthlight_modal-inner. */
.dthlight_modal-content {
  position: relative;
  color: var(--dthlight-text);
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  width: min(1400px, 95vw);
  height: min(780px, 88vh);
  max-width: 95vw;
  max-height: 88vh;
  animation: dthlight_fadeScaleIn 0.22s ease-out;
}

@keyframes dthlight_fadeScaleIn {
  from { opacity: 0; transform: scale(0.97); }
  to   { opacity: 1; transform: scale(1); }
}

/* Inner box actually clips content to rounded corners */
.dthlight_modal-inner {
  position: relative;
  width: 100%;
  height: 100%;
  background: var(--dthlight-bg);
  border-radius: var(--dthlight-radius);
  box-shadow: 0 25px 70px rgba(0, 0, 0, 0.55);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ---------- Close button — floats at the corner, lightcase-style ---------- */
.dthlight_btn-close {
  position: absolute;
  top: -16px;
  right: -16px;
  z-index: 5;
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid var(--dthlight-border);
  background: var(--dthlight-surface);
  color: var(--dthlight-text);
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  transition: background 0.2s, transform 0.15s;
}
.dthlight_btn-close:hover {
  background: var(--dthlight-danger);
  border-color: var(--dthlight-danger);
  transform: rotate(90deg);
}

/* ---------- Caption / title bar (bottom, lightcase-style) ---------- */
.dthlight_caption-bar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  border-top: 1px solid var(--dthlight-border);
  background: var(--dthlight-surface);
}
.dthlight_caption-title {
  font-size: 13px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--dthlight-text);
}
.dthlight_caption-counter {
  flex-shrink: 0;
  font-size: 12px;
  font-weight: 600;
  color: var(--dthlight-text-dim);
}

/* ---------- Prev / Next arrows — overlap the viewport edges ---------- */
.dthlight_nav-arrow {
  display: none;
  align-items: center;
  justify-content: center;
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 4;
  width: 42px;
  height: 42px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(20, 22, 26, 0.55);
  color: #fff;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  transition: background 0.2s, opacity 0.2s;
}
.dthlight_nav-arrow:hover:not(:disabled) { background: var(--dthlight-accent); }
.dthlight_nav-arrow:disabled { opacity: 0.25; cursor: not-allowed; }
.dthlight_nav-arrow.dthlight_visible { display: flex; }
#dthlight_btn-prev { left: 12px; }
#dthlight_btn-next { right: 12px; }

/* ---------- Thumbnail strip ---------- */
.dthlight_thumbnail-strip {
  display: none;
  gap: 6px;
  padding: 8px 12px;
  overflow-x: auto;
  flex-shrink: 0;
  background: var(--dthlight-surface);
  border-top: 1px solid var(--dthlight-border);
}
.dthlight_thumbnail-strip.dthlight_visible { display: flex; }

.dthlight_thumbnail {
  flex-shrink: 0;
  width: 42px;
  height: 42px;
  border-radius: 6px;
  border: 2px solid transparent;
  overflow: hidden;
  cursor: pointer;
  background: var(--dthlight-surface-alt);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  color: var(--dthlight-text-dim);
  opacity: 0.55;
  transition: all 0.15s;
}
.dthlight_thumbnail:hover { opacity: 0.9; }
.dthlight_thumbnail.dthlight_active {
  border-color: var(--dthlight-accent);
  opacity: 1;
}
.dthlight_thumbnail img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* ---------- Body sections (image / pdf / doc) ---------- */
.dthlight_body-section {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  position: relative;
}

/* Image zoom controls */
.dthlight_controls {
  display: flex;
  gap: 6px;
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 3;
}
.dthlight_controls button {
  padding: 6px 10px;
  cursor: pointer;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 7px;
  background: rgba(20, 22, 26, 0.55);
  color: #fff;
  font-size: 12px;
  font-weight: 500;
  transition: background 0.2s;
}
.dthlight_controls button:hover { background: var(--dthlight-accent); }

.dthlight_viewport {
  width: 100%;
  height: 100%;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  position: relative;
  background-color: #000;
  cursor: grab;
  user-select: none;
}
.dthlight_viewport.dthlight_dragging { cursor: grabbing; }

.dthlight_zoom-target {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: none;
  display: block;
  object-fit: contain;
  transform-origin: center center;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s ease;
}
.dthlight_zoom-target.dthlight_visible { opacity: 1; }

/* PDF section — plain in-page viewing, no zoom/pan */
.dthlight_pdf-iframe {
  width: 100%;
  height: 100%;
  border: none;
  background: #fff;
}

/* Document download card */
.dthlight_download-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  flex: 1 1 auto;
  min-height: 0;
  background: var(--dthlight-surface);
  text-align: center;
  padding: 20px;
}
.dthlight_download-icon { font-size: 64px; }
.dthlight_download-filename {
  font-weight: 600;
  color: var(--dthlight-text);
  word-break: break-all;
  max-width: 90%;
  font-size: 15px;
}
.dthlight_download-btn {
  display: inline-block;
  padding: 10px 24px;
  background: var(--dthlight-success);
  color: #06231a;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
  transition: background 0.2s;
}
.dthlight_download-btn:hover { background: var(--dthlight-success-hover); }
.dthlight_hint {
  font-size: 12px;
  color: var(--dthlight-text-dim);
}

/* Loading spinner shown while an image/pdf is fetching */
.dthlight_spinner {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 30px;
  height: 30px;
  margin: -15px 0 0 -15px;
  border: 3px solid rgba(255, 255, 255, 0.2);
  border-top-color: var(--dthlight-accent);
  border-radius: 50%;
  animation: dthlight_spin 0.7s linear infinite;
  z-index: 2;
}
.dthlight_spinner.dthlight_hidden { display: none; }
@keyframes dthlight_spin { to { transform: rotate(360deg); } }

/* ---------- Mobile: go edge-to-edge like a full screen viewer ---------- */
@media (max-width: 700px) {
  .dthlight_modal-overlay { padding: 0; }
  .dthlight_modal-content {
    width: 100vw;
    height: 100vh;
    max-width: 100vw;
    max-height: 100vh;
  }
  .dthlight_modal-inner { border-radius: 0; }
  .dthlight_btn-close { top: 10px; right: 10px; }
}