/* =========================================================
   attachment_viewer.css — Portable Santa Fe
   Visor de adjuntos PRO (SaaS)
   - Compatible con tema claro/oscuro por variables CSS
   - Sin estilos duplicados
   ========================================================= */

/* =========================
   Tokens (fallbacks)
   Si tu sistema ya define variables, esto NO estorba:
   simplemente se pisan desde tu themes.css
   ========================= */
:root {
  --mkav-bg: rgba(0,0,0,.72);
  --mkav-panel: #111;
  --mkav-panel-2: #151515;
  --mkav-border: rgba(255,255,255,.10);
  --mkav-text: #fff;
  --mkav-text-2: rgba(255,255,255,.70);
  --mkav-btn-bg: rgba(255,255,255,.06);
  --mkav-btn-bd: rgba(255,255,255,.18);
  --mkav-btn-hv: rgba(255,255,255,.10);
  --mkav-focus: rgba(88,160,255,.45);
}

/* Si tu app usa modo claro, podés pisar variables desde tu theme.
   Esto es SOLO un fallback razonable. */
@media (prefers-color-scheme: light) {
  :root {
    --mkav-bg: rgba(0,0,0,.55);
    --mkav-panel: #f7f7f8;
    --mkav-panel-2: #ffffff;
    --mkav-border: rgba(0,0,0,.10);
    --mkav-text: #111;
    --mkav-text-2: rgba(0,0,0,.65);
    --mkav-btn-bg: rgba(0,0,0,.04);
    --mkav-btn-bd: rgba(0,0,0,.12);
    --mkav-btn-hv: rgba(0,0,0,.07);
    --mkav-focus: rgba(0,120,255,.28);
  }
}

/* =========================
   Root overlay
   ========================= */
#mkAttachmentViewer {
  position: fixed;
  inset: 0;
  z-index: 200000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

/* Backdrop (si tu JS lo crea como #mkAVBackdrop) */
#mkAVBackdrop {
  position: absolute;
  inset: 0;
  background: var(--mkav-bg);
}

/* =========================
   Panel principal
   ========================= */
#mkAVPanel {
  position: relative;
  width: min(1100px, 96vw);
  height: min(720px, 92vh);
  background: var(--mkav-panel);
  border-radius: 16px;
  overflow: hidden; /* el panel recorta, el body no */
  display: flex;
  flex-direction: column;
  border: 1px solid var(--mkav-border);
  box-shadow: 0 18px 60px rgba(0,0,0,.45);
}

/* =========================
   Header
   ========================= */
#mkAVHeader {
  padding: 12px 14px;
  border-bottom: 1px solid var(--mkav-border);
  background: linear-gradient(180deg, var(--mkav-panel-2), var(--mkav-panel));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

#mkAVTitleWrap {
  min-width: 0;
}

#mkAVTitle {
  font-size: 14px;
  font-weight: 650;
  color: var(--mkav-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#mkAVSubtitle {
  font-size: 12px;
  color: var(--mkav-text-2);
  margin-top: 2px;
}

/* Acciones */
#mkAVActions {
  display: flex;
  gap: 8px;
  align-items: center;
}

#mkAVActions a,
#mkAVActions button {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 7px 10px;
  border-radius: 10px;
  border: 1px solid var(--mkav-btn-bd);
  background: var(--mkav-btn-bg);
  color: var(--mkav-text);
  font-size: 12px;
  cursor: pointer;
  text-decoration: none;
  user-select: none;
  transition: transform .08s ease, background .12s ease, border-color .12s ease;
}

#mkAVActions a:hover,
#mkAVActions button:hover {
  background: var(--mkav-btn-hv);
}

#mkAVActions a:active,
#mkAVActions button:active {
  transform: translateY(1px);
}

#mkAVActions a:focus-visible,
#mkAVActions button:focus-visible {
  outline: 0;
  box-shadow: 0 0 0 3px var(--mkav-focus);
}

/* =========================
   Body (CLAVE)
   ========================= */
#mkAVBody {
  position: relative;
  flex: 1;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: visible; /* NO recortar controles */
  padding: 12px;
  box-sizing: border-box;
}

/* Frame genérico */
.mkav-frame {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
}

/* =========================
   Imagen
   ========================= */
#mkAVBody img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  background: #000;
}

/* =========================
   Video (FIX REAL)
   Forzamos que SIEMPRE entre en el body
   ========================= */
/* El body del viewer debe poder encogerse dentro del panel (fix flex/min-height) */
#mkAVPanel{
  display: flex;
  flex-direction: column;
}

#mkAVBody{
  flex: 1;
  min-height: 0;      /* CRÍTICO: evita que el body crezca más que el panel */
  overflow: hidden;   /* sin scroll global dentro del viewer */
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Video: nunca forzar height:100% (rompe controles). Usar max-height. */
#mkAVBody video{
  width: 100%;
  height: auto;
  max-height: 100%;
  background: #000;
  object-fit: contain;
  border-radius: 12px;
}

/* Premium desktop: videos verticales no deben “perderse” en un mar negro */
@media (min-width: 900px){
  #mkAVBody video{
    max-width: 860px;
  }
}

/* =========================
   PDF (si lo renderizás en iframe)
   ========================= */
#mkAVBody iframe {
  width: 100%;
  height: 100%;
  border: 0;
  background: #111;
}
