/* TekPrax V5.6.1 — acabamento responsivo dos editores e hierarquia de diálogos. */

/* Diálogos dos editores sempre devem ficar acima da faixa/painel mobile e da navbar. */
.tp-doc-modal,
body.tp-mobile-editor-active > .tp-doc-modal,
body.tp-mobile-editor-active > .modal,
body.tp-mobile-editor-doc > .modal,
body.tp-mobile-editor-sheet > .modal,
body.tp-mobile-editor-slides > .modal,
body.tp-mobile-editor-email > .modal{
  z-index:2147483647!important;
  isolation:isolate!important;
}
.tp-doc-modal{backdrop-filter:blur(2px)}
.tp-doc-modal-card,.tp-pro-dialog-card{position:relative;z-index:1}

/* A engrenagem passa a participar da grade de Fonte/Tamanho/Estilo. */
.tp-font-more-button{display:flex!important;align-items:center!important;justify-content:center!important;min-width:0!important}

@media(max-width:840px){
  /* Editor de documentos — topo 2x2, exatamente como: Fonte | Tamanho / Estilo | engrenagem. */
  body.tp-mobile-editor-doc .tp-font-selectors,
  #text-editor-sticky-tools .tp-font-selectors{
    display:grid!important;
    grid-template-columns:repeat(2,minmax(0,1fr))!important;
    grid-auto-flow:row!important;
    gap:6px!important;
    width:100%!important;
  }
  body.tp-mobile-editor-doc .tp-font-selectors>select,
  body.tp-mobile-editor-doc .tp-font-selectors>.tp-font-more-button,
  #text-editor-sticky-tools .tp-font-selectors>select,
  #text-editor-sticky-tools .tp-font-selectors>.tp-font-more-button{
    width:100%!important;
    min-width:0!important;
    height:42px!important;
    margin:0!important;
  }
  body.tp-mobile-editor-doc .tp-font-selectors>.tp-font-more-button,
  #text-editor-sticky-tools .tp-font-selectors>.tp-font-more-button{
    font-size:1rem!important;
    border-radius:8px!important;
  }

  /* Seis atalhos de formatação: duas linhas completas, sem célula vazia. */
  body.tp-mobile-editor-doc .tp-format-buttons,
  #text-editor-sticky-tools .tp-format-buttons{
    display:grid!important;
    grid-template-columns:repeat(3,minmax(0,1fr))!important;
    gap:6px!important;
    width:100%!important;
  }
  body.tp-mobile-editor-doc .tp-format-buttons>.tp-ribbon-command,
  #text-editor-sticky-tools .tp-format-buttons>.tp-ribbon-command{
    width:100%!important;min-width:0!important;min-height:38px!important;margin:0!important;
  }

  /* Cor, marcador e limpar ocupam sempre a largura inteira em três partes iguais. */
  body.tp-mobile-editor-doc .tp-font-mode-tools,
  #text-editor-sticky-tools .tp-font-mode-tools{
    display:grid!important;
    grid-template-columns:repeat(3,minmax(0,1fr))!important;
    gap:6px!important;
    width:100%!important;
  }
  body.tp-mobile-editor-doc .tp-font-mode-tools>.tp-color-tool,
  #text-editor-sticky-tools .tp-font-mode-tools>.tp-color-tool{
    width:100%!important;min-width:0!important;margin:0!important;
  }

  /* Demais grupos do Word-like editor usam flex-grow: a última linha se expande e não deixa buracos. */
  body.tp-mobile-editor-doc .tp-ribbon-section>.tp-ribbon-inline:not(.tp-font-selectors):not(.tp-format-buttons),
  #text-editor-sticky-tools .tp-ribbon-section>.tp-ribbon-inline:not(.tp-font-selectors):not(.tp-format-buttons){
    display:flex!important;
    flex-flow:row wrap!important;
    align-items:stretch!important;
    gap:6px!important;
    width:100%!important;
  }
  body.tp-mobile-editor-doc .tp-ribbon-section>.tp-ribbon-inline:not(.tp-font-selectors):not(.tp-format-buttons)>button,
  body.tp-mobile-editor-doc .tp-ribbon-section>.tp-ribbon-inline:not(.tp-font-selectors):not(.tp-format-buttons)>label,
  #text-editor-sticky-tools .tp-ribbon-section>.tp-ribbon-inline:not(.tp-font-selectors):not(.tp-format-buttons)>button,
  #text-editor-sticky-tools .tp-ribbon-section>.tp-ribbon-inline:not(.tp-font-selectors):not(.tp-format-buttons)>label{
    flex:1 1 92px!important;
    min-width:min(92px,100%)!important;
    width:auto!important;
    margin:0!important;
  }

  /* Ações de arquivo/biblioteca também redistribuem a linha final. */
  body.tp-mobile-editor-active .tp-file-actions,
  body.tp-mobile-editor-active .tp-editor-file-actions{
    display:flex!important;flex-flow:row wrap!important;gap:7px!important;width:100%!important;
  }
  body.tp-mobile-editor-active .tp-file-actions>*,
  body.tp-mobile-editor-active .tp-editor-file-actions>*{
    flex:1 1 128px!important;min-width:min(128px,100%)!important;width:auto!important;margin:0!important;
  }

  /* Planilhas: toolbar deixa de ser uma faixa horizontal e passa a preencher toda a largura. */
  .tp-sheet-toolbar{
    display:flex!important;
    flex-flow:row wrap!important;
    overflow:visible!important;
    align-items:stretch!important;
    gap:6px!important;
    padding:8px!important;
  }
  .tp-sheet-toolbar>.sep{display:none!important}
  .tp-sheet-toolbar>button,
  .tp-sheet-toolbar>select,
  .tp-sheet-toolbar>input[type="number"],
  .tp-sheet-toolbar>input[type="text"]{
    flex:1 1 72px!important;
    min-width:58px!important;
    width:auto!important;
    height:38px!important;
    margin:0!important;
  }
  .tp-sheet-toolbar>label.color{flex:1 1 44px!important;min-width:44px!important;max-width:68px!important;height:38px!important;margin:0!important}
  .tp-sheet-formula{grid-template-columns:minmax(68px,.34fr) minmax(0,1.66fr)!important;gap:6px!important}

  /* Slides: mesma regra de crescimento por linha; nada fica sobrando como faixa vazia. */
  .tp-slides-toolbar{
    display:flex!important;
    flex-flow:row wrap!important;
    overflow:visible!important;
    align-items:stretch!important;
    gap:6px!important;
    padding:8px!important;
  }
  .tp-slides-toolbar>.sep{display:none!important}
  .tp-slides-toolbar>button,
  .tp-slides-toolbar>select,
  .tp-slides-toolbar>input[type="number"]{
    flex:1 1 70px!important;
    min-width:56px!important;
    width:auto!important;
    height:38px!important;
    margin:0!important;
  }
  .tp-slides-toolbar>label.color{flex:1 1 44px!important;min-width:44px!important;max-width:68px!important;height:38px!important;margin:0!important}
  .tp-ins-grid{grid-template-columns:repeat(auto-fit,minmax(118px,1fr))!important}
  .tp-ins-actions{display:flex!important;flex-flow:row wrap!important;gap:7px!important}
  .tp-ins-actions>button{flex:1 1 128px!important;min-width:min(128px,100%)!important}

  /* Diálogos mobile: sempre acima do editor e dentro da área visível. */
  .tp-doc-modal,
  body.tp-mobile-editor-active > .modal{
    padding:max(10px,env(safe-area-inset-top)) 10px max(10px,env(safe-area-inset-bottom))!important;
    align-items:center!important;
    justify-content:center!important;
    overflow:auto!important;
  }
  .tp-doc-modal-card,.tp-pro-dialog-card{
    width:min(100%,680px)!important;
    max-width:100%!important;
    max-height:calc(100dvh - 24px)!important;
    overflow:auto!important;
    margin:auto!important;
  }
}

@media(max-width:480px){
  body.tp-mobile-editor-doc .tp-ribbon-panel{padding:5px!important}
  body.tp-mobile-editor-doc .tp-font-selectors{gap:5px!important}
  body.tp-mobile-editor-doc .tp-format-buttons{gap:5px!important}
  body.tp-mobile-editor-doc .tp-font-mode-tools{gap:5px!important}
  .tp-sheet-toolbar>button,.tp-sheet-toolbar>select,.tp-slides-toolbar>button,.tp-slides-toolbar>select{font-size:.73rem!important;padding-left:6px!important;padding-right:6px!important}
  .tp-doc-modal-card,.tp-pro-dialog-card{padding:15px!important;border-radius:14px!important}
}
