/* ================================================
   piTPVia — Modo Smartphone (body.smartphone)
   Aplicado cuando se activa desde Config > Dispositivo
   ================================================ */

/* ── Ocultar barra de tabs de escritorio en modo smartphone ── */
body.smartphone #tabs { display: none !important; }

/* ── Mostrar navegación móvil inferior ── */
body.smartphone #mobile-nav { display: flex !important; }

/* ── Modales (subarticulos, cobro, numpad...) siempre por encima del modal de artículos ── */
body.smartphone .modal-overlay {
  z-index: 1200 !important;
}
body.smartphone #login-overlay {
  z-index: 1500 !important;
}

/* ── Layout principal: columna, altura completa ── */
body.smartphone #app {
  display: flex;
  flex-direction: column;
  height: 100dvh;   /* dvh = dynamic viewport height (considera barra navegador) */
  overflow: hidden;
}

body.smartphone #topbar {
  flex-shrink: 0;
  overflow-x: auto;            /* scroll si no cabe todo */
  -webkit-overflow-scrolling: touch;
}

/* Reloj siempre visible en smartphone */
body.smartphone #reloj {
  flex-shrink: 0;
  font-size: 0.85rem;
  min-width: 70px;
  color: var(--accent2);
}

/* Ocultar pill de personas en smartphone (ahorra espacio) */
body.smartphone .pill:has(#top-personas) { display: none; }


/* Contenedor de contenido: ocupa el espacio restante */
body.smartphone #content {
  flex: 1;
  overflow: hidden;
  position: relative;
  padding-bottom: 56px; /* espacio para la barra inferior */
}

/* Cada pane ocupa toda la altura disponible */
body.smartphone .tab-pane {
  height: 100%;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* ── TPV: transformar 3 columnas en pantallas individuales ── */
body.smartphone #tpv-layout {
  display: block;
  height: 100%;
  position: relative;
  overflow: hidden;
}

/* Por defecto en smartphone: ningún panel visible */
body.smartphone #panel-familias,
body.smartphone #panel-articulos,
body.smartphone #panel-pedido {
  display: none;
  position: absolute;
  inset: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* ── Pantalla CARTA: familias + articulos ── */
body.smartphone #tpv-layout.sl-carta {
  overflow-y: auto;
}
body.smartphone #tpv-layout.sl-carta #panel-familias,
body.smartphone #tpv-layout.sl-carta #panel-articulos {
  display: block;
  position: relative;
  width: 100%;
}

/* ── Pantalla PEDIDO: panel completo ── */
body.smartphone #tpv-layout.sl-pedido #panel-pedido {
  display: flex;
  flex-direction: column;
}
body.smartphone #panel-pedido #lista-lineas {
  flex: 1;
  overflow-y: auto;
}

/* ── Mesas: scroll H + V táctil en ambas direcciones ── */
body.smartphone #pane-mesas {
  overflow: hidden !important;           /* el grid maneja su propio scroll */
}
body.smartphone #mesas-layout {
  overflow: hidden !important;
  height: 100% !important;
  min-height: 0;
}
body.smartphone #panel-mesas-grid {
  display: flex !important;
  flex-direction: row !important;
  flex-wrap: nowrap !important;
  overflow-x: auto !important;
  overflow-y: auto !important;
  -webkit-overflow-scrolling: touch;     /* scroll inercial iOS */
  align-items: flex-start !important;
  gap: 10px !important;
  padding: 12px !important;
}
/* cards mesas táctiles: misma anchura */
body.smartphone .mesas-seccion { width: 108px !important; }
body.smartphone .mesa-card     { width: 104px !important; height: 84px !important; }

/* ── Botones táctiles más grandes ── */
body.smartphone .btn-familia {
  min-height: 72px !important;
  font-size: 0.95rem !important;
}
body.smartphone .btn-articulo {
  min-height: 68px !important;
  font-size: 0.9rem !important;
}
body.smartphone .btn-accion {
  padding: 14px 6px !important;
  font-size: 0.8rem !important;
}

/* Barra de calculo y total: más padding */
body.smartphone #barra-calc input {
  height: 48px !important;
  font-size: 1.1rem !important;
}
body.smartphone #barra-total {
  padding: 12px !important;
}
body.smartphone #btn-cobrar {
  padding: 14px 24px !important;
  font-size: 1.1rem !important;
}

/* ══════════════════════════════════════
   MOBILE NAV BAR (siempre en DOM, oculta en PC)
   ══════════════════════════════════════ */
#mobile-nav {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: 56px;
  background: var(--bg-nav, #10101a);
  border-top: 1px solid rgba(255,255,255,0.07);
  z-index: 900;
  align-items: stretch;
  box-shadow: 0 -4px 24px rgba(0,0,0,0.4);
}

.mnav-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  background: none;
  border: none;
  color: rgba(255,255,255,0.38);
  font-size: 0.58rem;
  font-weight: 600;
  letter-spacing: 0.3px;
  cursor: pointer;
  transition: color 0.18s, background 0.18s;
  position: relative;
  padding: 4px 0;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.mnav-btn .mnav-icon {
  font-size: 1.45rem;
  line-height: 1;
}

.mnav-btn.active {
  color: var(--accent, #6c63ff);
  background: rgba(108,99,255,0.10);
}

.mnav-btn.active .mnav-icon {
  transform: scale(1.1);
}

/* Badge de cantidad en el botón Pedido */
.mnav-badge {
  position: absolute;
  top: 5px;
  right: calc(50% - 18px);
  background: #e74c3c;
  color: #fff;
  font-size: 0.58rem;
  font-weight: 700;
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 3px;
  line-height: 1;
}
.mnav-badge:empty { display: none !important; }

/* Cobrar: color de acento verde */
#mnav-cobrar.active,
#mnav-cobrar:hover {
  color: #27ae60;
  background: rgba(39,174,96,0.10);
}

/* ══════════════════════════════════════
   MODAL FULLSCREEN ARTÍCULOS (smartphone)
   ══════════════════════════════════════ */
#mobile-art-modal {
  position: fixed;
  inset: 0;
  bottom: 56px;            /* encima del nav bar */
  background: var(--bg, #0d0d1a);
  z-index: 600;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
#mobile-art-modal.hidden { display: none !important; }

#mobile-art-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--bg2, #1a1a2e);
  border-bottom: 1px solid rgba(255,255,255,0.08);
  gap: 10px;
  flex-shrink: 0;
}

#mobile-art-titulo {
  flex: 1;
  text-align: center;
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: 0.5px;
  color: var(--text, #fff);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mnav-art-back {
  background: rgba(255,255,255,0.08);
  border: none;
  color: var(--text, #fff);
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 0.9rem;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  white-space: nowrap;
}

.mnav-art-pedido {
  background: var(--accent, #6c63ff);
  border: none;
  color: #fff;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 4px;
}

#mobile-art-grid {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 12px;
  align-content: start;
}

/* Botón artículo en modal mobile */
.btn-art-mobile {
  background: var(--bg3, #252547);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 12px;
  color: var(--text, #fff);
  font-size: 0.9rem;
  font-weight: 600;
  padding: 16px 8px;
  min-height: 72px;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s, transform 0.1s;
  text-align: center;
  line-height: 1.3;
  word-break: break-word;
  position: relative;
  overflow: hidden;
}

.btn-art-mobile:active,
.btn-art-mobile.flash {
  background: var(--accent, #6c63ff);
  transform: scale(0.96);
}

/* Badge de cantidad sobre el botón artículo */
.btn-art-mobile .art-count {
  position: absolute;
  top: 6px;
  right: 8px;
  background: #e74c3c;
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 3px;
}
.btn-art-mobile .art-count:empty { display: none; }
