/* NFE — visual moderno (25/10/2026). Só aparência e movimento: menu flutuante em pílula, dicas ao passar o mouse,
 * entrada suave das telas e dos cards, elevação ao passar o mouse e números que sobem.
 * Usa as mesmas cores do CRM (variáveis --nfe-*). Nenhuma tela, configuração ou integração muda. */

/* ---------------------------------------------------------------- menu flutuante (computador) */
@media (min-width: 1024px) {
  #sidebar {
    left: 16px !important; top: 16px !important; bottom: 16px !important; height: auto !important; width: 76px !important;
    background: var(--nfe-rail-bg, rgb(17 17 17)) !important; border: 0 !important; border-radius: 30px;
    box-shadow: 0 18px 50px -12px rgba(0, 0, 0, .35); overflow: visible;
    animation: nfeRailIn .4s cubic-bezier(.2, .8, .2, 1) both;
  }
  #sidebar > div:first-child { padding: 18px 0 10px !important; border: 0 !important; display: flex; justify-content: center; }
  #sidebar > div:first-child > div { justify-content: center; }
  #sidebar > div:first-child > div > div { display: none; } /* nome "NFE CRM" escondido: só o logo */
  #sidebar .nfe-logo-sidebar { width: 36px !important; height: 36px !important; object-fit: contain; filter: brightness(0) invert(1); }
  #sidebar-nav { padding: 6px 12px !important; display: flex; flex-direction: column; align-items: center; gap: 6px; scrollbar-width: none; }
  #sidebar-nav::-webkit-scrollbar { display: none; }
  #sidebar-nav > p { /* títulos de seção viram um traço discreto */
    font-size: 0 !important; padding: 0 !important; margin: 6px 0; width: 22px; height: 1px; background: rgb(255 255 255 / .18); flex-shrink: 0;
  }
  #sidebar .sidebar-link, #sidebar > div:last-child button {
    width: 48px !important; height: 48px; min-height: 48px; padding: 0 !important; justify-content: center; border-radius: 9999px !important; flex-shrink: 0;
    color: rgb(255 255 255 / .62) !important; background: transparent !important; box-shadow: none !important;
    transition: background .25s ease, color .25s ease, transform .25s cubic-bezier(.2, .8, .2, 1) !important;
  }
  #sidebar .sidebar-link i, #sidebar > div:last-child button i { color: inherit !important; width: auto !important; font-size: 17px; }
  #sidebar .sidebar-link > span, #sidebar > div:last-child button > span { display: none; }
  #sidebar .sidebar-link:hover, #sidebar > div:last-child button:hover { color: #fff !important; background: rgb(255 255 255 / .10) !important; transform: scale(1.06); }
  /* item ativo: mesmas cores de antes (ícone e marcador verde-limão da NFE) */
  #sidebar .sidebar-link.active { color: rgb(var(--nfe-lime)) !important; background: rgb(255 255 255 / .14) !important; box-shadow: inset 0 0 0 1px rgb(255 255 255 / .10) !important; }
  #sidebar .sidebar-link.active::before { left: -12px !important; top: 12px !important; bottom: 12px !important; animation: nfeFade .3s ease both; }
  #sidebar .sidebar-link [id$="badge"], #sidebar .sidebar-link .badge, #sidebar .sidebar-link span[class*="rounded-full"] { display: inline-flex !important; position: absolute; top: 2px; right: 0; transform: scale(.85); }
  #sidebar > div:last-child { border: 0 !important; padding: 10px 0 16px !important; display: flex; justify-content: center; }
  #app-container > .lg\:ml-64 { margin-left: 108px !important; }
}

/* ---------------------------------------------------------------- menu flutuante no celular/tablet (só administradores: body.nfe-rail-m) */
@media (max-width: 1023px) {
  body.nfe-rail-m #sidebar {
    left: 8px !important; top: 8px !important; bottom: 8px !important; height: auto !important; width: 60px !important; transform: none !important;
    background: var(--nfe-rail-bg, rgb(17 17 17)) !important; border: 0 !important; border-radius: 26px;
    box-shadow: 0 14px 36px -12px rgba(0, 0, 0, .35); overflow: hidden;
  }
  body.nfe-rail-m #sidebar-overlay, body.nfe-rail-m header button[onclick="App.toggleSidebar()"] { display: none !important; }
  body.nfe-rail-m #sidebar > div:first-child { padding: 14px 0 8px !important; border: 0 !important; display: flex; justify-content: center; }
  body.nfe-rail-m #sidebar > div:first-child > div { justify-content: center; }
  body.nfe-rail-m #sidebar > div:first-child > div > div { display: none; }
  body.nfe-rail-m #sidebar .nfe-logo-sidebar { width: 30px !important; height: 30px !important; object-fit: contain; filter: brightness(0) invert(1); }
  body.nfe-rail-m #sidebar-nav { padding: 4px 9px !important; display: flex; flex-direction: column; align-items: center; gap: 4px; scrollbar-width: none; }
  body.nfe-rail-m #sidebar-nav::-webkit-scrollbar { display: none; }
  body.nfe-rail-m #sidebar-nav > p { font-size: 0 !important; padding: 0 !important; margin: 5px 0; width: 20px; height: 1px; background: rgb(255 255 255 / .18); flex-shrink: 0; }
  body.nfe-rail-m #sidebar .sidebar-link, body.nfe-rail-m #sidebar > div:last-child button {
    position: relative; width: 42px !important; height: 42px; min-height: 42px; padding: 0 !important; justify-content: center; border-radius: 9999px !important; flex-shrink: 0;
    color: rgb(255 255 255 / .62) !important; background: transparent !important; box-shadow: none !important;
    -webkit-tap-highlight-color: transparent; transition: background .2s ease, color .2s ease, transform .16s ease !important;
  }
  body.nfe-rail-m #sidebar .sidebar-link:active, body.nfe-rail-m #sidebar > div:last-child button:active { transform: scale(.94); }
  body.nfe-rail-m #sidebar .sidebar-link i, body.nfe-rail-m #sidebar > div:last-child button i { color: inherit !important; width: auto !important; font-size: 16px; }
  body.nfe-rail-m #sidebar .sidebar-link > span, body.nfe-rail-m #sidebar > div:last-child button > span { display: none; }
  body.nfe-rail-m #sidebar .sidebar-link.active { color: rgb(var(--nfe-lime)) !important; background: rgb(255 255 255 / .14) !important; box-shadow: inset 0 0 0 1px rgb(255 255 255 / .10) !important; }
  body.nfe-rail-m #sidebar .sidebar-link.active::before { left: -9px !important; top: 10px !important; bottom: 10px !important; }
  body.nfe-rail-m #sidebar .sidebar-link [id$="badge"], body.nfe-rail-m #sidebar .sidebar-link .badge, body.nfe-rail-m #sidebar .sidebar-link span[class*="rounded-full"] { display: inline-flex !important; position: absolute; top: 0; right: -2px; transform: scale(.8); }
  body.nfe-rail-m #sidebar > div:last-child { border: 0 !important; padding: 8px 0 12px !important; display: flex; justify-content: center; }
  body.nfe-rail-m #app-container > .lg\:ml-64 { margin-left: 76px !important; }
  body.nfe-rail-m #app-container > .lg\:ml-64 > header { padding-left: 12px !important; padding-right: 12px !important; }
}

/* dica com o nome do menu (criada pelo nfe-visual.js) */
#nfe-tip {
  position: fixed; z-index: 60; pointer-events: none; padding: 6px 12px; border-radius: 9999px; font-size: 12px; font-weight: 600; white-space: nowrap;
  background: rgb(var(--nfe-900)); color: rgb(var(--nfe-white)); box-shadow: 0 10px 24px -8px rgba(0, 0, 0, .35);
  opacity: 0; transform: translate(-6px, -50%); transition: opacity .18s ease, transform .22s cubic-bezier(.2, .8, .2, 1);
}
#nfe-tip.on { opacity: 1; transform: translate(0, -50%); }

/* ---------------------------------------------------------------- entrada das telas e dos cards */
.nfe-enter { animation: nfeRise .32s cubic-bezier(.2, .8, .2, 1) both; animation-delay: calc(var(--i, 0) * 28ms); } /* rápido: só opacidade e posição (placa de vídeo), sem atrasar cliques */
@keyframes nfeRise { from { opacity: 0; transform: translate3d(0, 8px, 0); } to { opacity: 1; transform: none; } }
@keyframes nfeRailIn { from { opacity: 0; transform: translateX(-24px); } to { opacity: 1; transform: none; } }
@keyframes nfeFade { from { opacity: 0; } to { opacity: 1; } }

/* elevação ao passar o mouse (cards clicáveis, cards do funil e cards de números) */
#main-content .kanban-card, #main-content .nfe-lift {
  transition: transform .22s cubic-bezier(.2, .8, .2, 1), box-shadow .22s ease !important;
}
#main-content .kanban-card:hover, #main-content .nfe-lift:hover { transform: translateY(-5px); box-shadow: 0 18px 36px -18px rgba(0, 0, 0, .28) !important; }
#main-content .rounded-xl, #main-content .rounded-2xl { border-radius: 18px; }

/* janelas (modais) abrem com o mesmo movimento */
#modal-container:not(.hidden) #modal-content { animation: nfeRise .22s cubic-bezier(.2, .8, .2, 1) both; }

@media (prefers-reduced-motion: reduce) {
  #sidebar, .nfe-enter, #modal-container:not(.hidden) #modal-content, 
  #main-content .kanban-card:hover, #main-content .nfe-lift:hover, #sidebar .sidebar-link:hover { transform: none !important; }
}

/* ---------------------------------------------------------------- Acessos: abas Equipe / Clientes e busca */
.nfe-acc-tabs { display: inline-flex; gap: 4px; padding: 4px; margin-bottom: 18px; border-radius: 9999px; background: rgb(var(--nfe-100)); }
.nfe-acc-tab { display: inline-flex; align-items: center; gap: 8px; padding: 8px 18px; border-radius: 9999px; font-size: 14px; font-weight: 600; color: rgb(var(--nfe-500)); transition: background .2s ease, color .2s ease, box-shadow .2s ease; }
.nfe-acc-tab span { font-size: 11px; padding: 1px 7px; border-radius: 9999px; background: rgb(var(--nfe-200)); color: rgb(var(--nfe-700)); }
.nfe-acc-tab:hover { color: rgb(var(--nfe-900)); }
.nfe-acc-tab.on { background: rgb(var(--nfe-900)); color: rgb(var(--nfe-white)); box-shadow: 0 6px 16px -8px rgba(0, 0, 0, .4); }
.nfe-acc-tab.on span { background: rgb(var(--nfe-lime)); color: rgb(var(--nfe-900)); }
.nfe-acc-search { position: relative; display: flex; align-items: center; gap: 10px; margin-bottom: 14px; padding: 0 16px; height: 52px; border-radius: 9999px; background: rgb(var(--nfe-white)); border: 1px solid rgb(var(--nfe-200)); box-shadow: 0 8px 24px -18px rgba(0, 0, 0, .35); transition: border-color .2s ease, box-shadow .2s ease; }
.nfe-acc-search:focus-within { border-color: rgb(var(--nfe-900)); box-shadow: 0 0 0 4px rgb(var(--nfe-lime) / .35); }
.nfe-acc-search > i { color: rgb(var(--nfe-400)); }
.nfe-acc-search input:focus, .nfe-acc-search input:focus-visible { border: 0 !important; outline: none !important; box-shadow: none !important; }
.nfe-acc-search input { flex: 1; min-width: 0; height: 100%; border: 0 !important; outline: none !important; box-shadow: none !important; background: transparent; font-size: 15px; }
.nfe-acc-search kbd { font: 600 11px/1 inherit; padding: 4px 7px; border-radius: 6px; border: 1px solid rgb(var(--nfe-200)); color: rgb(var(--nfe-500)); }
.nfe-acc-search #nfe-acc-count { font-size: 12px; color: rgb(var(--nfe-500)); white-space: nowrap; }
.nfe-acc-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 14px 18px; transition: background .15s ease; }
.nfe-acc-row:hover { background: rgb(var(--nfe-50)); }
@media (max-width: 640px) { .nfe-acc-row { flex-direction: column; align-items: flex-start; } .nfe-acc-search kbd { display: none; } }
.nfe-acc-badge { display: inline-flex; align-items: center; gap: 4px; margin-left: 6px; padding: 2px 8px; border-radius: 9999px; font-size: 11px; font-weight: 600; background: rgb(var(--nfe-lime) / .25); color: rgb(var(--nfe-900)); vertical-align: middle; }

/* ---------------------------------------------------------------- celular: tela ajustada e fluida (14/11/2026)
 * Vale para o navegador do celular e para o app instalado (tela cheia: respeita notch e barra de gestos via env(safe-area-*)).
 * --nfe-vvh/--nfe-vvt = área visível acima do teclado (nfe-wa-panel.js). */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
@media (max-width: 1023px) {
  button, a, label, select, [role="button"], [onclick] { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
  #main-content { overscroll-behavior-y: contain; }
  body:not(.nfe-rail-m) #sidebar { padding-top: env(safe-area-inset-top); padding-bottom: env(safe-area-inset-bottom); }
  /* menu em pílula afastado do notch e da barra de gestos */
  body.nfe-rail-m #sidebar { top: calc(8px + env(safe-area-inset-top)) !important; bottom: calc(8px + env(safe-area-inset-bottom)) !important; left: calc(8px + env(safe-area-inset-left)) !important; }
  body.nfe-rail-m #app-container > .lg\:ml-64 { margin-left: calc(76px + env(safe-area-inset-left)) !important; }
}
@media (max-width: 767px) {
  #main-content { padding: 16px 14px calc(28px + env(safe-area-inset-bottom)) !important; }
  #app-container > .lg\:ml-64 > header { padding-top: max(10px, env(safe-area-inset-top)) !important; padding-bottom: 10px !important; padding-left: 14px !important; padding-right: 14px !important; }
  /* campos com 16px: o iPhone não dá zoom ao tocar para digitar */
  input:not([type="checkbox"]):not([type="radio"]):not([type="range"]), select, textarea { font-size: 16px !important; }
  #main-content input, #main-content select, #main-content textarea { max-width: 100%; }
  /* grades e cartões nunca passam da largura da tela (textos longos quebram) */
  #main-content { overflow-wrap: break-word; }
  #main-content .grid > *, #main-content .flex > .flex-1 { min-width: 0; }
  /* filtros e buscas em linha: quebram para a linha de baixo em vez de sumir na lateral */
  #main-content .flex:not(.overflow-x-auto):not(.wa2-composer):has(> select, > input:not([type="checkbox"]):not([type="radio"])) { flex-wrap: wrap; }
  #main-content .flex:not(.overflow-x-auto):not(.wa2-composer):has(> select, > input:not([type="checkbox"]):not([type="radio"])) > :is(select, input) { flex: 1 1 140px; min-width: 0; width: auto; }
  /* abas e listas que rolam de lado: deslizar suave, sem barra */
  #main-content .overflow-x-auto, #main-content .rcv-tabs { scrollbar-width: none; -webkit-overflow-scrolling: touch; overscroll-behavior-x: contain; }
  #main-content .overflow-x-auto::-webkit-scrollbar, #main-content .rcv-tabs::-webkit-scrollbar { display: none; }
  #main-content .overflow-x-auto > button, #main-content .rcv-tabs > button { flex-shrink: 0; white-space: nowrap; }
  /* janelas: cabem na tela e acima do teclado */
  #modal-container > div:last-child { padding: 10px !important; }
  #modal-content { max-height: calc(var(--nfe-vvh, 100dvh) - 20px - env(safe-area-inset-top) - env(safe-area-inset-bottom)) !important; border-radius: 18px !important; overscroll-behavior: contain; }
  #toast-container { left: 12px !important; right: 12px !important; bottom: calc(12px + env(safe-area-inset-bottom)) !important; }
  /* Marketing: cartões de canais cabem lado a lado */
  #main-content .mk-g6 { grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)) !important; }
  #main-content .mk-g6 > * { min-width: 0; }

  /* ---------- WhatsApp no celular: conversa em tela cheia, como no app do WhatsApp */
  .wa2.wa2-open {
    position: fixed; left: 0; right: 0; top: var(--nfe-vvt, 0px); height: var(--nfe-vvh, 100dvh) !important; min-height: 0 !important;
    z-index: 45; margin: 0; border: 0 !important; border-radius: 0 !important; box-shadow: none !important;
  }
  body:has(.wa2.wa2-open) { overflow: hidden; }
  .wa2-page:has(.wa2-open), .wa2-page:has(.wa2-open) .nfe-enter { animation: none !important; transform: none !important; } /* a animação de entrada prenderia a tela cheia */
  .wa2.wa2-open .wa2-chat-head { padding-top: calc(10px + env(safe-area-inset-top)); padding-left: calc(12px + env(safe-area-inset-left)); padding-right: calc(12px + env(safe-area-inset-right)); }
  .wa2.wa2-open .wa2-composer { padding-left: calc(10px + env(safe-area-inset-left)); padding-right: calc(10px + env(safe-area-inset-right)); }
  .wa2-msgs { overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
  .wa2-composer textarea { min-height: 44px; padding: 11px 16px; }
  .wa2-send, .wa2-icon { width: 44px; height: 44px; }
  .wa2-thread { min-height: 64px; padding: 12px 10px; }
  .wa2-threads { overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
  .wa2-bubble { max-width: 88%; }
}
/* celulares estreitos (até 400px): menu um pouco mais fino, sobra mais tela para o conteúdo */
@media (max-width: 400px) {
  body.nfe-rail-m #sidebar { width: 54px !important; left: calc(6px + env(safe-area-inset-left)) !important; border-radius: 22px; }
  body.nfe-rail-m #sidebar-nav { padding: 4px 7px !important; }
  body.nfe-rail-m #sidebar .sidebar-link, body.nfe-rail-m #sidebar > div:last-child button { width: 40px !important; height: 40px; min-height: 40px; }
  body.nfe-rail-m #sidebar .sidebar-link.active::before { left: -7px !important; }
  body.nfe-rail-m #sidebar .nfe-logo-sidebar { width: 26px !important; height: 26px !important; }
  body.nfe-rail-m #app-container > .lg\:ml-64 { margin-left: calc(64px + env(safe-area-inset-left)) !important; }
  #main-content { padding-left: 12px !important; padding-right: 12px !important; }
  #main-content .grid > :is(.p-5, .p-6) { padding: 14px !important; }
  #main-content .grid { gap: 10px; }
}

/* ---------------------------------------------------------------- celular, 2ª rodada (14/11/2026): nada cortado na lateral, WhatsApp com cara de app */
@media (max-width: 767px) {
  /* abas (WhatsApp | Instagram e Facebook | …, abas de cliente, loja…): viram pílulas que quebram linha, nunca ficam cortadas */
  #main-content .flex:has(> .tab-active):has(> .tab-inactive) { flex-wrap: wrap; overflow: visible !important; gap: 6px !important; border-bottom: 0 !important; margin-bottom: 14px !important; padding: 0 !important; }
  #main-content .flex:has(> .tab-active):has(> .tab-inactive) > :is(.tab-active, .tab-inactive) {
    flex-shrink: 0; border: 0 !important; border-radius: 999px !important; padding: 7px 14px !important; margin: 0 !important; font-size: 13px !important; line-height: 1.2; white-space: nowrap;
    background: rgb(var(--nfe-100)); color: rgb(var(--nfe-600)) !important;
  }
  #main-content .flex:has(> .tab-active):has(> .tab-inactive) > .tab-active { background: rgb(var(--nfe-900)) !important; color: rgb(var(--nfe-white)) !important; }

  /* WhatsApp: o título repetido some (a aba já diz WhatsApp) e os botões ficam numa linha só, compactos */
  .wa2-page > div:first-child { margin-bottom: 10px !important; }
  .wa2-page > div:first-child > div:first-child { display: none; }
  .wa2-page > div:first-child > div:last-child { flex-wrap: nowrap !important; overflow: visible !important; gap: 8px !important; width: 100%; margin: 0 !important; padding: 0 !important; }
  .wa2-page > div:first-child > div:last-child > button { flex-shrink: 0; width: 40px; height: 40px; padding: 0 !important; font-size: 0 !important; display: inline-flex; align-items: center; justify-content: center; border-radius: 12px !important; }
  .wa2-page > div:first-child > div:last-child > button i { font-size: 15px !important; margin: 0 !important; }
  .wa2-page .wa2-conn-slot { flex: 1; min-width: 0; display: flex; }
  .wa2-page .wa2-conn { width: 100%; min-width: 0; height: 40px; font-size: 0; justify-content: flex-start; }
  .wa2-page .wa2-conn::after { content: "Conectado"; font-size: 13px; white-space: nowrap; }
  .wa2-page .wa2-conn.off::after { content: "Desconectado"; }
  /* lista de conversas: menos moldura, mais conversas na tela */
  .wa2 { border-radius: 18px !important; }
  .wa2-side-head { padding: 12px 12px 6px !important; gap: 10px !important; }
  .wa2-side-title h2 { font-size: 17px; }
  .wa2-threads { padding: 2px 4px 10px !important; }
  .wa2-thread { gap: 10px !important; padding: 10px 8px !important; }
  .wa2-thread .nfe-wa-del { display: none !important; } /* apagar sem querer no toque: o Excluir fica dentro da conversa */
  .wa2-thread-body, .wa2-thread .min-w-0 { min-width: 0; }
  body:has(.wa2.wa2-open) #toast-container { bottom: auto !important; top: calc(12px + env(safe-area-inset-top)) !important; } /* avisos no topo: não cobrem o campo de digitar */
  body:has(.wa2.wa2-open) .nfe-appbar { display: none !important; } /* avisos do app (instalar/atualizar) voltam ao sair da conversa */
}
