/* =====================================================================
   20/11 — GESTÃO NO TELEMÓVEL (iPhone)
   Só funciona em ecrãs até 700 px de largura. No PC e no iPad fica tudo igual.
   - colunas lado a lado: desliza-se com o dedo, uma coluna de cada vez
   - fila de separadores fixa em cima com o nome e o número de cada coluna
   - topo compacto (botões numa linha que desliza), frase do dia numa linha própria
   - a receção abre por cima do quadro (ecrã inteiro), com botão ✕ Fechar
   O comportamento (separadores, salto na pesquisa, abrir a receção ao tocar
   num cartão) está no gestao-mobile.js.
   ===================================================================== */

/* fora do telemóvel os separadores não existem */
#mmjMobAbas, #mmjMobFechar{ display:none; }

@media (max-width: 700px){

  /* ---------- página: desliza normalmente (sem alturas fixas) ---------- */
  /* overflow "visible" é obrigatório: com hidden/auto aqui, a fila de separadores deixa de ficar fixa no iPhone */
  html:not(.m1):not(.m2):not(.m3), html:not(.m1):not(.m2):not(.m3) body{
    height:auto !important; overflow:visible !important;
  }
  html:not(.m1):not(.m2):not(.m3) body .container{
    display:block !important; height:auto !important; overflow:visible !important;
  }
  html:not(.m1):not(.m2):not(.m3) body .board-wrapper{
    height:auto !important; overflow:visible !important; background-attachment:scroll !important;
  }
  html:not(.m1):not(.m2):not(.m3) body #viewGestao{ height:auto !important; }
  html:not(.m1):not(.m2):not(.m3) body #viewGestao .board{
    display:block !important; height:auto !important; overflow:visible !important; padding:10px 0 24px !important;
  }

  /* ---------- topo compacto ---------- */
  html:not(.m1):not(.m2):not(.m3) body .banner-bar{ padding:10px 0 9px !important; }
  html:not(.m1):not(.m2):not(.m3) body .banner-header{
    flex-direction:column !important; align-items:stretch !important; row-gap:9px !important;
  }
  html:not(.m1):not(.m2):not(.m3) body .banner-left{ padding:0 14px !important; }
  html:not(.m1):not(.m2):not(.m3) body .banner-title .bt-marca{ font-size:26px !important; }
  html:not(.m1):not(.m2):not(.m3) body .banner-title .bt-logo{ height:26px !important; padding-left:10px !important; }
  html:not(.m1):not(.m2):not(.m3) body .banner-right{
    flex-wrap:nowrap !important; overflow-x:auto !important; -webkit-overflow-scrolling:touch;
    padding:0 14px 2px !important; gap:7px !important; scrollbar-width:none;
  }
  html:not(.m1):not(.m2):not(.m3) body .banner-right::-webkit-scrollbar{ display:none; }
  html:not(.m1):not(.m2):not(.m3) body .banner-right > .nav-btn{
    flex:0 0 auto !important; margin-left:0 !important;
    font-size:13.5px !important; padding:6px 13px !important; border-width:1.5px !important;
  }

  /* ---------- pesquisa e contadores ---------- */
  html:not(.m1):not(.m2):not(.m3) body #viewGestao .gestao-searchbar{
    padding:0 12px !important; margin:0 0 6px !important; column-gap:8px !important; row-gap:8px !important;
  }
  /* 16 px evita que o iPhone faça zoom ao tocar no campo */
  html:not(.m1):not(.m2):not(.m3) body .gestao-searchbar #searchGestao{ font-size:16px !important; padding:11px 12px !important; }
  html:not(.m1):not(.m2):not(.m3) body .gestao-searchbar .btn-clear{ width:44px !important; height:44px !important; }
  html:not(.m1):not(.m2):not(.m3) body .gestao-searchbar .search-info{ min-width:0 !important; flex:0 0 100% !important; text-align:left !important; }
  html:not(.m1):not(.m2):not(.m3) body .mmj-contadores{ gap:6px !important; }
  html:not(.m1):not(.m2):not(.m3) body .mmj-contadores .badge{ font-size:13px !important; padding:5px 10px !important; }
  /* frase do dia: numa linha própria, inteira, no fim dos contadores */
  html:not(.m1):not(.m2):not(.m3) body .mmj-contadores-espaco{
    order:99 !important; flex:0 0 100% !important; padding:6px 4px 0 !important;
  }
  html:not(.m1):not(.m2):not(.m3) body #mmjFraseDia{ white-space:normal !important; overflow:visible !important; }
  html:not(.m1):not(.m2):not(.m3) body #mmjFraseDia .mfd-texto{ font-size:17px !important; }
  html:not(.m1):not(.m2):not(.m3) body #mmjFraseDia .mfd-aspas{ font-size:28px !important; vertical-align:-9px; }

  /* ---------- separadores das colunas (fixos em cima ao deslizar a página) ---------- */
  html:not(.m1):not(.m2):not(.m3) body #mmjMobAbas{
    display:flex; gap:6px; overflow-x:auto; -webkit-overflow-scrolling:touch; scrollbar-width:none;
    position:sticky; top:0; z-index:50; padding:8px 12px; margin:4px 0 6px;
    background:#EEF1F5; box-shadow:0 4px 8px -6px rgba(16,24,40,.25);
  }
  #mmjMobAbas::-webkit-scrollbar{ display:none; }
  #mmjMobAbas button{
    flex:0 0 auto; border:1px solid #DDE3EA; background:#FFFFFF; color:#2E3A4B;
    border-radius:999px; padding:7px 12px; font:600 13.5px/1.2 -apple-system,"Segoe UI",Roboto,sans-serif;
    transition:opacity .2s;
  }
  #mmjMobAbas button .q{ margin-left:5px; color:#C2410C; font-weight:700; }
  #mmjMobAbas button.on{ background:#2E3A4B; border-color:#2E3A4B; color:#FFFFFF; }
  #mmjMobAbas button.on .q{ color:#FDBA74; }
  #mmjMobAbas button.zero{ opacity:.4; }

  /* ---------- colunas lado a lado, uma de cada vez ---------- */
  html:not(.m1):not(.m2):not(.m3) body #viewGestao .colunas,
  html:not(.m1):not(.m2):not(.m3) body #viewGestao .colunas.mmj-entrada-recolhida{
    display:flex !important; flex-direction:row !important; align-items:flex-start !important;
    overflow-x:auto !important; overflow-y:hidden !important;
    scroll-snap-type:x mandatory; -webkit-overflow-scrolling:touch; overscroll-behavior-x:contain;
    gap:0 !important; min-width:0 !important; max-width:none !important; width:100% !important;
    grid-template-columns:none !important; scrollbar-width:none; padding:0 !important;
  }
  html:not(.m1):not(.m2):not(.m3) body #viewGestao .colunas::-webkit-scrollbar{ display:none; }
  html:not(.m1):not(.m2):not(.m3) body #viewGestao .colunas > .coluna,
  html:not(.m1):not(.m2):not(.m3) body #viewGestao .colunas > .coluna.mmj-coluna-recolhida{
    flex:0 0 100% !important; width:100% !important; max-width:100% !important; min-width:0 !important;
    max-height:none !important; height:auto !important; overflow:visible !important;
    scroll-snap-align:start; scroll-snap-stop:always;
    background:transparent !important; border-radius:0 !important; padding:0 12px !important; box-sizing:border-box !important;
  }
  /* cabeçalho da coluna como no PC (ardósia + fio laranja), cantos redondos em cima */
  html:not(.m1):not(.m2):not(.m3) body #viewGestao .coluna > .coluna-header{
    writing-mode:horizontal-tb !important; transform:none !important; min-height:0 !important;
    flex-direction:row !important; justify-content:center !important;
    padding:10px 12px !important; margin:0 !important; border-radius:12px 12px 0 0 !important;
    border-bottom:3px solid #F07A1E !important; cursor:default !important;
  }
  html:not(.m1):not(.m2):not(.m3) body #viewGestao .coluna .coluna-titulo{ font-size:16.5px !important; text-decoration:none !important; }
  html:not(.m1):not(.m2):not(.m3) body #viewGestao .coluna .coluna-subtitulo{
    writing-mode:horizontal-tb !important; transform:none !important;
    font-size:13px !important; line-height:20px !important; padding:0 9px !important;
    background:rgba(255,255,255,.18) !important;
  }
  /* lista de cartões: sem scroll próprio, cresce com os cartões */
  html:not(.m1):not(.m2):not(.m3) body #viewGestao .coluna > div[id^="col-"],
  html:not(.m1):not(.m2):not(.m3) body #viewGestao .coluna.mmj-coluna-recolhida > div[id^="col-"]{
    display:block !important; overflow:visible !important; max-height:none !important; min-height:80px !important;
    background:#E3E8EF !important; border-radius:0 0 12px 12px !important; padding:10px 10px 4px !important;
  }

  /* ---------- cartões: tamanho de telemóvel (letra normal, matrícula grande) ---------- */
  html:not(.m1):not(.m2):not(.m3) body #viewGestao .card{
    height:auto !important; min-height:176px !important; max-height:none !important;
    padding:12px 12px 52px 18px !important; margin-bottom:10px !important; border-radius:12px !important;
  }
  html:not(.m1):not(.m2):not(.m3) body #viewGestao .card:hover{ transform:none !important; }
  html:not(.m1):not(.m2):not(.m3) body .card .matricula{ height:31px !important; margin-bottom:8px !important; }
  html:not(.m1):not(.m2):not(.m3) body .card .matricula-pt-eu{ width:18px !important; }
  html:not(.m1):not(.m2):not(.m3) body .card .matricula-pt-eu svg{ width:14px !important; height:14px !important; }
  html:not(.m1):not(.m2):not(.m3) body .card .matricula-pt-p{ font-size:11px !important; }
  html:not(.m1):not(.m2):not(.m3) body .card .matricula-main{ font-size:20px !important; letter-spacing:3px !important; padding:3px 7px 3px 10px !important; }
  html:not(.m1):not(.m2):not(.m3) body #viewGestao .card .servico-row{ max-height:none !important; min-height:0 !important; }
  html:not(.m1):not(.m2):not(.m3) body .card .servico{ font-size:15.5px !important; }
  html:not(.m1):not(.m2):not(.m3) body .card .viatura{ font-size:15px !important; margin-top:6px !important; }
  html:not(.m1):not(.m2):not(.m3) body .card .entrada,
  html:not(.m1):not(.m2):not(.m3) body .card .notas-info{ font-size:13px !important; }
  html:not(.m1):not(.m2):not(.m3) body .card .obs,
  html:not(.m1):not(.m2):not(.m3) body .card .ultima-nota{ font-size:12.5px !important; }
  html:not(.m1):not(.m2):not(.m3) body .mmjEtiqRow .ckTagG,
  html:not(.m1):not(.m2):not(.m3) body .mmjEtiqRow .fatBtnG,
  html:not(.m1):not(.m2):not(.m3) body .mmjEtiqRow .fatTagG{ font-size:12px !important; padding:2px 8px !important; }
  /* botões Entrada / Anexar / Dossier fáceis de tocar com o dedo */
  html:not(.m1):not(.m2):not(.m3) body .card .btnCardActionsMMJ{ left:10px !important; right:8px !important; bottom:8px !important; gap:6px !important; }
  html:not(.m1):not(.m2):not(.m3) body .card:has(.btnHorasCard) .btnCardActionsMMJ{ right:50px !important; }
  html:not(.m1):not(.m2):not(.m3) body .card .btnEntradaCard,
  html:not(.m1):not(.m2):not(.m3) body .card .btnAnexarCard,
  html:not(.m1):not(.m2):not(.m3) body .card .btnDossierCard{ font-size:12px !important; min-height:38px !important; }
  html:not(.m1):not(.m2):not(.m3) body .card .btnCardActionsMMJ .ic{ font-size:15px !important; }
  html:not(.m1):not(.m2):not(.m3) body .card .btnHorasCard{ width:34px !important; height:34px !important; right:9px !important; bottom:10px !important; }

  /* ---------- receção: abre por cima do quadro, em ecrã inteiro ---------- */
  html:not(.m1):not(.m2):not(.m3) body .sidebar{
    position:fixed !important; inset:0 !important; z-index:9000 !important;
    width:100% !important; min-width:0 !important; max-width:none !important;
    height:100% !important; max-height:none !important; transform:none !important;
    overflow-y:auto !important; -webkit-overflow-scrolling:touch; overscroll-behavior:contain;
    padding:0 16px calc(28px + env(safe-area-inset-bottom, 0px)) !important;
    border-right:0 !important; border-top:4px solid #F07A1E !important; box-sizing:border-box !important;
  }
  html:not(.m1):not(.m2):not(.m3) body.mmj-lateral-fechada .sidebar{ display:none !important; }
  html:not(.m1):not(.m2):not(.m3) body:not(.mmj-lateral-fechada){ overflow:hidden !important; }
  html:not(.m1):not(.m2):not(.m3) body .sidebar h2{ font-size:19px !important; margin-top:6px !important; }
  /* campos com 16 px: o iPhone não faz zoom ao escrever */
  html:not(.m1):not(.m2):not(.m3) body .sidebar input,
  html:not(.m1):not(.m2):not(.m3) body .sidebar select,
  html:not(.m1):not(.m2):not(.m3) body .sidebar textarea{ font-size:16px !important; padding:10px 11px !important; }
  html:not(.m1):not(.m2):not(.m3) body .sidebar .campo > label{ font-size:14px !important; }
  html:not(.m1):not(.m2):not(.m3) body .sidebar button{ min-height:40px; }
  /* barra fixa no topo da receção com o botão Fechar */
  html:not(.m1):not(.m2):not(.m3) body #mmjMobFechar{
    display:flex; position:sticky; top:0; z-index:5; justify-content:flex-end;
    margin:0 -16px; padding:calc(10px + env(safe-area-inset-top, 0px)) 14px 10px; background:#2E3A4B;
  }
  #mmjMobFechar button{
    border:1.5px solid rgba(255,255,255,.85); background:transparent; color:#fff;
    border-radius:999px; padding:8px 16px; font:600 15px/1 -apple-system,"Segoe UI",Roboto,sans-serif;
  }

  /* o botão "☰ Lateral" do tablet não faz falta no telemóvel */
  #mmjTabletToggle{ display:none !important; }
}
