/*
 * CIMA Viewer — visor público de documentos por enlace compartible (viewer.appcima.com)
 * Renderiza el documento desde D1 (token expirable). Solo Guardar / Imprimir.
 * © 2024–2026 CIMA Development Group. Todos los derechos reservados.
 */
/* Tema institucional del landing (appcima.com): navy #04346C + teal #00AFC2; SIEMPRE claro, como appcima.com (no sigue al dispositivo). */
:root {
  color-scheme: light;
  --primary: #04346C; --primary-2: #0A5AA8; --accent: #00AFC2; --accent-2: #5FD6E3;
  --bg: #EDF2F8; --surface: #FFFFFF; --bar-bg: rgba(255, 255, 255, .88);
  --border: rgba(10, 37, 64, .12); --text: #0A2540; --text-muted: rgba(10, 37, 64, .66);
  --shadow: 0 14px 44px rgba(4, 20, 44, .14); --sheet-shadow: 0 14px 44px rgba(4, 20, 44, .22);
  --hover: rgba(10, 37, 64, .06); --ok: #0E9F78; --ok-bg: rgba(45, 212, 167, .16); --ok-line: rgba(14, 159, 120, .45);
  --bad: #C62828; --bad-2: #EF5350; --hold: #B45309; --hold-2: #F59E0B;
  --logo-filter: none; --font: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif; --font-head: 'Roboto Condensed', 'Inter', sans-serif;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
/* Sin gestos del navegador: ni pinch-zoom, ni swipe atrás/adelante, ni callout iOS. */
html, body { overscroll-behavior: none; touch-action: pan-x pan-y; -webkit-touch-callout: none; }
/* [hidden] SIEMPRE gana (el display:flex de .vw-bar le ganaba al atributo → la barra
   salía hasta en "Enlace no válido"). */
[hidden] { display: none !important; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

/* ── Barra superior (logo como en la ventana de CIMA Docs) ─────────────────── */
.vw-bar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px;
  background: var(--bar-bg);
  backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--border);
  border-top: 3px solid var(--accent);
}
.vw-brand { color: var(--primary); display: flex; align-items: center; gap: 6px; font-weight: 700; font-size: .95rem; flex: 0 0 auto; }
.vw-logo { height: 16px; filter: var(--logo-filter); }
.vw-title {
  flex: 1 1 auto; min-width: 0;
  font-size: .86rem; color: var(--text-muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.vw-act { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }
.vw-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 12px; border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--surface); color: var(--text);
  cursor: pointer; font-size: .84rem; font-family: inherit;
}
.vw-btn:hover { background: var(--hover); border-color: var(--accent); }
.vw-btn[disabled] { opacity: .5; cursor: default; }
.vw-chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 6px 10px; border-radius: 999px;
  border: 1px solid var(--ok-line);
  background: var(--ok-bg); color: var(--ok);
  font-size: .76rem; text-decoration: none;
}

/* ── Lienzo de hojas ───────────────────────────────────────────────────────── */
.vw-stage { padding: 26px 12px 60px; display: flex; flex-direction: column; align-items: center; gap: 22px; }
.vw-wrap { position: relative; overflow: visible; flex: 0 0 auto; }
.vw-sheet {
  background: #fff; color: #111;
  box-shadow: var(--sheet-shadow);
  transform-origin: top left;
  position: relative; overflow: hidden;
}
.vw-sheet .cd-qr, .vw-sheet [data-cd-qrflow] { display: none !important; }   /* placeholders del editor, nunca en el render */

/* de1696: foto o PDF subido */
.vw-file { width: 100%; max-width: 900px; display: flex; justify-content: center; }
.vw-file img { max-width: 100%; height: auto; background: #fff; box-shadow: var(--sheet-shadow); }
.vw-file.pdf iframe { width: 100%; height: calc(100vh - 170px); min-height: 420px; border: 0; background: #fff; box-shadow: var(--sheet-shadow); }
.vw-file-open { max-width: 260px; }

/* ── Tarjetas de estado (cargando / caducado / inválido) ───────────────────── */
.vw-card {
  width: 100%; max-width: 440px; margin: 10vh auto 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 4px solid var(--accent);
  border-radius: 18px; padding: 32px 28px 26px;
  box-shadow: var(--shadow);
  text-align: center;
}
.vw-badge { width: 92px; height: 92px; border-radius: 50%; display: flex; align-items: center; justify-content: center; margin: 0 auto 18px; }
.vw-badge.expired { background: linear-gradient(145deg, var(--hold), var(--hold-2)); box-shadow: 0 0 0 8px rgba(245, 158, 11, .14); }
.vw-badge.bad { background: linear-gradient(145deg, var(--bad), var(--bad-2)); box-shadow: 0 0 0 8px rgba(239, 83, 80, .14); }
.vw-h1 { font-family: var(--font-head); font-size: 1.5rem; font-weight: 700; letter-spacing: .2px; color: var(--primary); }
.vw-sub { margin: 8px 0 20px; color: var(--text-muted); font-size: .92rem; line-height: 1.5; }
.vw-cta {
  display: inline-block; padding: 12px 22px;
  border-radius: 11px; border: none;
  background: var(--primary);
  color: #fff; font-size: .95rem; font-weight: 700; text-decoration: none; cursor: pointer;
}
.vw-brandline { margin-top: 22px; display: flex; align-items: center; justify-content: center; gap: 7px; color: var(--text-muted); font-size: .74rem; letter-spacing: .04em; }
.vw-brandline img { height: 16px; filter: var(--logo-filter); }
.vw-spin { display: inline-block; width: 30px; height: 30px; border: 3px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: vwspin 1s linear infinite; }
@keyframes vwspin { to { transform: rotate(360deg); } }

/* ── de0881 E4: selector «¿Quién eres?» del enlace permanente ──────────────── */
.vw-who { container-type: inline-size; }
.vw-who-logo { display: block; max-width: 140px; max-height: 72px; margin: 0 auto 10px; object-fit: contain; border-radius: 12px; }
.vw-who-logo.cima { width: 64px; height: 64px; }
.vw-who-org { color: var(--text); font-size: .9rem; font-weight: 600; margin-bottom: 14px; overflow-wrap: anywhere; }
.vw-who-btn { display: flex; flex-direction: column; align-items: center; gap: 2px; width: 100%; margin-top: 10px; padding: 14px 18px; border-radius: 13px; font-size: 1rem; font-weight: 700; text-decoration: none; color: #fff; box-sizing: border-box; }
.vw-who-btn small { font-size: .76rem; font-weight: 500; opacity: .78; }
.vw-who-btn.alt { background: transparent; color: var(--primary); border: 1px solid var(--primary); }
.vw-cta:hover { background: var(--primary-2); }
.vw-loading { padding: 26px 0; color: var(--text-muted); }
@container (max-width: 340px) { .vw-who .vw-h1 { font-size: 1.2rem; } .vw-who-btn { padding: 12px 14px; } }
@media (max-width: 480px) { .vw-card { margin-top: 6vh; padding: 26px 18px 22px; } }

/* ── Impresión: hojas a tamaño real, una por página, sin chrome ────────────── */
@media print {
  body { background: #fff; }
  .vw-bar { display: none !important; }
  .vw-stage { padding: 0; gap: 0; display: block; }
  .vw-wrap { width: auto !important; height: auto !important; page-break-after: always; break-after: page; }
  .vw-wrap:last-child { page-break-after: auto; break-after: auto; }
  .vw-sheet { transform: none !important; box-shadow: none !important; }
  .vw-file img { box-shadow: none; max-height: 100vh; }
  .vw-file-open { display: none !important; }
  @page { size: letter; margin: 0; }
}
body.vw-landscape-print { }
@media print { body.vw-landscape-print { } }
