/* ═══════════════════════════════════════════════════════════════════════════
   O MODAL DO TIPO DO ITEM (Almoxarifado) — `static/js/cautela_tipos.js` +
   `partials/_cautela_tipo_modal.html`. Componente é JS, CSS e markup.

   ⚠️ No celular ele é uma FOLHA de tela inteira, com o Salvar preso embaixo
   (acima do risquinho do home). As exigências são LINHAS COM CHAVE, uma por
   linha e com 52px de altura: a grade de caixinhas de 18px do protótipo não
   se acertava com o dedo (pedido do Marcos, 04/10/2026).
   ═══════════════════════════════════════════════════════════════════════════ */

.ctm[hidden] { display: none !important; }
/* ⚠️ Toda peça daqui que se esconde por `[hidden]` tem `display` próprio
   (flex, grid): sem esta regra a classe ganha do `[hidden]` e o prazo de
   devolução aparecia no EPI (a família do #23/#25/#31, achada na foto). */
.ctm [hidden] { display: none !important; }
.ctm {
  /* ⚠️ Abaixo do catálogo de características (`#caractCatModal`, 1100), que
     abre POR CIMA dele pelo "Editar o catálogo da empresa". */
  position: fixed; inset: 0; z-index: 1090;
  display: flex; align-items: center; justify-content: center;
}
.ctm-veu { position: absolute; inset: 0; background: rgba(15, 23, 32, .55); }
.ctm-caixa {
  position: relative; display: flex; flex-direction: column;
  width: min(640px, calc(100vw - 32px)); max-height: calc(100vh - 48px);
  background: var(--card-bg, #fff); color: var(--text, #10202e);
  border-radius: 18px; box-shadow: 0 20px 60px rgba(0, 0, 0, .25);
  overflow: hidden;
}
.ctm-topo, .ctm-tipos, .ctm-pe { flex: 0 0 auto; }
.ctm-topo {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px 10px; border-bottom: 1px solid var(--border-color, #e5ebf2);
}
.ctm-topo h2 { margin: 0; font-size: 18px; font-weight: 800; flex: 1 1 auto; min-width: 0; }
.ctm-x {
  width: 44px; height: 44px; border: 0; border-radius: 12px; flex: 0 0 auto;
  background: transparent; color: inherit; font-size: 24px; line-height: 1; cursor: pointer;
}
.ctm-x:hover { background: var(--bg-soft, #f2f6fa); }

/* A fileira dos tipos: troca de tipo sem fechar o modal. */
.ctm-tipos {
  display: flex; gap: 6px; overflow-x: auto; padding: 10px 16px 2px;
  scrollbar-width: none; -webkit-overflow-scrolling: touch;
}
.ctm-tipos::-webkit-scrollbar { display: none; }
.ctm-tipo {
  flex: 0 0 auto; display: inline-flex; align-items: center; gap: 6px;
  min-height: 40px; padding: 0 14px; border-radius: 20px; cursor: pointer;
  border: 1px solid var(--border-color, #d6e0ea); background: var(--card-bg, #fff);
  color: inherit; font: inherit; font-size: 13px; font-weight: 600; white-space: nowrap;
}
.ctm-tipo svg { width: 16px; height: 16px; }
.ctm-tipo.is-on { background: var(--brand-grad, linear-gradient(118deg,#7bbf2e 0%,#7bbf2e 50%,#11adb4 100%)); color: #fff; border-color: transparent; }
.ctm-tipo.is-off { opacity: .55; text-decoration: line-through; }
.ctm-tipo-novo { border-style: dashed; }

.ctm-corpo { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 8px 16px 16px; display: grid; gap: 18px; -webkit-overflow-scrolling: touch; }
.ctm-sec { display: grid; gap: 8px; min-width: 0; }
.ctm-rot {
  font-size: 12px; font-weight: 700; color: var(--text-soft, #5b6d7d);
  text-transform: uppercase; letter-spacing: .05em;
}
.ctm-dica { margin: 0; font-size: 13px; color: var(--text-soft, #5b6d7d); }
.ctm-campo {
  width: 100%; box-sizing: border-box; min-height: 46px; padding: 0 12px;
  border: 1px solid var(--border-color, #d6e0ea); border-radius: 12px;
  font: inherit; font-size: 15px; background: var(--card-bg, #fff); color: inherit;
}

/* Ícone: uma fileira de botões redondos (rádio). */
.ctm-icones { display: flex; flex-wrap: wrap; gap: 6px; }
.ctm-icone {
  width: 44px; height: 44px; border-radius: 12px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--border-color, #d6e0ea); background: var(--card-bg, #fff); color: inherit;
}
.ctm-icone svg { width: 20px; height: 20px; }
.ctm-icone.is-on { background: var(--brand-grad, #11adb4); color: #fff; border-color: transparent; }

/* Como o item sai: três cartões, um por linha no celular. */
.ctm-modos { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.ctm-modo {
  text-align: left; padding: 12px 14px; min-height: 64px; border-radius: 14px; cursor: pointer;
  border: 1px solid var(--border-color, #d6e0ea); background: var(--card-bg, #fff);
  color: inherit; font: inherit;
}
.ctm-modo b { display: block; font-size: 15px; }
.ctm-modo small { display: block; font-size: 12px; color: var(--text-soft, #5b6d7d); margin-top: 2px; }
.ctm-modo.is-on { background: var(--brand-grad, #11adb4); color: #fff; border-color: transparent; }
.ctm-modo.is-on small { color: #fff; opacity: .9; }

/* As exigências: LINHA COM CHAVE, o desenho das configurações do celular. */
.ctm-chaves {
  display: grid; border: 1px solid var(--border-color, #e5ebf2); border-radius: 14px; overflow: hidden;
}
.ctm-chave {
  display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 8px 14px;
  cursor: pointer; background: var(--card-bg, #fff);
}
.ctm-chave + .ctm-chave { border-top: 1px solid var(--border-color, #e5ebf2); }
.ctm-chave-txt { flex: 1 1 auto; min-width: 0; }
.ctm-chave-txt b { display: block; font-size: 15px; font-weight: 600; color: var(--text, #10202e); }
.ctm-chave-txt small { display: block; font-size: 12px; color: var(--text-soft, #5b6d7d); }
.ctm-chave input { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }
.ctm-trilho {
  flex: 0 0 auto; position: relative; width: 50px; height: 30px; border-radius: 15px;
  background: var(--border-color, #cbd5e1); transition: background .15s;
}
.ctm-trilho::after {
  content: ''; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .25); transition: transform .15s;
}
.ctm-chave input:checked + .ctm-trilho { background: #11adb4; }
.ctm-chave input:checked + .ctm-trilho::after { transform: translateX(20px); }
.ctm-chave input:focus-visible + .ctm-trilho { outline: 2px solid #11adb4; outline-offset: 2px; }

/* As características exigidas: chips com ×, e o autocomplete da casa embaixo. */
.ctm-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.ctm-chips:empty { display: none; }
.ctm-chip {
  display: inline-flex; align-items: center; gap: 4px; min-height: 36px; padding: 0 4px 0 12px;
  border-radius: 18px; background: #e6f7f7; color: #0a5f63; font-size: 14px; font-weight: 600;
}
.ctm-chip button {
  width: 32px; height: 32px; border: 0; border-radius: 50%; background: transparent;
  color: inherit; font-size: 18px; line-height: 1; cursor: pointer;
}
.ctm-chip button:hover { background: rgba(10, 95, 99, .12); }

.ctm-sec [data-ctm-catalogo] { justify-self: start; min-height: 40px; }
.ctm-prazo { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.ctm-prazo .vstep { width: 150px; }
.ctm-sozinho { margin: 0; font-size: 13px; color: var(--text-soft, #5b6d7d); padding: 10px 0; }

.ctm-pe {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--border-color, #e5ebf2); background: var(--card-bg, #fff);
}
.ctm-msg { flex: 1 1 200px; min-width: 0; font-size: 13px; color: var(--text-soft, #5b6d7d); }
.ctm-msg.is-ruim { color: #b42318; }
.ctm-pe .btn { min-height: 46px; padding: 0 22px; }

/* O lápis do tipo, nos lugares em que o tipo aparece. */
.ct-tipo-lapis {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-width: 40px; min-height: 40px; padding: 0 10px; border-radius: 10px; cursor: pointer;
  border: 1px dashed var(--border-color, #9fb3c5); background: transparent;
  color: var(--text-soft, #33475a); font: inherit; font-size: 13px; font-weight: 600;
}
.ct-tipo-lapis svg { width: 16px; height: 16px; }
.ct-tipo-lapis:hover { background: var(--bg-soft, #f2f6fa); }

@media (max-width: 680px) {
  .ctm { align-items: stretch; }
  .ctm-caixa {
    width: 100vw; max-height: none; height: 100%; border-radius: 0;
    padding-top: env(safe-area-inset-top, 0px);
  }
  .ctm-modos { grid-template-columns: 1fr; }
  .ctm-pe .btn { flex: 1 1 100%; }
  /* O botão flutuante do Suporte mora no canto de baixo: o Salvar abre espaço
     pra ele (esconder não serve, é por ali que se pede ajuda). */
  body:has(.supw) .ctm-pe { padding-right: 84px; }
}

/* ═══ NOVA CARACTERÍSTICA (`caract_nova.js`): por cima de tudo da aba (o
   modal do tipo é 1090, o catálogo 1100), e no celular uma folha embaixo. ═══ */
.ctn[hidden], .ctn [hidden] { display: none !important; }
.ctn { position: fixed; inset: 0; z-index: 1120; display: flex; align-items: center; justify-content: center; }
.ctn-veu { position: absolute; inset: 0; background: rgba(15, 23, 32, .55); }
.ctn-caixa {
  position: relative; display: grid; gap: 10px; width: min(460px, calc(100vw - 32px));
  max-height: calc(100vh - 48px); overflow-y: auto; padding: 18px 16px;
  background: var(--card-bg, #fff); color: var(--text, #10202e);
  border-radius: 18px; box-shadow: 0 20px 60px rgba(0, 0, 0, .25);
}
.ctn-caixa h2 { margin: 0 0 4px; font-size: 18px; font-weight: 800; }
.ctn-tipos { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.ctn-tipo {
  text-align: left; min-height: 64px; padding: 10px 12px; border-radius: 14px; cursor: pointer;
  border: 1px solid var(--border-color, #d6e0ea); background: var(--card-bg, #fff); color: inherit; font: inherit;
}
.ctn-tipo b { display: block; font-size: 15px; }
.ctn-tipo small { display: block; font-size: 12px; color: var(--text-soft, #5b6d7d); margin-top: 2px; }
.ctn-tipo.is-on { background: var(--brand-grad, #11adb4); color: #fff; border-color: transparent; }
.ctn-tipo.is-on small { color: #fff; opacity: .9; }
.ctn-opcoes { display: grid; gap: 8px; }
.ctn-add { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
.ctn-add .btn { min-height: 46px; }
.ctn-acoes { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.ctn-acoes .btn { min-height: 46px; padding: 0 18px; }
.ctn .ctm-msg { margin: 0; }
.ctn .ctm-msg:empty { display: none; }

@media (max-width: 680px) {
  .ctn { align-items: flex-end; }
  .ctn-caixa {
    width: 100vw; border-radius: 18px 18px 0 0; max-height: 92vh;
    padding-bottom: calc(18px + env(safe-area-inset-bottom, 0px));
  }
  .ctn-tipos { grid-template-columns: 1fr; }
  .ctn-acoes .btn { flex: 1 1 0; }
  /* o botão flutuante do Suporte mora no canto: os botões abrem espaço pra ele */
  body:has(.supw) .ctn-acoes { padding-right: 76px; }
}
