/* =====================================================================
   MEDIA VIEWER (v3.0) - Photo & PDF viewer. Self-contained: works on the
   website and inside the admin portal.
   ===================================================================== */
.mv-root{--mv-bg:rgba(9,18,28,.985);--mv-bar:rgba(15,30,44,.92);--mv-line:rgba(255,255,255,.12);--mv-text:#eef3f7;--mv-muted:#9db0bf;--mv-accent:#c69a4b;
  position:fixed; inset:0; z-index:100000; display:flex; flex-direction:column; background:var(--mv-bg); color:var(--mv-text);
  font-family:'Inter',system-ui,-apple-system,'Segoe UI',sans-serif; font-size:14px; line-height:1.4;
  opacity:0; visibility:hidden; transition:opacity .22s ease, visibility .22s; -webkit-tap-highlight-color:transparent}
.mv-root.open{opacity:1; visibility:visible}
html.mv-lock, html.mv-lock body{overflow:hidden !important}
.mv-root svg{width:20px; height:20px; fill:none; stroke:currentColor; stroke-width:1.8; stroke-linecap:round; stroke-linejoin:round; display:block}

.mv-bar{display:flex; align-items:center; gap:12px; padding:10px 14px; background:var(--mv-bar); border-bottom:1px solid var(--mv-line); flex:none; min-height:58px}
.mv-title{display:flex; align-items:center; gap:10px; min-width:0; flex:1}
.mv-title strong{font-weight:600; font-size:15px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis}
.mv-badge{flex:none; font-size:10px; font-weight:700; letter-spacing:.12em; padding:3px 7px; border-radius:6px; background:var(--mv-accent); color:#241a08}
.mv-root.mv-is-pdf .mv-badge{background:#d9534f; color:#fff}
.mv-counter{color:var(--mv-muted); flex:none}
.mv-tools{display:flex; align-items:center; gap:4px; flex:none}
.mv-tools button, .mv-tools a{width:40px; height:40px; display:inline-flex; align-items:center; justify-content:center; border-radius:10px; border:0; background:transparent;
  color:var(--mv-text); cursor:pointer; text-decoration:none; transition:background .15s}
.mv-tools button:hover, .mv-tools a:hover{background:rgba(255,255,255,.1); color:#fff}
.mv-tools button:focus-visible, .mv-tools a:focus-visible, .mv-nav:focus-visible, .mv-thumb:focus-visible{outline:2px solid var(--mv-accent); outline-offset:2px}
.mv-tools .mv-close{background:rgba(255,255,255,.08); margin-left:4px}
.mv-tools .mv-close:hover{background:#c0392b}
.mv-zoom{min-width:48px; text-align:center; font-variant-numeric:tabular-nums; color:var(--mv-muted); font-size:13px}
.mv-page{color:var(--mv-muted); font-size:13px; margin-right:6px; white-space:nowrap; font-variant-numeric:tabular-nums}
.mv-sep{width:1px; height:24px; background:var(--mv-line); margin:0 4px}

.mv-body{position:relative; flex:1 1 auto; min-height:0; display:flex}
.mv-stage{position:relative; flex:1; overflow:hidden; outline:none}
.mv-root.mv-is-pdf .mv-stage{overflow:auto; -webkit-overflow-scrolling:touch}
.mv-img-wrap{position:absolute; inset:0; overflow:hidden; cursor:zoom-in; touch-action:none}
.mv-img-wrap.zoomed{cursor:grab}
.mv-img-wrap.zoomed:active{cursor:grabbing}
.mv-img{position:absolute; left:50%; top:50%; max-width:none !important; transform-origin:center center; user-select:none; -webkit-user-drag:none;
  box-shadow:0 20px 60px rgba(0,0,0,.5); transition:transform .12s ease-out; background:#fff}
.mv-img-wrap:active .mv-img{transition:none}

.mv-nav{position:absolute; top:50%; transform:translateY(-50%); z-index:3; width:48px; height:48px; border-radius:50%; border:1px solid var(--mv-line);
  background:rgba(15,30,44,.78); color:#fff; display:none; align-items:center; justify-content:center; cursor:pointer; transition:background .15s, transform .15s}
.mv-nav:hover{background:var(--mv-accent); color:#241a08}
.mv-prev{left:14px} .mv-next{right:14px}
.mv-root.mv-multi .mv-nav{display:flex}

.mv-pdf{display:flex; flex-direction:column; align-items:center; gap:16px; padding:18px 16px 40px; min-width:min-content}
.mv-pdf-page{position:relative; background:#fff; box-shadow:0 10px 30px rgba(0,0,0,.45); flex:none}
.mv-pdf-page canvas{display:block}
.mv-pdf-page:not(.ready)::after{content:""; position:absolute; inset:0; background:linear-gradient(100deg,#f1f3f5 30%,#fafbfc 50%,#f1f3f5 70%); background-size:200% 100%; animation:mvShimmer 1.2s infinite}
.mv-pdf-num{position:absolute; right:8px; bottom:6px; z-index:2; font-size:11px; color:#556; background:rgba(255,255,255,.85); padding:1px 6px; border-radius:4px}
@keyframes mvShimmer{to{background-position:-200% 0}}
.mv-iframe{width:100%; height:calc(100% - 34px); border:0; background:#fff}
.mv-fallback-note{text-align:center; margin:8px 0; color:var(--mv-muted); font-size:13px}
.mv-fallback-note a{color:var(--mv-accent)}
.mv-error{position:absolute; inset:0; display:flex; align-items:center; justify-content:center; color:var(--mv-muted)}

.mv-spinner{position:absolute; left:50%; top:50%; width:42px; height:42px; margin:-21px; border-radius:50%; border:3px solid rgba(255,255,255,.18); border-top-color:var(--mv-accent); animation:mvSpin .8s linear infinite}
@keyframes mvSpin{to{transform:rotate(360deg)}}

.mv-foot{flex:none; background:var(--mv-bar); border-top:1px solid var(--mv-line)}
.mv-caption{padding:12px 18px; max-height:22vh; overflow:auto; font-size:14.5px; line-height:1.6; color:#dfe8ef; text-align:center}
.mv-thumbs{display:flex; gap:8px; padding:0 14px 12px; overflow-x:auto; justify-content:safe center}
.mv-thumbs:empty{display:none}
.mv-thumb{flex:none; width:64px; height:48px; border-radius:8px; overflow:hidden; border:2px solid transparent; background:#1d3346; padding:0; cursor:pointer; opacity:.6;
  color:#fff; display:flex; flex-direction:column; align-items:center; justify-content:center; gap:1px; font-size:9px; font-weight:700; transition:opacity .15s, border-color .15s}
.mv-thumb img{width:100%; height:100%; object-fit:cover}
.mv-thumb:hover{opacity:.9}
.mv-thumb.active{opacity:1; border-color:var(--mv-accent)}

/* PDF first-page thumbnails used on cards */
[data-pdf-thumb]{position:relative; overflow:hidden}
[data-pdf-thumb] .mv-thumb-canvas{position:absolute; inset:0; width:100%; height:auto; min-height:100%; object-fit:cover; object-position:top; background:#fff}

@media (max-width:640px){
  .mv-bar{padding:8px 8px; gap:6px; flex-wrap:wrap}
  .mv-title{flex-basis:100%; order:0}
  .mv-tools{width:100%; justify-content:space-between}
  .mv-tools button, .mv-tools a{width:38px; height:38px}
  .mv-sep, [data-a="open"]{display:none !important}
  .mv-nav{width:40px; height:40px; top:auto; bottom:12px; transform:none}
  .mv-caption{font-size:13.5px; padding:10px 12px}
}
@media print{ .mv-root{display:none !important} }
