/* client/src/styles/v217.css — v2.17 Protección del contenido (copia, capturas, impresión)
   y reglas responsivas generales (ningún texto se desborda). */

/* ── Sin selección ni arrastre de texto (components/protect.js) ───────── */
html.vl-protect, html.vl-protect body, html.vl-protect body * {
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
}
html.vl-protect input, html.vl-protect textarea, html.vl-protect select,
html.vl-protect [contenteditable=""], html.vl-protect [contenteditable="true"] {
  -webkit-user-select: text; user-select: text;
}
html.vl-protect img, html.vl-protect svg, html.vl-protect a { -webkit-user-drag: none; }

/* ── Impresión: sólo el visor de documentos y los informes ────────────── */
@media print {
  body:not(.docv-printing):not(.vl-print-ok) > * { display: none !important; }
  body:not(.docv-printing):not(.vl-print-ok)::before {
    content: 'ValdiviaLux — las pantallas no se imprimen. Use el botón «Documento» o «Imprimir» del informe.';
    display: block; padding: 40px; font: 14px/1.5 system-ui, Arial, sans-serif; color: #000;
  }
}

/* ── Regla responsiva general (v2.17) ─────────────────────────────────────
   Ningún texto puede salirse de su caja: las palabras largas (códigos,
   correos, nombres de obra) se parten en vez de empujar el ancho. */
.card, .modal-title, .modal-body, .toast, .empty-state, .page-title, .field-hint, .field-label,
.hlp-pop, .hlp-body, .pvc-cat-info, .user-menu, .sidebar-footer, .page-header > *,
.nav-item {
  /* v2.17.1: «break-word» y no «anywhere». Las dos parten una palabra que no
     cabe en la línea, pero «anywhere» (que se hereda) además rebaja el ancho
     mínimo de cada hijo a una letra: en una fila flex o en un menú flotante
     el navegador aplastaba el texto en una columna de letras (menú de sesión,
     «Impo/rtar», nombres de cliente al importar). */
  overflow-wrap: break-word; min-width: 0;
}
table.rt td { overflow-wrap: anywhere; min-width: 0; }
/* Un botón nunca se angosta más que su palabra más larga ni la parte por la
   mitad; si no caben juntos, la fila se quiebra (regla siguiente). */
.btn { max-width: 100%; white-space: normal; text-align: center; overflow-wrap: break-word; min-width: auto; }
/* Toda fila con dos o más botones se quiebra en vez de apretarlos (las filas
   con clase propia y flex-wrap: nowrap mantienen lo suyo: :where pesa cero). */
:where(div, span, header, footer, nav, form, td):has(> .btn + .btn, > .btn + .hlp-pair, > .hlp-pair + .btn, > .hlp-pair + .hlp-pair) {
  flex-wrap: wrap;
}
.page-header { flex-wrap: wrap; gap: 8px; }
.page-header > * { max-width: 100%; }
.hlp-row { min-width: 0; }
img, svg, canvas, video { max-width: 100%; }

/* Teléfono acostado (poca altura): ventanas y ayudas caben y se desplazan por dentro */
@media (max-height: 480px) and (orientation: landscape) {
  /* (las ventanas .modal-box ya ocupan toda la altura: responsive.css) */
  .hlp-pop { max-height: 80vh; max-height: 80dvh; overflow-y: auto; }
  .hlp-sheet { max-height: 85vh; max-height: 85dvh; }
}

/* ── v2.17.1 Menú de la sesión (chip de usuario) ──────────────────────────
   Cuelga de un chip de ~36 px en el teléfono: sin un ancho propio, la regla
   general de arriba (min-width: 0 + overflow-wrap: anywhere) lo dejaba de
   72 px de ancho y más de 1000 px de alto, con el texto partido letra a letra.
   Ahora toma el ancho de su contenido, nunca menos de 230 px ni más que la
   pantalla, y si no cabe a lo alto (teléfono acostado) se desplaza por dentro. */
#user-chip .user-menu {
  width: max-content;
  min-width: min(230px, calc(100vw - 16px));
  max-width: min(340px, calc(100vw - 16px));
  max-height: calc(100vh - var(--topbar-h, 56px) - 16px);
  max-height: calc(100dvh - var(--topbar-h, 56px) - env(safe-area-inset-top) - 16px);
  overflow-y: auto; overscroll-behavior: contain;
  overflow-wrap: break-word;
}
#user-chip .user-menu-item { min-height: 44px; text-align: left; white-space: normal; }
#user-chip .user-menu-item .ic { flex: 0 0 auto; }

/* ── v2.17.1 Panel de Control ───────────────────────────────────────────
   Tarjetas: el texto al lado del ícono puede angostarse (antes empujaba la
   tarjeta y quedaba cortado a 1024 px). Barras: el nombre del cliente se
   envuelve en vez de cortarse con «…». */
.stat-card > :not(.stat-icon) { min-width: 0; overflow-wrap: break-word; }

/* ── v2.17.1 Título de la barra superior en el teléfono ─────────────────
   Antes era una línea con «…» («Versiones de presupuest…» a 320 px). Ahora
   usa hasta dos líneas dentro de la misma barra. */
@media (max-width: 767px) {
  #topbar-breadcrumb {
    white-space: normal; text-overflow: clip; overflow-wrap: break-word;
    line-height: 1.15; display: -webkit-box; -webkit-box-orient: vertical;
    -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden;
  }
}
.hbar-label { white-space: normal; overflow: visible; text-overflow: clip; overflow-wrap: break-word; line-height: 1.3; }

/* ── Botón pegado a su ⓘ (components/help.js → helpPair) ──────────────── */
.hlp-pair { display: inline-flex; align-items: center; gap: 6px; flex-wrap: nowrap; max-width: 100%; min-width: 0; }
.hlp-pair > .btn { min-width: 0; }
