/* ─── Caixa de E-mails Unificada ─── */

body:has(#viewEmails.active) {
  overflow: hidden;
}
body:has(#viewEmails.active) .main-content {
  overflow: hidden;
  height: 100vh;
  min-height: 0;
}

#viewEmails {
  overflow: hidden;
  padding: 0;
  flex: 1;
  min-height: 0;
}

/* Corpo: 3 colunas (sidebar + lista + painel) */
.embox-body {
  flex: 1;
  display: flex;
  overflow: hidden;
  min-height: 0;
  position: relative;
}

/* ─── SIDEBAR (coluna A) ─── */
.embox-sidebar {
  width: 200px;
  flex: none;
  border-right: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 8px;
  overflow-y: auto;
  z-index: 5;
}

.embox-sidebar-novo {
  display: flex;
  align-items: center;
  gap: 7px;
  width: 100%;
  padding: 9px 12px;
  border-radius: var(--radius);
  border: none;
  background: var(--accent);
  color: var(--accent-contrast, #fff);
  font-size: .83rem;
  font-weight: 600;
  cursor: pointer;
  margin-bottom: 6px;
  transition: filter .15s;
}
.embox-sidebar-novo:hover { filter: brightness(1.08); }
.embox-sidebar-novo svg { width: 14px; height: 14px; flex: none; }

/* Pastas */
.embox-sidebar-pastas {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

/* Tabs reestilizados como itens de sidebar */
.embox-tab {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 10px;
  border-radius: 7px;
  border: none;
  background: none;
  font-size: .82rem;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
  text-align: left;
  transition: background .12s, color .12s;
}
.embox-tab:hover { background: var(--surface-raised); color: var(--text); }
.embox-tab.active { background: color-mix(in srgb, var(--accent) 12%, var(--surface)); color: var(--accent); font-weight: 600; }
.embox-tab svg { width: 14px; height: 14px; flex: none; }

.embox-sidebar-unread {
  margin-left: auto;
  font-size: .7rem;
  font-weight: 700;
  background: var(--accent);
  color: var(--accent-contrast, #fff);
  border-radius: 999px;
  padding: 1px 6px;
  display: none;
}
.embox-sidebar-unread:not(:empty) { display: inline-block; }

/* Label de seção */
.embox-sidebar-label {
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .06em;
  color: var(--text-muted);
  padding: 10px 10px 4px;
}

/* Contas conectadas */
.embox-sidebar-contas {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

/* Neg-pills viram itens de conta */
.embox-neg-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 7px 10px;
  border-radius: 7px;
  border: none;
  background: none;
  font-size: .8rem;
  font-weight: 400;
  color: var(--text-muted);
  cursor: pointer;
  text-align: left;
  transition: background .12s, color .12s;
}
.embox-neg-pill:hover { background: var(--surface-raised); color: var(--text); }
.embox-neg-pill.active { background: color-mix(in srgb, var(--accent) 10%, var(--surface)); color: var(--text); font-weight: 500; }

.embox-acc-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex: none;
}
.negocio-carbono_zero-dot { background: var(--cz); }
.negocio-tarmac-dot       { background: var(--tm); }
.negocio-elevator-dot     { background: var(--el); }

.embox-acc-info {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}
.embox-acc-nome  { font-size: .8rem; font-weight: 500; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.embox-acc-email { font-size: .68rem; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.embox-neg-pill.active .embox-acc-nome { color: var(--text); }

/* Rodapé da sidebar */
.embox-sidebar-bottom {
  margin-top: auto;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}
.embox-sync-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding: 7px 10px;
  border-radius: 7px;
  border: none;
  background: none;
  font-size: .78rem;
  color: var(--text-muted);
  cursor: pointer;
  transition: background .12s, color .12s;
}
.embox-sync-btn:hover { background: var(--surface-raised); color: var(--text); }
.embox-sync-btn svg { width: 13px; height: 13px; }
.embox-sync-btn.spinning svg { animation: embox-spin .8s linear infinite; }
@keyframes embox-spin { to { transform: rotate(360deg); } }

/* Hamburger (só aparece em telas estreitas) */
.embox-hamburger {
  display: none;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border: none;
  background: none;
  cursor: pointer;
  color: var(--text-muted);
  border-radius: var(--radius);
  transition: background .12s;
}
.embox-hamburger:hover { background: var(--surface-raised); color: var(--text); }
.embox-hamburger svg { width: 16px; height: 16px; }

/* Backdrop mobile */
.embox-sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 74;
}
.embox-sidebar-backdrop.visible { display: block; }

/* Lista (coluna B) */
.embox-list {
  width: 300px;
  min-width: 220px;
  max-width: 360px;
  border-right: 1px solid var(--border);
  flex: none;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Busca fixa no topo da lista */
.embox-search-wrap {
  flex: none;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 1;
}
.embox-search-input {
  width: 100%;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  font-size: .82rem;
  box-sizing: border-box;
}
.embox-search-input:focus { outline: none; border-color: var(--accent); }

#emboxListItens { flex: 1; overflow-y: auto; }

/* Conteúdo (direita) */
.embox-content {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

/* Estados vazios */
.embox-list-vazio,
.embox-content-vazio {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  height: 100%;
  min-height: 180px;
  color: var(--text-muted);
  font-size: .85rem;
}
.embox-content-vazio svg { width: 32px; height: 32px; opacity: .35; }

.embox-loading {
  padding: 20px;
  text-align: center;
  color: var(--text-muted);
  font-size: .85rem;
}

/* ─── Item de lista ─── */
.embox-item {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background .12s;
}
.embox-item:hover { background: var(--surface-raised); }
.embox-item.active { background: color-mix(in srgb, var(--accent) 12%, var(--surface)); border-left: 3px solid var(--accent); }
.embox-item.nao-lido .embox-item-assunto { font-weight: 600; }

.embox-item-top {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 3px;
}
.embox-item-empresa {
  flex: 1;
  font-size: .84rem;
  font-weight: 500;
  color: var(--text);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.embox-item-data {
  font-size: .74rem;
  color: var(--text-muted);
  flex: none;
}
.embox-item-assunto {
  font-size: .8rem;
  color: var(--text-muted);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  margin-bottom: 3px;
}
.embox-item-sub {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: .74rem;
  color: var(--text-muted);
}
.embox-item-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 1px 6px;
  border-radius: 999px;
  font-size: .7rem;
  font-weight: 500;
}
.embox-item-badge--nao-lido { background: rgba(99,102,241,.15); color: #818cf8; }
.embox-item-badge--vinc { background: rgba(34,197,94,.12); color: #4ade80; }

/* ─── Painel de conteúdo ─── */
.embox-msg-header {
  padding: 18px 22px 14px;
  border-bottom: 1px solid var(--border);
  flex: none;
}
.embox-msg-assunto {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 8px;
}
.embox-msg-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  font-size: .8rem;
  color: var(--text-muted);
  align-items: center;
}
.embox-msg-meta strong { color: var(--text); }
.embox-msg-acoes {
  margin-top: 10px;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
}
.embox-acoes-grupo {
  display: flex;
  gap: 2px;
}
.embox-btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  transition: background .1s, color .1s;
  padding: 0;
  border-radius: 6px;
}
.embox-btn-icon:hover { background: color-mix(in srgb, var(--text) 8%, transparent); color: var(--text); }
.embox-btn-icon svg { width: 15px; height: 15px; stroke-width: 1.8; }
.embox-btn-icon--danger:hover { background: color-mix(in srgb, #ef4444 10%, transparent); color: #ef4444; }
.embox-msg-body {
  flex: 1;
  padding: 18px 22px;
  font-size: .875rem;
  line-height: 1.7;
  color: var(--text);
  overflow-y: auto;
  min-height: 0;
}
.embox-msg-body:has(> iframe) {
  padding: 0;
  background: #fff;
  border-radius: 0 0 var(--radius) var(--radius);
}
.embox-iframe {
  width: 100%;
  min-height: 400px;
  height: auto;
  border: none;
  display: block;
}
.embox-anexos {
  padding: 10px 22px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.embox-anexo-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: .8rem;
  color: var(--text);
  text-decoration: none;
  background: var(--surface);
  cursor: pointer;
}
.embox-anexo-chip:hover { background: var(--surface-raised); }
.embox-anexo-chip svg { width: 13px; height: 13px; }

/* ─── Bulk actions ─── */
/* ─── Chips de filtro lido/data ─── */
.embox-filtros-bar {
  flex: none;
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  scrollbar-width: none;
}
.embox-filtros-bar::-webkit-scrollbar { display: none; }
.embox-filtro-chip {
  flex: none;
  padding: 3px 10px;
  font-size: .74rem;
  font-weight: 500;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-raised);
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
  transition: background .12s, color .12s, border-color .12s;
}
.embox-filtro-chip:hover { color: var(--text); border-color: var(--accent); }
.embox-filtro-chip.active { background: var(--accent); border-color: var(--accent); color: #fff; }

.embox-bulk-bar {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.embox-bulk-count { font-size: .8rem; font-weight: 600; color: var(--text); flex: 1; }
.embox-bulk-acoes { display: flex; gap: 2px; }


.embox-item.bulk-checked,
.embox-thread.bulk-checked { background: color-mix(in srgb, var(--accent) 14%, var(--surface)); border-left: 3px solid var(--accent); }
.embox-list--bulk-mode .embox-item,
.embox-list--bulk-mode .embox-item--nv { cursor: default; user-select: none; }

/* Modal vincular bulk */
.embox-bulk-modal {
  position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 300;
  display: flex; align-items: center; justify-content: center;
}
.embox-bulk-modal-inner {
  background: var(--surface); border-radius: var(--radius);
  padding: 20px; width: 360px; max-width: 90vw;
  display: flex; flex-direction: column; gap: 12px;
}
.embox-bulk-modal-header {
  display: flex; align-items: center; justify-content: space-between;
  font-size: .9rem;
}
.embox-bulk-modal-inner input {
  padding: 7px 10px; border: 1px solid var(--border);
  border-radius: var(--radius); background: var(--bg);
  color: var(--text); font-size: .83rem; width: 100%; box-sizing: border-box;
}

.embox-thread-empresa {
  font-size: .72rem;
  color: var(--accent);
  margin-top: 2px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  opacity: .85;
}
.embox-thread-empresa--nv {
  color: var(--text-muted);
  opacity: .6;
}
.embox-thread-bottom {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
  min-height: 16px;
}
.embox-thread-bottom .embox-thread-empresa { margin-top: 0; }
.embox-thread-neg {
  font-size: .68rem;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 999px;
  flex: none;
}
.embox-thread-neg.negocio-carbono_zero { background: var(--cz); color: var(--cz-fg); }
.embox-thread-neg.negocio-tarmac       { background: var(--tm); color: var(--tm-fg); }
.embox-thread-neg.negocio-elevator     { background: var(--el); color: var(--el-fg); }
.embox-thread-clip {
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  flex: none;
}
.embox-thread-clip svg { width: 11px; height: 11px; }
.embox-thread-msg { display: flex; align-items: center; gap: 6px; }
.embox-thread-msg .embox-thread-clip svg { width: 10px; height: 10px; }

/* ── Novo composer ── */
.embox-novo { display:flex; flex-direction:column; height:100%; overflow:hidden; }
.embox-novo-header { display:flex; align-items:center; justify-content:space-between; padding:14px 20px 12px; border-bottom:1px solid var(--border); flex:none; }
.embox-novo-titulo { font-size:.9rem; font-weight:600; color:var(--text); display:flex; align-items:center; gap:7px; }
.embox-novo-titulo svg { width:15px; height:15px; }
.embox-novo-fechar { background:none; border:none; cursor:pointer; color:var(--text-muted); display:flex; padding:4px; border-radius:var(--radius); transition:background .1s; }
.embox-novo-fechar:hover { background:var(--surface-raised); color:var(--text); }
.embox-novo-fechar svg { width:16px; height:16px; }
.embox-novo-form { flex:none; border-bottom:1px solid var(--border); }
.embox-nf-linha { display:flex; align-items:center; min-height:44px; border-bottom:1px solid var(--border); padding:0 20px; }
.embox-nf-linha:last-child { border-bottom:none; }
.embox-nf-label { font-size:.77rem; color:var(--text-muted); width:52px; flex:none; font-weight:500; }
.embox-nf-select-wrap { flex:1; display:flex; align-items:center; position:relative; }
.embox-nf-select { flex:1; appearance:none; background:transparent; border:none; outline:none; color:var(--text); font-size:.83rem; padding:0 20px 0 0; cursor:pointer; }
.embox-nf-chevron { position:absolute; right:0; pointer-events:none; color:var(--text-muted); display:flex; }
.embox-nf-chevron svg { width:14px; height:14px; }
.embox-nf-cc-toggle { display:flex; gap:6px; flex:none; padding-left:8px; }
.embox-novo-cc-btn { background:none; border:1px solid var(--border); border-radius:var(--radius); color:var(--text-muted); font-size:.74rem; cursor:pointer; padding:2px 8px; transition:border-color .1s,color .1s; }
.embox-novo-cc-btn:hover { border-color:var(--accent); color:var(--accent); }
.embox-nf-assunto { flex:1; border:none; outline:none; background:transparent; color:var(--text); font-size:.83rem; padding:0; }
.embox-nf-linha--assunto { min-height:46px; }
.embox-novo-corpo { flex:1; border:none !important; border-radius:0 !important; outline:none; background:var(--bg); color:var(--text); font-size:.85rem; line-height:1.65; padding:16px 20px; min-height:0; overflow-y:auto; }
.embox-novo-corpo:empty::before { content:attr(data-placeholder); color:var(--text-muted); pointer-events:none; }
/* Toolbar dentro do novo composer: sem borda lateral/topo própria, herda do form */
#emboxNovoToolbarSlot .embox-toolbar { border-radius:0; border-left:none; border-right:none; margin:0; }
.embox-novo-corpo p   { margin: 0; }
.embox-novo-corpo div { margin: 0; min-height: 1.4em; }
.embox-novo-corpo br  { display: block; }
.embox-assinatura { color:#555; font-size:.83rem; }
.embox-assinatura a { color:#1a73e8; }
.embox-novo-footer { flex:none; display:flex; align-items:center; gap:8px; padding:10px 20px; border-top:1px solid var(--border); }
.embox-novo-descartar { background:none; border:none; color:var(--text-muted); font-size:.82rem; cursor:pointer; padding:4px 8px; border-radius:var(--radius); margin-left:auto; transition:color .1s; }
.embox-novo-descartar:hover { color:var(--text); }

/* ── Chips e autocomplete ── */
.embox-chips-inline { flex:1; display:flex; flex-wrap:wrap; gap:4px; align-items:center; min-height:36px; cursor:text; padding:4px 0; }
.embox-chip { display:inline-flex; align-items:center; gap:3px; padding:2px 8px 2px 10px; background:color-mix(in srgb,var(--accent) 10%,var(--surface)); border:1px solid color-mix(in srgb,var(--accent) 20%,var(--border)); border-radius:999px; font-size:.78rem; color:var(--text); }
.embox-chip button { background:none; border:none; cursor:pointer; color:var(--text-muted); padding:0; display:flex; }
.embox-chip button svg { width:11px; height:11px; }
.embox-chips-input { border:none; outline:none; background:transparent; color:var(--text); font-size:.83rem; min-width:100px; flex:1; }
.embox-ac-drop { position:absolute; left:0; right:0; top:calc(100% + 2px); z-index:50; background:var(--surface); border:1px solid var(--border); border-radius:var(--radius); box-shadow:0 6px 20px rgba(0,0,0,.2); max-height:240px; overflow-y:auto; }
.embox-ac-item { padding:9px 14px; cursor:pointer; display:flex; align-items:center; gap:8px; font-size:.82rem; }
.embox-ac-item:hover { background:var(--surface-raised); }
.embox-ac-nome { font-weight:500; color:var(--text); flex:none; max-width:40%; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.embox-ac-empresa { color:var(--text-muted); font-size:.76rem; }
.embox-ac-email { color:var(--text-muted); font-size:.74rem; margin-left:auto; white-space:nowrap; }
.embox-ac-badge { font-size:.68rem; padding:1px 5px; border-radius:999px; }

/* ── FAB mobile ── */
.embox-fab { display:none; position:absolute; bottom:20px; right:16px; z-index:10; width:48px; height:48px; border-radius:50%; background:var(--accent); color:var(--accent-contrast); border:none; cursor:pointer; box-shadow:0 4px 14px rgba(0,0,0,.25); align-items:center; justify-content:center; transition:transform .15s; }
.embox-fab:hover { transform:scale(1.07); }
.embox-fab svg { width:20px; height:20px; }
@media (max-width:640px) { .embox-fab { display:flex; } }

/* ── Responsive: sidebar vira drawer em telas estreitas ── */
@media (max-width: 900px) {
  .embox-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 220px;
    transform: translateX(-100%);
    transition: transform .25s ease;
    z-index: 75;
    box-shadow: 4px 0 20px rgba(0,0,0,.25);
  }
  .embox-sidebar.open { transform: translateX(0); }
  .embox-hamburger { display: flex; }
  .embox-list { width: 100%; max-width: none; min-width: 0; }
}

/* ── Toast contato criado ── */
.embox-toast-contato { position:fixed; bottom:72px; right:16px; z-index:250; background:var(--surface); border:1px solid var(--border); border-radius:var(--radius); box-shadow:0 4px 16px rgba(0,0,0,.15); padding:10px 12px; display:flex; align-items:center; gap:8px; font-size:.82rem; color:var(--text); max-width:320px; animation:embox-toast-in .25s ease; }
.embox-toast-contato.embox-toast-saindo { animation:embox-toast-out .3s ease forwards; }
.embox-toast-ver { background:none; border:1px solid var(--border); border-radius:var(--radius); padding:2px 8px; font-size:.76rem; cursor:pointer; color:var(--accent); }
.embox-toast-close { background:none; border:none; cursor:pointer; color:var(--text-muted); display:flex; padding:0; margin-left:auto; }
.embox-toast-close svg { width:13px; height:13px; }
@keyframes embox-toast-in  { from{opacity:0;transform:translateY(8px)} to{opacity:1;transform:none} }
@keyframes embox-toast-out { to{opacity:0;transform:translateY(8px)} }
