/* Ajustes do Portal de Vendas para celular.
   Este arquivo só é carregado com media="screen and (max-width: 700px)",
   então a versão de computador e a impressão não mudam.
   Os filtros recolhíveis são controlados por assets/portal-mobile.js. */

/* ---------- Base: letras legíveis e campos sem zoom no iPhone ---------- */
html body { font-size: 14px; }
html input, html select, html textarea { font-size: 16px !important; }
html button { font-size: 14px; }
html small { font-size: 12px; }
html table { font-size: 13px; }
html table th, html table td { font-size: 13px !important; }
html .field label, html .modal-product-filter label { font-size: 13px; }

/* ---------- Filtros recolhíveis (genérico) ---------- */
.mf-host:not(.mf-open) .mf-extra { display: none !important; }
html .mf-toggle {
  display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  height: auto; min-height: 38px; padding: 6px 8px; width: 100%;
  background: #fff; color: #263746; border: 1px solid #9aa9b8; border-radius: 6px;
  font-size: 14px; font-weight: bold; line-height: 1.15; white-space: nowrap;
}
.mf-toggle .mf-count {
  display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 5px;
  border-radius: 10px; background: #237f35; color: #fff; font-size: 12px;
}
.mf-toggle .mf-count[hidden] { display: none; }
.mf-host.mf-open .mf-toggle { background: #edf4ff; border-color: #2674c5; }

/* ======================= Portal (index.html) ======================= */

/* Painel: cartões crescem com o texto (antes o texto vazava para o cartão de baixo). */
html .dashboard { gap: 7px; }
html .dashboard button { height: auto; min-height: 84px; padding: 9px 30px 9px 10px; font-size: 14px; }
html .dashboard strong { font-size: 17px; }
html .dashboard small { font-size: 12px; }
html .dashboard button.orders-notification::before { top: auto; bottom: 6px; right: 30px; }

/* Painel: período em uma linha + botão "Filtros"; o resto abre sob demanda. */
html #dashboardTools {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; margin-bottom: 9px;
}
html #dashboardTools > button {
  width: 100%; height: auto; min-height: 38px; padding: 6px 4px;
  font-size: 13px; line-height: 1.15; white-space: normal; text-align: center;
}
html #dashboardTools > .mf-toggle { padding: 6px 4px; }
html #dashboardTools .dashboard-multi,
html #dashboardTools .dashboard-multi:first-of-type { grid-column: span 2; width: auto; min-width: 0; max-width: none; margin: 0; }
html #dashboardTools #dashboardActivity { grid-column: span 2; width: 100%; min-height: 38px; padding: 6px 24px 6px 8px; font-size: 16px; }
html #dashboardTools [data-dashboard-clear] { grid-column: 1 / -1; order: 10; color: #9c1e1e; border-color: #c98989; background: #fff; }
html #dashboardTools .dashboard-multi-picker { width: 100%; min-height: 38px; padding: 6px 8px; font-size: 14px; }
/* Lista de opções aberta ocupa a linha inteira em vez de sair da tela. */
html #dashboardTools .dashboard-multi:has(.dashboard-multi-panel:not(.hidden)) { grid-column: 1 / -1; }
html .dashboard-multi-panel { position: relative; top: auto; width: 100%; min-width: 0; max-width: 100%; margin-top: 4px; box-shadow: none; }
html .dashboard-multi-option { white-space: normal; font-size: 14px; }

/* Painel: comparativos */
html .insight { min-height: 0; }
html .insight h3 { font-size: 15px; }
html .chart-value, html .chart-label { font-size: 12px; }
html .ranking-list button, html .ranking-row { height: auto; font-size: 14px; }
html .ranking-name { white-space: normal; overflow-wrap: anywhere; }
html .action-list button { font-size: 14px; }

/* Cabeçalhos das telas */
html .home-heading, html .workspace-heading { margin: 0 0 9px; }
html .home-heading h2, html .workspace-heading h2 { font-size: 17px; }
html .workspace-heading { flex-wrap: wrap; }
html .workspace-heading > div { flex: 1 1 0; min-width: 0; }

/* Carteira: busca de cliente + botões numa linha; rota/datas recolhidas. */
html #workspace .filters {
  display: grid; grid-template-columns: repeat(10, minmax(0, 1fr)); gap: 6px; padding: 8px;
}
html #workspace .filters > * { grid-column: 1 / -1; }
html #workspace .filters > .client-field { order: 1; }
html #workspace .filters > button { order: 2; grid-column: span 2; width: 100%; height: 40px; min-width: 0; }
html #workspace .filters > .mf-toggle { order: 2; grid-column: span 2; padding: 4px 2px; font-size: 13px; }
html #workspace .filters > .mf-extra { order: 3; }
html #workspace .filters > .mf-date { grid-column: span 5; }
html #workspace .filters .field-check { height: auto; min-height: 30px; font-size: 14px; }
html #workspace .filters .route-picker { height: 40px; font-size: 14px; }
html .client-field input { height: 40px; }
html .route-option { white-space: normal; font-size: 14px; }

/* Carteira: cartões de cliente */
html .mobile-client { font-size: 14px; min-height: 0; padding: 10px; }
html .mobile-client small { color: #5d6d7d; font-size: 13px; }
html .mobile-month { font-size: 14px; }
html .footer { font-size: 13px; flex-direction: row; align-items: center; flex-wrap: wrap; }

/* Relatório de comissões: datas lado a lado, ações na mesma linha. */
html #commissionFilters { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 6px; align-items: end; }
html #commissionFilters > * { grid-column: span 6; min-width: 0; }
html #commissionFilters > .field:has(#commissionSeller) { order: 1; }
html #commissionFilters > #commissionCurrentMonth { order: 2; grid-column: span 3; padding: 4px; line-height: 1.1; }
html #commissionFilters > #commissionSearch { order: 3; grid-column: span 3; padding: 4px; }
html #commissionFilters input, html #commissionFilters select { width: 100%; height: 40px; }
html #commissionFilters button { width: 100%; height: 40px; }
html #commissionView .workspace-heading > button { flex: 0 0 auto; height: 36px; }

/* Janelas (cliente, produtos, período, evolução, pesquisa avançada) */
html .modal-head h2 { font-size: 16px; }
html .modal-head small { font-size: 12px; }
html .modal-head > div:last-child { flex-wrap: wrap; }
html .modal-head > div:last-child > button { flex: 1 1 40%; height: auto; min-height: 38px; padding: 6px; line-height: 1.15; }
html .modal-head:has(> button) { flex-direction: row; align-items: center; }
html .modal-head > button { flex: 0 0 auto; height: auto; min-height: 36px; padding: 6px 12px; }
html .period-tools { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
html .period-tools button { height: 38px; }
html .period-tools label { min-width: 0; font-size: 13px; }
html .period-tools label.hidden { display: none; }
html .period-tools select { width: 100%; }
html .advanced-filter-fields { grid-template-columns: 1fr 1fr; gap: 6px; padding: 10px; }
html .advanced-filter-fields .field { min-width: 0; }
html .advanced-filter-fields select { width: 100%; }
html .advanced-filter-actions { padding: 0 10px 10px; }
html .advanced-filter-actions button { width: 100%; height: 40px; }
html .evolution-chart { padding: 8px; }
html .modal-content table td:nth-child(2) { white-space: normal; min-width: 150px; max-width: 190px; }
html .modal-content table { min-width: 0; }

/* Login */
html .login input { height: 42px; }
html .login button { min-height: 40px; }
html .keypad button { min-width: 38px; height: 38px; font-size: 16px; }

/* ===================== Catálogo / Pedidos / Clientes ===================== */

/* Menu lateral recolhido como no Portal: libera ~60px de largura. */
html body > aside.side-menu { width: 0; padding: 0; background: transparent; }
html body > aside.side-menu.menu-expanded { width: 230px; padding: 7px 4px; background: var(--dark); }
html body > aside.side-menu .menu-toggle {
  position: fixed; left: 4px; top: 4px; z-index: 31; width: 40px; height: 36px;
}
html body > aside.side-menu.menu-expanded .menu-toggle { position: static; }
html body > aside.side-menu ~ main.wrap { margin: 0; padding: 44px 6px 8px; }
html body > aside.side-menu ~ main.wrap .card { padding: 10px; }

html .panel-heading h2, html .orders-head h2 { font-size: 17px; }

/* Produtos do catálogo: os campos de cada produto passavam da tela
   e o celular reduzia a página inteira. */
html .catalog-product { display: grid; grid-template-columns: 44px minmax(0, 1fr) 40px; gap: 8px; align-items: start; }
html .catalog-product .product-text { min-width: 0; font-size: 14px; }
html .catalog-product > .product-meta {
  grid-column: 1 / -1; width: auto; margin: 0;
  display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 6px;
}
html .catalog-product > .product-meta > label { min-width: 0; font-size: 12px; grid-column: span 3; }
html .catalog-product > .product-meta > label:nth-child(-n+3) { grid-column: span 4; }
html .product-meta .category-value { display: block; min-width: 0; overflow-wrap: anywhere; font-size: 13px; }
html .product-meta input { width: 100%; min-width: 0; height: 38px; padding: 5px; }
html .product-meta input[type="checkbox"] { width: 24px; height: 24px; margin: 7px 0; }
html .catalog-product > .photo-button { grid-column: 3; grid-row: 1; }

/* Filtros de produto recolhidos atrás de "Filtros". */
html #productsCard .catalog-filters { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
html #productsCard .catalog-filters > * { min-width: 0; width: 100%; }
html #productsCard .catalog-filters > .mf-toggle { grid-column: 1 / -1; }
html #productsCard .catalog-filters select { min-width: 0; width: 100%; height: 40px; padding: 6px; }
html #productsCard .product-type-picker { grid-column: 1 / -1; min-width: 0; }
html #productsCard .product-type-picker > button { min-width: 0; height: 40px; }
html #productsCard .product-type-options { position: relative; top: auto; min-width: 0; width: 100%; margin-top: 4px; box-shadow: none; }
html #productSearch { height: 40px; }
html #productsCard > .row { gap: 8px; }

/* Pedidos recebidos: a faixa de situação passava de 800px de largura. */
html .orders-head-top { display: block; }
html .order-filter-bar { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 10px; }
html .order-filter-bar .order-search-field { grid-column: 1 / -1; min-width: 0; font-size: 13px; }
html .order-filter-bar .order-search-field input { height: 40px; }
html .order-filter-bar button { height: 40px; padding: 6px; }
html .order-status-group { grid-template-columns: minmax(0, 1fr); min-width: 0; margin-top: 8px; }
html .order-status-actions { display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; min-width: 0; }
html .order-status-buttons { width: 100%; max-width: 100%; min-width: 0; overflow-x: auto; flex-wrap: nowrap; -webkit-overflow-scrolling: touch; }
html .order-status-button { flex: 0 0 auto; font-size: 13px; padding: 7px 9px; }
html #orders .order > .row { flex-wrap: wrap; }
html #orders .order > .row > [data-view-order] { flex: 1 1 100%; white-space: normal; font-size: 13px; font-weight: normal; line-height: 1.35; }
html #orders .order > .row > .row { flex-wrap: wrap; font-size: 13px; margin-left: auto; }
/* Dicas dos botões de ação: escondidas não ocupam espaço; quando abertas,
   alinham pela direita para não passar da borda da tela. */
html .order-action:not(:hover):not(:focus-visible):not(.tooltip-open)::after { display: none; }
html .order-action::after { left: auto; right: 0; transform: none; max-width: min(230px, 80vw); }

/* Clientes: busca em cima, vendedor e rede lado a lado. */
html #customersCard > .panel-heading + .row { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin: 10px 0 !important; }
html #directorySearch { grid-column: 1 / -1; min-width: 0 !important; width: 100%; height: 40px; }
html #customersCard > .panel-heading + .row > select { min-width: 0; width: 100%; height: 40px; }
html #customersCard > .panel-heading + .row > select.hidden { display: none; }
html #customersCard > .panel-heading + .row > :not(input):not(select) { grid-column: 1 / -1; }

/* Clientes: a tabela de 8 colunas vira cartões (nenhuma coluna é perdida). */
html .directory-scroll { overflow: visible; max-height: none; border: 0; }
html .directory-table { display: block; min-width: 0; }
html .directory-table thead { display: none; }
html .directory-table tbody { display: grid; gap: 7px; }
html .directory-table tr {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 3px 8px; align-items: start;
  padding: 9px; border: 1px solid var(--line); border-radius: 7px; background: #fff !important;
}
html .directory-table td { display: block; padding: 0; border: 0; min-width: 0; overflow-wrap: anywhere; font-size: 13px !important; color: #33475a; }
html .directory-table td:nth-child(1) { grid-column: 1; grid-row: 1 / span 2; white-space: nowrap; font-weight: bold; color: #182b3b; }
html .directory-table td:nth-child(1) input { width: 20px; height: 20px; vertical-align: -4px; }
html .directory-table td:nth-child(2) { grid-column: 2; grid-row: 1; font-size: 14px !important; font-weight: bold; color: #182b3b; }
html .directory-table td:last-child { grid-column: 3; grid-row: 1; }
html .directory-table td:not(:nth-child(1)):not(:nth-child(2)):not(:last-child) { grid-column: 2 / -1; }
html .directory-table td:nth-child(3)::before { content: "CPF/CNPJ: "; color: #607384; }
html .directory-table tr:has(> td:nth-child(8)) > td:nth-child(5)::before { content: "Vendedor: "; color: #607384; }
html .directory-table tr:has(> td:nth-child(8)) > td:nth-child(6)::before { content: "Rede: "; color: #607384; }
html .directory-table td:nth-last-child(2)::before { content: "Empresa: "; color: #607384; }
html .directory-table td small { display: inline; margin-left: 4px; font-size: 12px; }
html .directory-table td:nth-child(2) small { display: block; margin: 2px 0 0; font-weight: normal; }
html .directory-table button { font-size: 13px; padding: 6px 9px; }
html .directory-table .directory-customer-name { font-size: 14px; text-align: left; white-space: normal; overflow-wrap: anywhere; }

/* Clientes: ações em lote recolhidas, abrem quando necessárias. */
html #directoryBulk { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 6px; align-items: center; }
html #directoryBulk.directory-admin-only[hidden], html #directoryBulk.hidden { display: none; }
html #directoryBulk > * { min-width: 0; }
html #directoryBulk > label { font-size: 13px; }
html #directoryBulk > label > input, html #directoryBulk > label > select { width: 100%; height: 40px; }
html #directoryBulk > button { height: auto; min-height: 38px; }
html #directoryBulk > #directoryApplySeller,
html #directoryBulk > #directoryApplyNetwork,
html #directoryBulk > #directoryApplyPriceTable { align-self: end; min-height: 40px; padding: 5px; line-height: 1.15; }
html #directoryBulk .directory-bulk-status { min-width: 0; font-size: 13px; }

/* Gerar link */
html #linkCard > .row { display: grid; grid-template-columns: 1fr; gap: 8px; }
html #linkCard > .row > * { min-width: 0; width: 100%; }
html #linkCard .created-inline { flex-wrap: wrap; }
html .suggestion-list label { font-size: 14px; }

/* Configurações e diálogos */
html .dialog { padding: 12px; }
html .permission-role-select { min-width: 0; width: 100%; }
html .receipt-meta { grid-template-columns: 1fr; }
html body > aside.side-menu ~ main.wrap select { min-height: 40px; max-width: 100%; border: 1px solid #c6d2df; border-radius: 7px; background: #fff; padding: 0 6px; }
/* Tabelas de configuração (tipo de recebimento, tipo de negócio): rolagem
   lateral só dentro da tabela, nunca da página. */
html body > aside.side-menu ~ main.wrap table:not(.directory-table) { display: block; max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
