/* NS Gestión · Adaptación a celular y tablet (r21).
   En el celular se usa el mismo sistema completo que en el PC (sin la vista móvil aparte).
   Se carga al final: solo corrige lo necesario en pantallas angostas. */

/* La vista móvil aparte queda retirada en todos los tamaños */
html.mpos-off .mobile-pos-shell,html .mpos-bottom-nav,#nsVolverMovil{display:none!important}
/* Las ventanas de diálogo quedan sobre el menú lateral (antes el menú tapaba el borde izquierdo de las ventanas anchas). */
html body .fx-back{z-index:10050!important}
html body .ns-modal-overlay{z-index:10040!important}

/* ---------- Tablet (hasta 1024 px) ---------- */
@media (max-width:1024px){
  html body .pos-venta,html body .pos-venta-3{grid-template-columns:minmax(0,1fr) minmax(0,1fr)!important}
  html body .pos-venta-3>*:first-child{grid-column:1/-1}
  html body .fx{max-width:min(var(--fx-max,900px),calc(100vw - 32px))!important}
}

/* ---------- Celular (hasta 768 px) ---------- */
@media (max-width:768px){
  html,body{overflow-x:hidden!important}
  html body.nsv2 .app{padding-left:12px!important;padding-right:12px!important}

  /* Barra superior: buscador ocupa el espacio libre, «Nuevo» queda como botón + */
  html body.nsv2 .ds-top{gap:8px!important;padding:0 12px 0 60px!important;margin:0 -12px 12px!important;height:58px!important}
  html body.nsv2 .ds-kbd,html body.nsv2 .ds-top-sp{display:none!important}
  html body.nsv2 .ds-search{flex:1 1 auto!important;min-width:0!important}
  html body.nsv2 .ds-search input{height:40px!important;font-size:16px!important}
  html body.nsv2 .ds-search-res{position:fixed!important;left:12px!important;right:12px!important;top:62px!important;width:auto!important;max-height:70vh}
  html body.nsv2 .ds-new{font-size:0!important;width:40px!important;height:40px!important;min-width:40px!important;padding:0!important;justify-content:center!important;border-radius:12px!important}
  html body.nsv2 .ds-new svg{margin:0!important;width:20px!important;height:20px!important}
  html body.nsv2 .ds-icon-btn[title="Soporte"]{display:none!important}
  html body.nsv2 .ds-pop{position:fixed!important;left:12px!important;right:12px!important;top:62px!important;width:auto!important;max-width:none!important;max-height:75vh;overflow:auto}

  /* Las páginas de cada módulo no se ensanchan por una tabla larga: la tabla se desliza dentro de su tarjeta */
  html body .tab-content .nsb-page,html body .tab-content .report-simple-page,html body .tab-content .fe-wrap{grid-template-columns:minmax(0,1fr)!important;max-width:100%!important}
  html body .tab-content>*,html body .tab-content>*>*,html body .tab-content>*>*>*{min-width:0!important;max-width:100%}

  /* Encabezados de cada módulo: título arriba, botones abajo a lo ancho */
  html body.nsv2 .tab-content .cot-header,html body.nsv2 .tab-content .fe-header,html body.nsv2 .tab-content .report-simple-header,html body.nsv2 .tab-content .fin-cab,html body.nsv2 .tab-content .nsb-head-row,
  html body.nsv2 .tab-content .config-view-head,html body.nsv2 .tab-content .fe-docs-cab,html body.nsv2 .tab-content .pv-head,html body.nsv2 .tab-content .nv-cab,html body.nsv2 .tab-content .card-header{
    flex-direction:column!important;align-items:stretch!important;justify-content:flex-start!important;gap:12px!important;text-align:left!important}
  html body.nsv2 .tab-content .cot-header>*,html body.nsv2 .tab-content .fe-header>*,html body.nsv2 .tab-content .report-simple-header>*,html body.nsv2 .tab-content .fin-cab>*,html body.nsv2 .tab-content .nsb-head-row>*,
  html body.nsv2 .tab-content .config-view-head>*,html body.nsv2 .tab-content .fe-docs-cab>*,html body.nsv2 .tab-content .pv-head>*,html body.nsv2 .tab-content .nv-cab>*,html body.nsv2 .tab-content .card-header>*{
    min-width:0!important;max-width:100%!important;width:auto!important;margin-left:0!important;text-align:left!important}
  html body .tab-content h1,html body .tab-content h2{white-space:normal!important;word-break:normal;overflow-wrap:anywhere}
  html body .tab-content p{white-space:normal!important}
  html body.nsv2 .tab-content .cot-header-actions,html body.nsv2 .tab-content .pos-cab-der,html body.nsv2 .tab-content .pv-head-acc{display:flex!important;flex-wrap:wrap!important;gap:8px!important;justify-content:flex-start!important;width:100%!important}
  html body.nsv2 .tab-content .cot-header-actions>button,html body.nsv2 .tab-content .cot-header-actions>a{flex:1 1 auto!important}

  /* Rejillas: una columna */
  html body .tab-content .grid-2,html body .tab-content .grid-3,html body .tab-content .grid-4,
  html body .pos-venta,html body .pos-venta-3{grid-template-columns:minmax(0,1fr)!important}
  html body .pos-venta-3>*{grid-column:auto!important}
  html body .tab-content [class*="kpi"]{min-width:0}
  html body .tab-content [class*="kpi"] strong{font-size:clamp(18px,5.6vw,24px)!important;overflow-wrap:anywhere}
  html body .tab-content [class*="kpis"]{gap:8px!important}
  html body.nsv2 .ds-tiles{gap:10px!important}
  html body.nsv2 .ds-tile{padding:14px!important;min-width:0}
  html body.nsv2 .ds-tile strong{font-size:clamp(18px,5.6vw,24px)!important;overflow-wrap:anywhere}

  /* Pestañas y menús de cada módulo: se deslizan de lado en vez de cortarse */
  html body .tab-content .fe-tabs,html body .tab-content .nsf-tabs,html body .tab-content .cob-tabs,html body .tab-content .sub-tabs{
    flex-wrap:nowrap!important;overflow-x:auto!important;-webkit-overflow-scrolling:touch;scrollbar-width:none}
  html body .tab-content .fe-tabs>*,html body .tab-content .nsf-tabs>*,html body .tab-content .cob-tabs>*,html body .tab-content .sub-tabs>*{flex:0 0 auto!important;white-space:nowrap}

  /* Tablas: desplazamiento lateral suave dentro de su tarjeta */
  html body .tab-content .table-wrap,html body .tab-content .tabla-wrap,html body .tab-content .fe-tabla,html body .tab-content [class*="table-scroll"]{overflow-x:auto!important;-webkit-overflow-scrolling:touch}
  html body .tab-content table{font-size:13px}
  html body .tab-content th,html body .tab-content td{white-space:nowrap}

  /* Filtros en columna */
  html body .fe-filtros{flex-wrap:wrap!important}
  html body .fe-filtros select,html body .fe-filtros input{flex:1 1 100%!important;width:100%!important;min-width:0!important}

  /* Formularios cómodos para el dedo y sin zoom automático en iPhone */
  html body input:not([type=checkbox]):not([type=radio]),html body select,html body textarea{font-size:16px!important}
  html body .tab-content button,html body .fx button{min-height:40px}

  /* Ventanas de diálogo a pantalla completa */
  html body .fx-back{padding:0!important;align-items:flex-end!important}
  html body .fx{max-width:100vw!important;width:100vw!important;max-height:92dvh!important;border-radius:18px 18px 0 0!important;margin:0!important;display:flex;flex-direction:column}
  html body .fx{overflow:hidden!important}
  html body .fx-cuerpo{flex:1 1 auto!important;min-height:0!important;max-height:none!important;overflow-y:auto!important;-webkit-overflow-scrolling:touch;padding-bottom:calc(12px + env(safe-area-inset-bottom))!important}
  html body .fx-cuerpo .grid-2,html body .fx-cuerpo .grid-3,html body .fx-cuerpo .grid-4,html body .fx-cuerpo [style*="grid-template-columns"]{grid-template-columns:minmax(0,1fr)!important}
  html body .fx-pie{position:sticky;bottom:0;z-index:2;background:#fff!important;display:flex;gap:8px;padding-top:10px!important;padding-bottom:10px!important;box-shadow:0 -8px 14px -10px rgba(15,23,42,.25)}
  html body .fx-pie button{flex:1 1 0}
  html body .ns-modal,html body .ns-user-modal{width:100vw!important;max-width:100vw!important;max-height:92dvh!important;border-radius:18px 18px 0 0!important;overflow:auto}
  html body .ns-user-modal-backdrop{align-items:flex-end!important;padding:0!important}
}

@media (max-width:400px){
  html body.nsv2 .ds-top{padding-left:56px!important}
  html body .tab-content h1{font-size:22px!important}
  html body .tab-content h2{font-size:20px!important}
}
