/* FENIX/SIVA — Accesibilidad movil V2 · 2026-11-19
 * Complemento visual. NO modifica permisos, QR, GPS, formularios, OCR ni actas.
 * Funciona con data-fenix-lectura="normal|grande|extra" ya instalado.
 * Seleccion del tema: se respetan las variables --vt-* existentes.
 */

/* En telefonos, el zoom global de 120 % estrechaba el area disponible.
   Reducimos SOLO el zoom de la maqueta movil, compensando con fuentes
   legibles en controles afectados. En escritorio se mantiene 110/120 %. */
@media screen and (max-width: 767px) {
  html[data-fenix-lectura="grande"] body { zoom: 1.06 !important; }
  html[data-fenix-lectura="extra"] body { zoom: 1.10 !important; }
}

@media screen and (max-width: 767px) {
  /* Cabecera y perfil: evitar un nombre largo que empuje el menu fuera del movil. */
  html body .app-header {
    box-sizing: border-box !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    padding-inline: 10px !important;
  }
  html body .app-header .header-left,
  html body .app-header .header-right,
  html body .app-header .user-menu { min-width: 0 !important; }
  html body .app-header .user-menu button.top-user-button {
    box-sizing: border-box !important;
    width: 50px !important;
    min-width: 50px !important;
    max-width: 50px !important;
    height: 50px !important;
    min-height: 50px !important;
    padding: 4px !important;
    justify-content: center !important;
    gap: 0 !important;
  }
  html body .app-header .user-menu .top-user-text,
  html body .app-header .user-menu .top-user-chevron {
    display: none !important;
  }
  html body .app-header .user-menu .top-user-photo {
    box-sizing: border-box !important;
    flex: 0 0 40px !important;
    width: 40px !important;
    height: 40px !important;
    min-width: 40px !important;
    min-height: 40px !important;
  }
  html body .app-header .user-menu .top-user-photo img {
    display: block !important;
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
  }

  /* El menu se abre completamente dentro del ancho del telefono y permite scroll. */
  html body .app-header .user-menu .account-menu {
    box-sizing: border-box !important;
    position: fixed !important;
    top: 74px !important;
    left: auto !important;
    right: 10px !important;
    width: min(310px, calc(100vw - 54px)) !important;
    max-width: calc(100vw - 54px) !important;
    max-height: calc(100dvh - 86px) !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    overscroll-behavior: contain !important;
    -webkit-overflow-scrolling: touch !important;
    z-index: 100020 !important;
  }
  html body .account-menu .account-summary,
  html body .account-menu .account-summary-text,
  html body .account-menu .account-actions { min-width: 0 !important; }
  html body .account-menu .account-summary-text strong,
  html body .account-menu .account-summary-text span,
  html body .account-menu .account-item {
    overflow-wrap: anywhere !important;
    white-space: normal !important;
    line-height: 1.35 !important;
  }
  html body .account-menu .account-item {
    box-sizing: border-box !important;
    min-height: 44px !important;
    height: auto !important;
    padding-top: 9px !important;
    padding-bottom: 9px !important;
  }

  /* La vista operativa no debe tener una anchura minima heredada. */
  html body .app-main,
  html body .app-content,
  html body .qr-panel,
  html body .qr-panel-body {
    box-sizing: border-box !important;
    min-width: 0 !important;
    max-width: 100% !important;
  }
  html body .qr-grid2,
  html body .qr-repl-topgrid,
  html body .qr-repl-midgrid {
    grid-template-columns: minmax(0,1fr) !important;
    min-width: 0 !important;
  }
  html body .qr-btn-row,
  html body .qr-repl-card-actions { flex-wrap: wrap !important; }
  html body .qr-btn-row .qr-btn,
  html body .qr-repl-card-actions .qr-btn,
  html body .qr-panel .qr-notice,
  html body .qr-panel .qr-location-status {
    height: auto !important;
    white-space: normal !important;
    overflow-wrap: anywhere !important;
    line-height: 1.5 !important;
  }
  html body .qr-btn-row .qr-btn,
  html body .qr-repl-card-actions .qr-btn { min-height: 44px !important; padding: 9px 13px !important; }
}

/* Novedades operativas: estas clases provienen de novedades/widget.php y
   assets/css/pages/novedades-widget.css del proyecto. */
@media screen and (max-width: 767px) {
  html body > .fn-modal {
    box-sizing: border-box !important;
    padding: 7px !important;
    max-width: 100% !important;
  }
  html body > .fn-modal .fn-panel,
  html body > .fn-modal .fn-panel.sm,
  html body > .fn-modal .fn-panel.xs {
    box-sizing: border-box !important;
    width: 100% !important;
    max-width: 100% !important;
    max-height: calc(100dvh - 14px) !important;
    min-height: 0 !important;
    margin: auto 0 !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
  }
  html body > .fn-modal .fn-panel > form {
    min-height: 0 !important;
    flex: 1 1 auto !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
  }
  html body > .fn-modal .fn-body {
    box-sizing: border-box !important;
    min-width: 0 !important;
    min-height: 0 !important;
    flex: 1 1 auto !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    -webkit-overflow-scrolling: touch !important;
    overscroll-behavior-y: contain !important;
  }
  html body > .fn-modal .fn-head,
  html body > .fn-modal .fn-footer { box-sizing: border-box !important; flex: 0 0 auto !important; }
  html body > .fn-modal .fn-footer {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 8px !important;
    padding: 10px 12px max(10px, env(safe-area-inset-bottom)) !important;
  }
  html body > .fn-modal .fn-footer > .fn-btn,
  html body > .fn-modal form .fn-footer > .fn-btn {
    box-sizing: border-box !important;
    flex: 1 1 120px !important;
    min-width: 0 !important;
    min-height: 44px !important;
    height: auto !important;
    white-space: normal !important;
    line-height: 1.3 !important;
    padding: 9px 12px !important;
    text-align: center !important;
  }
  html body > .fn-modal .fn-grid { grid-template-columns: minmax(0, 1fr) !important; }
  html body > .fn-modal .fn-section,
  html body > .fn-modal .fn-field,
  html body > .fn-modal .fn-file-picker,
  html body > .fn-modal .fn-file-picker-copy { min-width: 0 !important; box-sizing: border-box !important; }
  html body > .fn-modal .fn-field label,
  html body > .fn-modal .fn-section-title {
    overflow-wrap: anywhere !important;
    white-space: normal !important;
    line-height: 1.35 !important;
    font-size: 12px !important;
  }
  html body > .fn-modal .fn-help,
  html body > .fn-modal .fn-upload-note {
    white-space: normal !important;
    overflow-wrap: anywhere !important;
    font-size: 11px !important;
    line-height: 1.45 !important;
  }
  html body > .fn-modal .fn-field input:not([type="file"]),
  html body > .fn-modal .fn-field select,
  html body > .fn-modal .fn-field textarea {
    box-sizing: border-box !important;
    width: 100% !important;
    max-width: 100% !important;
    font-size: 16px !important; /* Evita zoom automatico de iOS al enfocar */
    line-height: 1.45 !important;
  }
  html body > .fn-modal .fn-field select,
  html body > .fn-modal .fn-field input:not([type="file"]) { min-height: 48px !important; }
  html body > .fn-modal .fn-field textarea { min-height: 130px !important; }

  /* Botones de fotografia/video visibles; etiquetas completas y pulsables. */
  html body > .fn-modal .fn-file-picker {
    display: grid !important;
    grid-template-columns: 36px minmax(0,1fr) !important;
    align-items: start !important;
    gap: 5px 9px !important;
    width: 100% !important;
    min-height: 88px !important;
    height: auto !important;
    padding: 10px !important;
    overflow: visible !important;
    cursor: pointer !important;
  }
  html body > .fn-modal .fn-file-picker-icon {
    grid-column: 1 !important;
    width: 36px !important;
    height: 36px !important;
    flex-basis: 36px !important;
  }
  html body > .fn-modal .fn-file-picker-copy {
    grid-column: 2 !important;
    min-width: 0 !important;
    overflow: visible !important;
  }
  html body > .fn-modal .fn-file-picker-copy b {
    display: block !important;
    font-size: 12px !important;
    line-height: 1.4 !important;
    white-space: normal !important;
    overflow-wrap: anywhere !important;
  }
  html body > .fn-modal .fn-file-picker-copy span {
    display: block !important;
    max-width: 100% !important;
    font-size: 11px !important;
    line-height: 1.45 !important;
    white-space: normal !important;
    overflow-wrap: anywhere !important;
    overflow: visible !important;
    text-overflow: clip !important;
  }
  html body > .fn-modal .fn-file-picker-btn {
    display: inline-flex !important; /* Version anterior los ocultaba en movil */
    grid-column: 2 !important;
    justify-self: start !important;
    align-self: start !important;
    justify-content: center !important;
    align-items: center !important;
    min-height: 36px !important;
    height: auto !important;
    padding: 7px 12px !important;
    font-size: 11px !important;
    line-height: 1.25 !important;
    white-space: normal !important;
    border-radius: 9px !important;
  }
  html body > .fn-modal .fn-file-picker:focus-within { outline: 2px solid var(--vt-primary,#dc2626); outline-offset: 2px; }
  html body > .fn-modal .fn-media-preview,
  html body > .fn-modal .fn-media-gallery { grid-template-columns: minmax(0,1fr) !important; }
  html body > .fn-modal .fn-head h3 { font-size: 15px !important; line-height: 1.35 !important; }
  html body > .fn-modal .fn-head p { font-size: 11px !important; line-height: 1.35 !important; }
  html body > .fn-modal .fn-close { flex: 0 0 40px !important; width: 40px !important; height: 40px !important; }
}

@media screen and (max-width: 360px) {
  html body > .fn-modal .fn-file-picker-btn { grid-column: 1 / -1 !important; width: 100% !important; }
  html body .app-header .user-menu .account-menu { right: 8px !important; width: calc(100vw - 48px) !important; }
}

@media print {
  /* El CSS original ya anula zoom; no intervenir en impresion. */
  html body > .fn-modal .fn-file-picker-btn { display: none !important; }
}
