/* ============================================================
   Variante B (zoom/expand) · standalone landing-v5 · dark híbrido
   Layout: phone | computadora | trail flotante (detrás de la compu).
   Mantiene la planilla ERP en light (es un documento).
   ============================================================ */

.viewport-wrap {
  grid-template-rows: 1fr !important;
  padding: 16px 24px;
}

/* 3 columnas: celular | computadora | audit trail */
.stage {
  grid-template-columns: auto 1fr var(--trail-w, 262px);
  gap: var(--stage-gap, 6px);
}

body[data-variant="b"] .phone-col,
body[data-variant="b"] .laptop-col {
  position: relative;
  z-index: 3;
}

/* ---------- Audit Trail (capa detrás de la compu, frosted dark) ---------- */
.trail {
  position: relative;
  z-index: 1;
  margin-left: -64px;
  padding-left: 70px;
  align-self: center;
  height: var(--ph-height, 600px);
  max-height: calc(100dvh - 110px);
  margin-top: 0;
  background: rgba(20, 22, 28, 0.78);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  backdrop-filter: blur(24px) saturate(180%);
  border: 1px solid rgba(107,143,255,0.18);
  border-radius: 22px;
  padding: 14px 14px 8px;
  box-shadow:
    0 1px 0 rgba(255,255,255,0.05) inset,
    0 18px 50px -16px rgba(0, 0, 0, 0.7);
  display: flex;
  flex-direction: column;
  min-height: 0;
  color: #fff;
}

.trail-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 2px 4px 11px;
  border-bottom: 0.5px solid rgba(255, 255, 255, 0.10);
  margin-bottom: 6px;
}
.trail-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent2);
  box-shadow: 0 0 0 3px rgba(30,91,255,0.20);
}
.trail-title {
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: -0.3px;
  color: #fff;
  flex: 1;
}
.trail-counter {
  font-family: var(--mono);
  font-size: 11px;
  color: rgba(255,255,255,0.45);
}
.trail-counter span { color: #fff; font-weight: 600; }

.trail-list {
  flex: 1;
  list-style: none;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0;
  margin: 0;
  padding: 0 2px;
}
.trail-list::-webkit-scrollbar { width: 0; }
.trail-list { scrollbar-width: none; }

/* Filas limpias estilo Apple sobre dark */
.trail-row {
  display: grid;
  grid-template-columns: 9px minmax(0, 1fr);
  grid-template-rows: auto auto;
  grid-template-areas:
    "dot head"
    "dot text";
  align-items: start;
  gap: 1px 11px;
  padding: 10px 8px;
  border-radius: 12px;
  border-bottom: 0.5px solid rgba(255, 255, 255, 0.06);
  position: relative;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.3s ease, transform 0.3s ease, background 0.2s ease;
}
.trail-row:last-child { border-bottom: none; }
.trail-row.show { opacity: 1; transform: none; }

.trail-row .tr-dot {
  grid-area: dot;
  width: 8px; height: 8px;
  border-radius: 50%;
  align-self: center;
  margin-top: 0;
  border: none;
  box-shadow: none;
}
.trail-row.t-think .tr-dot { background: var(--accent-deep); }
.trail-row.t-erp .tr-dot { background: var(--accent2); }
.trail-row.t-ok .tr-dot { background: var(--ok); }
.trail-row.t-warn .tr-dot { background: var(--warn); }
.trail-row.t-bad .tr-dot { background: var(--bad); }
.trail-row.t-wa .tr-dot { background: #25d366; }

/* head: tipo + hora */
.trail-row .tr-kind {
  grid-area: head;
  display: inline;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.55);
}
.trail-row.t-think .tr-kind { color: var(--accent-deep); }
.trail-row.t-erp .tr-kind { color: var(--accent2); }
.trail-row.t-ok .tr-kind { color: var(--ok); }
.trail-row.t-warn .tr-kind { color: var(--warn); }
.trail-row.t-wa .tr-kind { color: #25d366; }
.trail-row .tr-ts { display: none; }
.trail-row .tr-text {
  grid-area: text;
  font-size: 13px;
  letter-spacing: -0.32px;
  line-height: 1.4;
  color: rgba(255,255,255,0.92);
  margin-top: 2px;
}
.trail-row.t-think .tr-text { color: rgba(255,255,255,0.78); font-style: italic; }

/* inactivos atenuados; el activo pleno */
.trail-row.show { opacity: 0.5; }
.trail-row.show.current { opacity: 1; }
.trail-row.current {
  background: rgba(30, 91, 255, 0.14);
  border-bottom-color: transparent;
}

/* ---------- Foco: atenuar la pantalla que no es centro ---------- */
.ph-screen,
.laptop-col .viewport {
  transition: filter 0.5s ease;
}
body.focus-computer .ph-screen {
  filter: brightness(0.45) saturate(0.85);
}
body.focus-phone .laptop-col .viewport {
  filter: brightness(0.45) saturate(0.85);
}

@media (max-width: 1100px) {
  .stage { grid-template-columns: auto 1fr 240px; }
}
/* En tablet (721-1023), trail se mueve al drawer en styles.css.
   styles-b.css solo deja de aplicar el layout side-by-side de 3 columnas. */
@media (max-width: 1023px) and (min-width: 721px) {
  .stage { grid-template-columns: auto 1fr !important; }
}

/* ============================================================
   Caso tractores: foto en WhatsApp + lightbox clickable,
   visor de cotización, planilla ERP (light, mantiene su look).
   ============================================================ */

/* ---- Burbuja con foto ---- */
.ph-bubble.has-photo {
  padding: 3px;
  max-width: 75%;
  overflow: hidden;
}
.ph-photo {
  position: relative;
  border-radius: 11px;
  overflow: hidden;
  line-height: 0;
}
.ph-photo img { width: 100%; height: auto; display: block; }
.ph-photo::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 42px;
  background: linear-gradient(to top, rgba(0,0,0,0.5), transparent);
  pointer-events: none;
}
.ph-photo-time {
  position: absolute; right: 9px; bottom: 6px; z-index: 1;
  font-size: 11px; line-height: 1; color: rgba(255,255,255,0.95);
  display: inline-flex; align-items: center; gap: 4px;
}
.ph-photo-time .ph-tick { color: #8fd0ff; }

.ph-clickable { cursor: pointer; transition: transform .14s ease, box-shadow .14s ease; }
@media (hover: hover) {
  .ph-clickable:hover { transform: translateY(-1px); }
}
.ph-clickable:active { transform: scale(0.99); }
.ph-filecard { position: relative; }
.ph-filecard-open { margin-left: auto; display: grid; place-items: center; color: var(--accent2); }
.ph-filecard-open svg { width: 16px; height: 16px; }
.ph-bubble.ph-clickable.show::after {
  content: ""; position: absolute; inset: -2px; border-radius: 16px;
  box-shadow: 0 0 0 0 rgba(107,143,255,0.45);
  animation: phTapPulse 2.4s ease-out 0.4s 3;
  pointer-events: none;
}
@keyframes phTapPulse {
  0% { box-shadow: 0 0 0 0 rgba(107,143,255,0.45); }
  70%,100% { box-shadow: 0 0 0 12px rgba(107,143,255,0); }
}

/* ---- Lightbox (la imagen y el PDF se ven sobre fondo oscuro,
   pero el panel del PDF/quote en sí queda LIGHT — es un documento) ---- */
.lightbox {
  position: fixed; inset: 0; z-index: 200;
  display: grid; place-items: center;
  opacity: 0; visibility: hidden;
  transition: opacity .28s ease, visibility 0s linear .28s;
}
.lightbox.open { opacity: 1; visibility: visible; transition: opacity .28s ease; }
.lightbox-backdrop {
  position: absolute; inset: 0;
  background: rgba(2, 4, 12, 0.82);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
}
.lightbox-panel {
  position: relative; z-index: 1;
  max-width: min(920px, 94vw); max-height: 90dvh;
  display: flex; flex-direction: column;
  transform: translateY(14px) scale(0.98);
  transition: transform .3s cubic-bezier(0.22,1,0.36,1);
}
.lightbox.open .lightbox-panel { transform: none; }
.lightbox-close {
  position: absolute; top: -14px; right: -14px; z-index: 3;
  width: 38px; height: 38px; border-radius: 50%;
  border: none; background: #fff; color: #07090f; cursor: pointer;
  display: grid; place-items: center;
  box-shadow: 0 8px 22px -8px rgba(0,0,0,0.7);
  transition: transform .15s ease;
}
.lightbox-close:hover { transform: scale(1.08); }
.lightbox-close svg { width: 18px; height: 18px; }
.lightbox-body { overflow: auto; border-radius: 16px; overscroll-behavior: contain; }
.lightbox.is-photo .lightbox-body { background: transparent; }
.lb-photo { margin: 0; }
.lb-photo img {
  display: block; max-width: 100%; max-height: 78dvh;
  border-radius: 16px; box-shadow: 0 30px 80px -30px rgba(0,0,0,0.8);
}
.lb-photo figcaption {
  margin-top: 12px; text-align: center; color: rgba(255,255,255,0.82);
  font-size: 13.5px; letter-spacing: -0.2px;
}

/* ---- Visor de cotización generado · LIGHT (documento) ---- */
/* Panel con ANCHO explícito: sin esto el flex shrink-wrap toma el ancho intrínseco
   del SVG (gigante) y la imagen se sale por la derecha. Con width fijo, width:100%
   de la img resuelve contra el panel y no hay overflow ni margen blanco. */
.lightbox.is-quote .lightbox-panel { width: min(880px, 92vw); }
.lightbox.is-quote .lightbox-body { background: #fff; box-shadow: 0 30px 90px -30px rgba(0,0,0,0.8); padding: 0; overflow-x: hidden; overflow-y: auto; border-radius: 12px; max-height: 88dvh; }
/* PDF preview como imagen estática (renderiza estable en cualquier viewport).
   width:100% + height:auto = llena el ancho del panel sin letterbox (sin object-fit). */
/* margin:0 obligatorio: <figure> trae 40px de margen UA por defecto → corría el PDF a la derecha y lo desbordaba */
.lb-pdf { display: block; width: 100%; height: auto; margin: 0; background: #fff; }
.lb-pdf img { display: block; width: 100%; max-width: 100%; height: auto; background: #fff; }
@media (max-width: 540px){
  .lightbox.is-quote .lightbox-panel { width: 92vw; }
  .lightbox.is-quote .lightbox-body { max-height: 82dvh; }
}
.qv { width: min(780px, 92vw); padding: 0 0 22px; color: #0b1020; font-size: 13.5px; overflow-x: auto; }
@media (max-width: 540px){
  .qv { width: min(94vw, 420px); font-size: 11px; }
  .qv-head { padding: 14px 14px 12px; flex-direction: column; align-items: flex-start; gap: 8px; }
  .qv-meta { text-align: left; }
  .qv-meta span { font-size: 11px; }
  .qv-meta span:first-child { font-size: 12px; }
  .qv-brand b { font-size: 16px; }
  .qv-brand span { font-size: 11px; }
  .qv-sub { padding: 9px 14px; font-size: 10.5px; flex-wrap: wrap; gap: 6px; }
  .qv-table { width: calc(100% - 24px); margin: 0 12px; font-size: 10px; }
  .qv-table th { font-size: 9px; padding: 5px 4px; }
  .qv-table td { padding: 5px 4px; vertical-align: middle; }
  .qv-codecell { font-size: 9.5px; }
  .qv-orig, .qv-note { font-size: 9px; }
  .qv-machine td { font-size: 10px; padding: 5px 4px; }
  .qv-total { margin: 8px 12px 0; font-size: 12px; padding: 8px 4px 2px; }
  .qv-total b { font-size: 16px; }
  .qv-foot { margin: 8px 12px 0; font-size: 9.5px; }
  .lightbox-panel { max-width: 94vw; }
}
@media (max-width: 380px){
  .qv { width: 96vw; font-size: 10px; }
  .qv-table { font-size: 9px; margin: 0 8px; width: calc(100% - 16px); }
  .qv-table th, .qv-table td { padding: 4px 3px; }
  .qv-codecell { font-size: 8.5px; }
}
.qv-head {
  display: flex; justify-content: space-between; align-items: center; gap: 18px;
  padding: 22px 28px; margin-bottom: 6px;
  background: linear-gradient(120deg, #033CCC 0%, #1e5bff 100%);
  color: #fff;
}
.qv-brand { display: flex; align-items: center; gap: 12px; }
.qv-logo { width: 36px; height: 36px; background: #fff; -webkit-mask: url('assets/img/logo-sv-clean.png') center/contain no-repeat; mask: url('assets/img/logo-sv-clean.png') center/contain no-repeat; }
.qv-brand b { display: block; font-size: 18px; font-weight: 800; letter-spacing: -0.4px; color: #fff; }
.qv-brand span { display: block; font-size: 12px; color: rgba(255,255,255,0.82); }
.qv-meta { text-align: right; }
.qv-meta span { display: block; font-size: 12px; color: rgba(255,255,255,0.82); }
.qv-meta span:first-child { font-weight: 700; color: #fff; font-size: 13px; }
.qv-sub { display: flex; justify-content: space-between; gap: 12px; padding: 12px 28px; color: #5b6478; font-size: 12.5px; border-bottom: 2px solid #033CCC; margin-bottom: 6px; }
.qv-sub b { color: #033CCC; }
.qv-table { width: calc(100% - 56px); margin: 0 28px; border-collapse: collapse; }
.qv-table th { text-align: left; font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.05em; color: #4f6bb3; font-weight: 700; padding: 7px 8px; border-bottom: 1px solid #d6e0fa; }
.qv-table td { padding: 9px 8px; border-bottom: 1px solid #eef2fb; vertical-align: top; }
.qv-num { text-align: right; white-space: nowrap; }
.qv-line { font-weight: 700; color: #033CCC; }
.qv-machine td { background: rgba(3,60,204,0.07); font-weight: 800; font-size: 12.5px; letter-spacing: -0.2px; color: #033CCC; padding: 8px; border-bottom: none; }
.qv-codecell { font-family: 'JetBrains Mono', ui-monospace, monospace; font-size: 12px; }
.qv-code { display: block; }
.qv-orig { display: block; font-size: 10.5px; color: #8a91a3; }
.qv-note { display: block; font-size: 10.5px; color: #b35a00; margin-top: 2px; }
.qv-total { display: flex; justify-content: flex-end; align-items: baseline; gap: 16px; margin: 10px 28px 0; padding: 14px 8px 4px; font-size: 15px; color: #033CCC; border-top: 1px solid #d6e0fa; }
.qv-total b { font-size: 21px; font-weight: 800; letter-spacing: -0.5px; color: #033CCC; }
.qv-foot { margin: 14px 28px 0; font-size: 11.5px; color: #8a91a3; line-height: 1.5; }

body.lightbox-active { overflow: hidden; }

/* ---- Planilla ERP dentro de Odoo (LIGHT — es el screen del ERP) ---- */
.erp-sheet {
  position: absolute;
  left: 0; right: 0; top: 0; bottom: 0;
  z-index: 5;
  background: #f4f5f7;
  color: #1d2433;
  font-size: 12px;
  display: none;
  flex-direction: column;
  overflow: hidden;
}
/* (Las media-queries mobile del erp-sheet viven DESPUÉS de las reglas base de abajo,
   para ganar por orden de fuente — ver bloque "ERP MOBILE" al final de esta sección.) */
.viewport.erp-sheet-on .erp-sheet { display: flex; animation: erpSheetIn .45s ease; }
@keyframes erpSheetIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.es-bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 9px 16px; background: #fff; border-bottom: 1px solid #e3e6ee;
}
.es-crumb { font-size: 12.5px; color: #5b6478; }
.es-crumb b { color: #1d2433; font-weight: 700; }
.es-state {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11px; font-weight: 700; color: #0a7a3e;
  background: rgba(10,122,62,0.10); padding: 4px 10px; border-radius: 999px;
}
.es-state i { width: 7px; height: 7px; border-radius: 50%; background: #0a7a3e; }
.es-meta {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px 18px;
  padding: 12px 16px; background: #fff; border-bottom: 1px solid #e3e6ee;
}
.es-meta .es-k { display: block; font-size: 10px; text-transform: uppercase; letter-spacing: 0.05em; color: #8a91a3; font-weight: 700; }
.es-meta .es-v { display: block; font-size: 12.5px; color: #1d2433; font-weight: 600; margin-top: 2px; }
.es-tablewrap { flex: 1; overflow: auto; background: #fff; margin: 10px; border: 1px solid #e3e6ee; border-radius: 8px; }
.es-table { width: 100%; border-collapse: collapse; }
.es-table thead th {
  position: sticky; top: 0; z-index: 1;
  text-align: left; font-size: 10px; text-transform: uppercase; letter-spacing: 0.04em;
  color: #6b7385; font-weight: 700; background: #f4f6fb;
  padding: 8px 12px; border-bottom: 1px solid #e3e6ee;
}
.es-table td { padding: 8px 12px; border-bottom: 1px solid #eef0f5; vertical-align: middle; }
.es-num { text-align: right; white-space: nowrap; }
.es-sub { font-weight: 700; color: #033CCC; }
.es-prod { font-family: 'JetBrains Mono', ui-monospace, monospace; font-size: 11.5px; font-weight: 600; }
.es-eq { font-family: var(--sans, 'Inter'); font-size: 10px; color: #b35a00; font-weight: 600; }
.es-machine td {
  background: rgba(3,60,204,0.06); color: #033CCC; font-weight: 800;
  font-size: 11.5px; letter-spacing: -0.1px; padding: 7px 12px;
}
.es-total {
  display: flex; justify-content: flex-end; align-items: baseline; gap: 16px;
  padding: 10px 22px 14px; background: #fff; border-top: 1px solid #e3e6ee;
  font-size: 13px; color: #1d2433;
}
.es-total b { font-size: 18px; font-weight: 800; color: #033CCC; letter-spacing: -0.4px; }

/* Wrapper de escala: en desktop es transparente (flex passthrough); en mobile lo
   escala el JS (fitErpSheet) para que la cotización ENTERA entre en la pantalla chica. */
.es-scale { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; width: 100%; }

/* ===== ERP MOBILE — DESPUÉS de las reglas base para ganar por orden de fuente =====
   La cotización entera entra de una en la pantalla chica de la laptop. Se achica el
   CONTENIDO html (no el chasis): fuentes compactas + columnas accesorias ocultas +
   sin scroll interno + scale-to-fit (--es-scale) que pone el JS. */
@media (max-width: 720px){
  .es-scale { flex: none; transform-origin: top center; transform: scale(var(--es-scale, 1)); }
  .erp-sheet { font-size: 8px; }
  .es-bar { padding: 3px 7px; flex-wrap: nowrap; white-space: nowrap; gap: 6px; }
  .es-crumb { font-size: 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; min-width: 0; }
  .es-state { font-size: 6.5px; padding: 1px 6px; flex: none; }
  .es-state i { width: 4px; height: 4px; }
  .es-meta { grid-template-columns: repeat(2, 1fr); gap: 1px 8px; padding: 3px 7px; }
  .es-meta > div:nth-child(n+3) { display: none; }
  .es-meta > div { min-width: 0; }
  .es-meta .es-k { font-size: 6px; letter-spacing: 0.02em; }
  .es-meta .es-v { font-size: 8px; margin-top: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .es-tablewrap { margin: 3px 4px; border-radius: 3px; overflow: visible; flex: none; }
  .es-table thead th { font-size: 6px; padding: 2px 5px; letter-spacing: 0; }
  .es-table thead th:nth-child(2),
  .es-table thead th:nth-child(3),
  .es-table thead th:nth-child(4),
  .es-table tbody tr:not(.es-machine) td:nth-child(2),
  .es-table tbody tr:not(.es-machine) td:nth-child(3),
  .es-table tbody tr:not(.es-machine) td:nth-child(4) { display: none; }
  .es-machine td { font-size: 7px; padding: 1.5px 5px; line-height: 1.1; }
  .es-table td { padding: 1.5px 5px; font-size: 7.5px; line-height: 1.15; vertical-align: middle; }
  .es-prod { font-size: 7px; line-height: 1.1; }
  .es-eq { font-size: 5.5px; display: inline; margin-top: 0; margin-left: 4px; }
  .es-num { font-size: 7.5px; font-weight: 700; }
  .es-total { padding: 3px 8px 4px; font-size: 8px; gap: 6px; }
  .es-total b { font-size: 10px; }
}

/* La planilla ERP cubre el viewport — pero NO el header mask, que queda sobre todo */
.viewport.erp-sheet-on .erp-header-mask { z-index: 6; }

/* ---- Trail: acento del paso activo ---- */
.trail-row.current {
  background: rgba(30, 91, 255, 0.14);
  box-shadow: inset 3px 0 0 var(--accent2);
}
.trail-row.current .tr-dot {
  box-shadow: 0 0 0 0 rgba(107,143,255,0.55);
  animation: trailDotPulse 1.6s ease-out infinite;
}
@keyframes trailDotPulse {
  0% { box-shadow: 0 0 0 0 rgba(107,143,255,0.55); }
  100% { box-shadow: 0 0 0 7px rgba(107,143,255,0); }
}

/* ============================================================
   WhatsApp dark mode — override de los colores light del mockup iphone-sv
   ============================================================ */
.ph-screen { background: #0b141a; }
.ph-statusbar {
  background: #1a1c1f;
  color: #e9edef;
}
.ph-header {
  background: var(--wa-bar);
  border-bottom: 1px solid rgba(255,255,255,0.06);
  color: #fff;
}
.ph-avatar {
  background: linear-gradient(135deg, #1e5bff, #033CCC);
}
.ph-hname { color: #ffffff; }
.ph-hstatus { color: rgba(255,255,255,0.72); }
.ph-hback { color: rgba(255,255,255,0.85); }

.ph-body {
  background-color: #0b141a;
  background-image:
    radial-gradient(rgba(255,255,255,0.025) 1px, transparent 1px);
}
.ph-datechip {
  background: rgba(30,38,46,0.92);
  color: rgba(233,237,239,0.72);
  box-shadow: 0 1px 0.5px rgba(0,0,0,0.5);
}
.ph-bubble.inc {
  background: #202c33;
  color: #e9edef;
}
.ph-bubble.out {
  background: #005c4b;
  color: #e9edef;
}
.ph-time {
  color: rgba(233,237,239,0.55);
}
.ph-bubble.out .ph-time {
  color: rgba(233,237,239,0.62);
}
.ph-tick { color: #8fd0ff; }
.ph-filecard {
  background: rgba(255,255,255,0.06);
}
.ph-bubble.out .ph-filecard {
  background: rgba(0,0,0,0.18);
}
.ph-filecard-ic {
  background: #2a3942;
  color: #d12f2f;
}
.ph-filecard-name { color: #e9edef; }
.ph-filecard-type { color: rgba(233,237,239,0.6); }
.ph-footer {
  background: #1f2c33;
}
.ph-footer .ph-foot-ic { color: rgba(233,237,239,0.65); }
.ph-inputbox {
  background: #2a3942;
  color: rgba(233,237,239,0.5);
}
.ph-inputbox svg { color: rgba(233,237,239,0.55); }
.ph-sendbtn {
  background: #00a884;
}
.ph-home {
  background: #0b141a;
}
.ph-home::after {
  background: rgba(255,255,255,0.82);
}
