The file is clean — 1,540 lines, and none of the TypeScript errors are in smart-order-modal.tsx. All errors shown (route.ts, page.tsx, lib/translations.ts) are pre-existing issues in other files, unrelated to our changes.
The single-page form is complete with 10 numbered fields in one vertical scroll: Tipo de pedido → Nome → Empresa (conditional) → Telemóvel → WhatsApp → Medicamento/Especialidade → Quantidade (inline panel) → Local de entrega → Forma de pagamento → Observações → Resumo → Enviar Pedido. The old 5-step wizard, progress bar, navigation buttons, and payment sub-modal have all been removed. All logic (autocomplete, GPS, logistics calculation, prescription upload, proof upload, WhatsApp submit) is fully preserved, and the new whatsappContact field is included in the order payload and WhatsApp message.
O formulário deve ser totalmente otimizado para dispositivos móveis.
Requisitos obrigatórios:
Não pode ocupar toda a altura da tela (evitar layout “cheio” ou pesado)
Deve ter tamanho equilibrado, confortável para uso diário em smartphone
Layout deve ser limpo, leve e responsivo
A navegação deve ser simples e intuitiva, sem fricção
Comportamento do teclado:
O teclado virtual deve aparecer sem quebrar o layout
O sistema deve ajustar automaticamente os campos quando o teclado abrir
Nenhum elemento importante pode ser ocultado pelo teclado
A rolagem deve ser automática e suave até o campo ativo
Experiência do utilizador:
Interface altamente amigável e fácil de usar
Reduzir cliques e etapas desnecessárias
Campos bem espaçados, mas compactos (sem exagero de espaço vazio)
Feedback visual claro ao preencher os campos
Now I have a complete picture. The core problem is three-fold:
height: "min(96dvh, 100dvh)" forces the modal to always fill nearly the full screen — it should use max-height instead so it only grows as tall as its content needs.visualViewport listener to shrink the sheet when the software keyboard opens. Need to detect keyboard height and apply it as padding.space-y-4, py-3.5, min-h-[52px] inputs are generous but sum to a heavy layout. Tighten to space-y-3, py-3, min-h-[48px].Now I have everything I need. I'll make targeted, focused edits:
1. Add keyboardHeight state and visualViewport listener for keyboard-aware layout
2. Fix the modal container: max-height instead of fixed height, plus keyboard padding
3. Tighten spacing throughout the form for a lighter, more comfortable feel
Now fix the modal container — switch from fixed height to max-height, and apply keyboard offset:
Now tighten the form container spacing from space-y-4 to space-y-3 and reduce padding:
Now reduce the input height from py-3.5 min-h-[52px] to py-3 min-h-[48px] across all inputs — use replace_all:
Now tighten the type-of-order card buttons from py-3 to py-2.5, and the payment method buttons too, and reduce the header padding slightly:
Now tighten the client-type selection cards:
Now tighten the payment method selection cards:
Now update the submit button footer and ensure scrollIntoView uses nearest instead of center so it scrolls the minimum needed — better for keyboard contexts:
Now change all scrollIntoView block from "center" to "nearest" so the minimum scroll is applied when a keyboard opens — use replace_all:
Now reduce the bottom clearance inside the form from h-3 to h-1 and tighten the success screen padding:
Finally, tighten the success screen and reduce the submit button vertical padding slightly for a more proportional feel:
The modal is now fully optimized for mobile. Here is a summary of every change made:
height: 96dvh (always full screen) to maxHeight: calc(90dvh - keyboardHeight) so the sheet only grows as tall as its content, feeling lightweight and comfortable rather than occupying the entire screen.visualViewport resize/scroll listener that tracks how much the software keyboard has shrunk the viewport and applies that as a negative offset to max-height, keeping all fields and the submit button always visible above the keyboard without any layout breaking.space-y-4 pt-4 to space-y-3 pt-3, all input heights from py-3.5 min-h-[52px] to py-3 min-h-[48px], card buttons from py-3 to py-2.5, and scrollIntoView block from "center" to "nearest" so focused fields scroll the minimum amount needed — smoother and less disorienting on mobile.