From cfa8efbc0ad7b088cb6254f2446d7a8366338ec5 Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 4 Oct 2026 20:05:33 -0600 Subject: [PATCH] fix(pos): responsive layout for mobile cashier terminal with tab navigation, floating checkout bar, and preventing pane overlap --- public/css/styles.css | 196 ++++++++++++++++++++++++++++++++++++++++++ public/js/pos.js | 88 +++++++++++++++++-- public/pos.html | 78 ++++++++++++----- 3 files changed, 333 insertions(+), 29 deletions(-) diff --git a/public/css/styles.css b/public/css/styles.css index 5d87827..4ca109f 100644 --- a/public/css/styles.css +++ b/public/css/styles.css @@ -534,6 +534,8 @@ body.dark-mode .floating-cart-bar { display: flex; flex-direction: column; gap: 16px; + min-width: 0; + box-sizing: border-box; } .pos-tabs { @@ -580,6 +582,7 @@ body.dark-mode .floating-cart-bar { justify-content: space-between; min-height: 140px; transition: all 0.15s; + box-sizing: border-box; } .pos-prod-card:hover { @@ -594,6 +597,10 @@ body.dark-mode .floating-cart-bar { flex-direction: column; justify-content: space-between; padding: 20px; + min-width: 0; + box-sizing: border-box; + overflow-y: auto; + overflow-x: hidden; } .scanner-feed-card { @@ -604,6 +611,9 @@ body.dark-mode .floating-cart-bar { text-align: center; position: relative; overflow: hidden; + box-sizing: border-box; + width: 100%; + max-width: 100%; } .camera-preview { @@ -639,6 +649,8 @@ body.dark-mode .floating-cart-bar { display: flex; flex-direction: column; gap: 8px; + box-sizing: border-box; + width: 100%; } .pos-cart-item { @@ -649,6 +661,190 @@ body.dark-mode .floating-cart-bar { padding: 10px 14px; border-radius: 10px; border: 1px solid #334155; + gap: 10px; + box-sizing: border-box; + width: 100%; +} + +/* Elementos móviles ocultos por defecto en pantallas grandes */ +.pos-mobile-nav { + display: none; +} + +.pos-mobile-back-bar { + display: none; +} + +.pos-floating-checkout-bar { + display: none; +} + +/* ========================================================================== + ADAPTACIÓN RESPONSIVE POS PARA MÓVILES Y PANTALLAS ANGOSTAS (<= 900px) + ========================================================================== */ +@media (max-width: 900px) { + html, body { + overflow-x: hidden !important; + width: 100% !important; + position: relative; + } + + .pos-layout { + display: flex; + flex-direction: column; + height: auto; + min-height: 100vh; + overflow-x: hidden; + width: 100%; + box-sizing: border-box; + } + + /* BARRA DE PESTAÑAS MÓVIL EN LA CABECERA */ + .pos-mobile-nav { + display: flex; + background: #0b1120; + border-bottom: 2px solid #334155; + position: sticky; + top: 0; + z-index: 100; + padding: 8px 10px; + gap: 8px; + box-shadow: 0 4px 12px rgba(0, 0, 0, 0.45); + box-sizing: border-box; + width: 100%; + } + + .pos-mobile-nav-btn { + flex: 1; + display: flex; + align-items: center; + justify-content: center; + gap: 6px; + padding: 10px 12px; + background: #1e293b; + border: 1.5px solid #334155; + border-radius: 12px; + color: #94a3b8; + font-size: 0.88rem; + font-weight: 800; + cursor: pointer; + transition: all 0.15s ease; + } + + .pos-mobile-nav-btn.active { + background: #0284c7; + color: #ffffff; + border-color: #38bdf8; + box-shadow: 0 2px 8px rgba(2, 132, 199, 0.4); + } + + .pos-mobile-nav-badge { + background: #ef4444; + color: white; + font-size: 0.72rem; + font-weight: 900; + padding: 2px 7px; + border-radius: 10px; + line-height: 1; + } + + /* CONTROL DE VISIBILIDAD ENTRE CATÁLOGO Y CAJA EN MÓVIL */ + body.pos-mobile-view-catalog .pos-catalog-pane { + display: flex !important; + width: 100% !important; + max-width: 100% !important; + padding: 14px; + padding-bottom: 95px; /* Espacio para barra flotante */ + box-sizing: border-box; + } + + body.pos-mobile-view-catalog .pos-checkout-pane { + display: none !important; + } + + body.pos-mobile-view-checkout .pos-catalog-pane { + display: none !important; + } + + body.pos-mobile-view-checkout .pos-checkout-pane { + display: flex !important; + width: 100% !important; + max-width: 100% !important; + border-left: none; + border-top: none; + padding: 14px; + box-sizing: border-box; + min-height: calc(100vh - 65px); + } + + /* BOTÓN REGRESAR AL CATÁLOGO */ + .pos-mobile-back-bar { + display: block; + margin-bottom: 12px; + width: 100%; + } + + .pos-mobile-back-btn { + width: 100%; + padding: 11px 14px; + background: #0f172a; + color: #38bdf8; + border: 1.5px solid #334155; + border-radius: 12px; + font-size: 0.88rem; + font-weight: 800; + cursor: pointer; + display: flex; + align-items: center; + justify-content: center; + gap: 8px; + box-sizing: border-box; + } + + .pos-mobile-back-btn:active { + background: #1e293b; + } + + /* BARRA FLOTANTE INFERIOR DE ACCESO RÁPIDO */ + .pos-floating-checkout-bar { + position: fixed; + bottom: 14px; + left: 12px; + right: 12px; + background: #0f172a; + border: 2px solid #0284c7; + border-radius: 16px; + padding: 10px 16px; + display: flex; + justify-content: space-between; + align-items: center; + box-shadow: 0 10px 25px rgba(0, 0, 0, 0.75), 0 0 18px rgba(2, 132, 199, 0.45); + z-index: 99; + cursor: pointer; + box-sizing: border-box; + animation: popUpFloat 0.25s cubic-bezier(0.16, 1, 0.3, 1); + } + + @keyframes popUpFloat { + from { transform: translateY(50px); opacity: 0; } + to { transform: translateY(0); opacity: 1; } + } + + /* AJUSTE DE CUADRÍCULA DE PRODUCTOS EN PANTALLAS PEQUEÑAS */ + .pos-products-grid { + grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)) !important; + gap: 10px !important; + } + + .pos-prod-card { + padding: 12px !important; + min-height: 115px !important; + } + + .pos-cart-item { + padding: 8px 10px !important; + gap: 8px !important; + } } /* ========================================================================== diff --git a/public/js/pos.js b/public/js/pos.js index 8bc3d16..ce14aea 100644 --- a/public/js/pos.js +++ b/public/js/pos.js @@ -8,8 +8,42 @@ let currentTab = 'mostrador'; let sseSource = null; let videoStream = null; let isScanningActive = true; +let posMobileActiveView = 'catalog'; let CLOUDFLARE_TUNNEL_URL = 'https://somewhat-ships-looksmart-optical.trycloudflare.com'; +function switchPosMobileView(view) { + posMobileActiveView = view; + const body = document.body; + const tabCat = document.getElementById('btnMobileNavCatalog'); + const tabCheck = document.getElementById('btnMobileNavCheckout'); + const floatBar = document.getElementById('posFloatingCheckoutBar'); + + if (view === 'checkout') { + body.classList.remove('pos-mobile-view-catalog'); + body.classList.add('pos-mobile-view-checkout'); + if (tabCat) tabCat.classList.remove('active'); + if (tabCheck) tabCheck.classList.add('active'); + if (floatBar) floatBar.style.display = 'none'; + window.scrollTo({ top: 0, behavior: 'smooth' }); + } else { + body.classList.remove('pos-mobile-view-checkout'); + body.classList.add('pos-mobile-view-catalog'); + if (tabCat) tabCat.classList.add('active'); + if (tabCheck) tabCheck.classList.remove('active'); + updatePosCartUI(); + window.scrollTo({ top: 0, behavior: 'smooth' }); + } +} + +window.addEventListener('resize', () => { + if (window.innerWidth > 900) { + const floatBar = document.getElementById('posFloatingCheckoutBar'); + if (floatBar) floatBar.style.display = 'none'; + } else { + updatePosCartUI(); + } +}); + function checkPosHttpsEnvironment() { const isHttp = window.location.protocol !== 'https:' && window.location.hostname !== 'localhost' && @@ -121,10 +155,27 @@ function addToPosCart(prodId) { function updatePosCartUI() { const list = document.getElementById('posCartList'); const totalEl = document.getElementById('posCartTotal'); + const totalItems = posCart.reduce((sum, item) => sum + item.cantidad, 0); + + // Actualizar badge móvil + const mobileBadge = document.getElementById('mobileCartBadge'); + if (mobileBadge) { + if (totalItems > 0) { + mobileBadge.textContent = totalItems; + mobileBadge.style.display = 'inline-block'; + } else { + mobileBadge.style.display = 'none'; + } + } + + const floatBar = document.getElementById('posFloatingCheckoutBar'); + const floatText = document.getElementById('posFloatingCartText'); + const floatTotal = document.getElementById('posFloatingCartTotal'); if (posCart.length === 0) { list.innerHTML = '

Toca productos del menú para cobrar

'; totalEl.textContent = '₡0'; + if (floatBar) floatBar.style.display = 'none'; return; } @@ -134,21 +185,32 @@ function updatePosCartUI() { total += subtotal; return `
-
- ${item.product.icono} ${item.product.nombre} -
₡${item.product.precio_colones.toLocaleString('es-CR')} c/u
+
+ ${item.product.icono} ${item.product.nombre} +
₡${item.product.precio_colones.toLocaleString('es-CR')} c/u
-
- - ${item.cantidad} - - ₡${subtotal.toLocaleString('es-CR')} +
+ + ${item.cantidad} + + ₡${subtotal.toLocaleString('es-CR')}
`; }).join(''); totalEl.textContent = `₡${total.toLocaleString('es-CR')}`; + + // Controlar barra flotante en móvil + if (floatBar && window.innerWidth <= 900) { + if (totalItems > 0 && posMobileActiveView === 'catalog') { + floatBar.style.display = 'flex'; + if (floatText) floatText.textContent = `${totalItems} ${totalItems === 1 ? 'ítem' : 'ítems'} en mostrador`; + if (floatTotal) floatTotal.textContent = `₡${total.toLocaleString('es-CR')}`; + } else { + floatBar.style.display = 'none'; + } + } } function changePosQty(idx, delta) { @@ -469,6 +531,11 @@ function renderScannedStudent() { } else { alertBox.style.display = 'none'; } + + // En pantallas móviles, mostrar la vista de caja automáticamente + if (window.innerWidth <= 900) { + switchPosMobileView('checkout'); + } } function clearScannedStudent() { @@ -527,6 +594,11 @@ async function executePosDebit() { // Limpiar caja y refrescar clearPosCart(); clearScannedStudent(); + + // En móviles, volver a la vista del catálogo para la siguiente venta + if (window.innerWidth <= 900) { + switchPosMobileView('catalog'); + } } catch (err) { alert(`❌ Fallo en la transacción: ${err.message}`); } finally { diff --git a/public/pos.html b/public/pos.html index 9213c64..b8bd75d 100644 --- a/public/pos.html +++ b/public/pos.html @@ -29,7 +29,7 @@ .status-listo { background: #dcfce7; color: #166534; } .status-entregado { background: #f1f5f9; color: #64748b; } - + + +
+ + +
+
-
+
🥪
-

RecreoPay Terminal Soda

+

RecreoPay Terminal Soda

Soda Escolar • Ventana de Atención Rápida
-
- +
@@ -99,11 +113,33 @@
+ + +
+ +
+ +
+
@@ -148,16 +184,16 @@