@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
  --navy-900: #101820;
  --navy-800: #17232E;
  --navy-700: #223142;
  --teal-500: #0E8388;
  --teal-600: #0B6C70;
  --amber-500: #E2984B;
  --gray-50: #F4F5F7;
  --white: #FFFFFF;
  --ink-900: #1B232C;
  --ink-500: #5B6572;
  --ink-300: #8A93A0;
  --line-200: #E1E4E8;
  --danger-500: #D64545;
  --danger-50: #FBEAEA;
  --success-500: #2E9E5B;
  --success-50: #E9F7EF;
  --radius: 8px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: 'Inter', -apple-system, Segoe UI, sans-serif;
  color: var(--ink-900);
  background: var(--gray-50);
  font-size: 14px;
  line-height: 1.5;
}

a { color: var(--teal-600); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { font-weight: 600; margin: 0 0 16px; color: var(--ink-900); }
h1 { font-size: 20px; }
h2 { font-size: 17px; }

/* ---------- Login ---------- */

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--navy-900);
}

.login-card {
  width: 360px;
  background: var(--white);
  border-radius: var(--radius);
  padding: 40px 32px;
}

.login-card .marca {
  font-weight: 700;
  font-size: 20px;
  color: var(--navy-900);
  margin-bottom: 4px;
}

.login-card .subtitulo {
  color: var(--ink-500);
  font-size: 13px;
  margin-bottom: 28px;
}

.login-card .barra-teal {
  width: 40px;
  height: 4px;
  background: var(--teal-500);
  border-radius: 2px;
  margin-bottom: 16px;
}

.logo-area {
  margin-bottom: 30px;
  display: flex;
  justify-content: center;
}

.logo-image {
  width: 240px;
  height: 60px;
  object-fit: contain;
  background-color: #000;
  border-radius: 12px;
  padding: 8px 12px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
  transition: var(--transition);
  border: 4px solid rgb(255, 255, 255);
}

.logo-image:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
  border-color: var(--primary-color);
}

.logo-container {
  padding: 25px 20px;
  text-align: center;
  background: linear-gradient(to bottom, rgba(0, 0, 0, 0.2), transparent);
}

.logo_circular {
  width: 150px;
  height: 150px;
  object-fit: contain;
  border-radius: 50%;
  transition: transform var(--transition-speed) ease;
  border: 3px solid ;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

/* ---------- Shell (sidebar + topbar + iframe) ---------- */

.shell {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

.sidebar {
  width: 232px;
  flex-shrink: 0;
  background: var(--navy-900);
  color: #C7CFD8;
  display: flex;
  flex-direction: column;
}

.sidebar .marca {
  padding: 20px 20px 16px;
  font-weight: 700;
  font-size: 16px;
  color: var(--white);
  border-bottom: 1px solid var(--navy-700);
}

.sidebar .marca span { color: var(--teal-500); }

.sidebar nav {
  flex: 1;
  overflow-y: auto;
  padding: 12px 0;
}

.sidebar .grupo-titulo {
  padding: 16px 20px 6px;
  font-size: 11px;
  color: var(--ink-300);
  letter-spacing: 0.02em;
}

.sidebar button.item-grupo {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px 10px 18px;
  background: none;
  border: none;
  border-left: 3px solid transparent;
  color: #C7CFD8;
  font-size: 13.5px;
  font-family: inherit;
  cursor: pointer;
  text-align: left;
}

.sidebar button.item-grupo .item-grupo-label {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar button.item-grupo:hover { background: var(--navy-800); }

.sidebar button.item-grupo .seta {
  transition: transform 0.15s;
  font-size: 11px;
  color: var(--ink-300);
}

.sidebar .submenu.aberto + button.item-grupo .seta,
.sidebar button.item-grupo[aria-expanded="true"] .seta {
  transform: rotate(90deg);
}

.sidebar .submenu {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.2s ease;
}

.sidebar .submenu.aberto {
  max-height: 600px;
}

.sidebar .submenu a.item {
  padding-left: 38px;
  font-size: 13px;
}

.icone-menu { flex-shrink: 0; }

.sidebar a.item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px 10px 18px;
  color: #C7CFD8;
  border-left: 3px solid transparent;
  font-size: 13.5px;
}

.sidebar a.item {
  display: block;
  padding: 10px 20px 10px 18px;
  color: #C7CFD8;
  border-left: 3px solid transparent;
  font-size: 13.5px;
}

.sidebar a.item:hover {
  background: var(--navy-800);
  text-decoration: none;
}

.sidebar a.item.ativo {
  background: var(--navy-800);
  border-left-color: var(--teal-500);
  color: var(--white);
}

.topbar {
  height: 56px;
  flex-shrink: 0;
  background: var(--white);
  border-bottom: 1px solid var(--line-200);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 12px;
}

.topbar .usuario {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 13px;
  color: var(--ink-500);
  margin-left: auto;
}

.topbar .usuario strong { color: var(--ink-900); }

.topbar a.sair {
  color: var(--danger-500);
  font-size: 13px;
}

.btn-hamburguer {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
  color: var(--ink-900);
}
.btn-hamburguer span {
  display: block;
  width: 20px;
  height: 2px;
  background: var(--ink-900);
  margin: 4px 0;
}

.fundo-sidebar-mobile {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(16, 24, 32, 0.45);
  z-index: 20;
}

.area-principal {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

iframe#conteudo {
  flex: 1;
  border: none;
  width: 100%;
  background: var(--gray-50);
}

/* ---------- Componentes usados dentro das telas (iframe) ---------- */

.pagina { padding: 24px; }

.cabecalho-pagina {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: none;
  border-radius: var(--radius);
  padding: 9px 16px;
  font-size: 13.5px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
}

.btn-primario { background: var(--teal-500); color: var(--white); }
.btn-primario:hover { background: var(--teal-600); }

.btn-secundario { background: var(--white); color: var(--ink-900); border: 1px solid var(--line-200); }
.btn-secundario:hover { background: var(--gray-50); }

.btn-perigo { background: var(--white); color: var(--danger-500); border: 1px solid var(--danger-500); }
.btn-perigo:hover { background: var(--danger-50); }

.cartao {
  background: var(--white);
  border: 1px solid var(--line-200);
  border-radius: var(--radius);
  overflow-x: auto;
}

table.tabela {
  width: 100%;
  border-collapse: collapse;
}

table.tabela th {
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-500);
  padding: 12px 16px;
  border-bottom: 1px solid var(--line-200);
}

table.tabela td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--line-200);
  font-size: 13.5px;
}

table.tabela tr:last-child td { border-bottom: none; }
table.tabela tr:hover td { background: var(--gray-50); }

.tag {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
}

.tag-ativo { background: var(--success-50); color: var(--success-500); }
.tag-inativo { background: var(--danger-50); color: var(--danger-500); }

.acoes-linha { display: flex; gap: 14px; }
.acoes-linha a { font-size: 13px; margin-right: 14px; }
.acoes-linha a:last-child { margin-right: 0; }
.acoes-linha a.excluir { color: var(--danger-500); }

/* Formulários */

.campo { margin-bottom: 16px; }
.campo label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 6px;
  color: var(--ink-900);
}

.campo input[type="text"],
.campo input[type="email"],
.campo input[type="password"],
.campo select,
.campo textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--line-200);
  border-radius: var(--radius);
  font-size: 13.5px;
  font-family: inherit;
  color: var(--ink-900);
  background: var(--white);
}

.campo input:focus,
.campo select:focus,
.campo textarea:focus {
  outline: 2px solid var(--teal-500);
  outline-offset: -1px;
  border-color: var(--teal-500);
}

.linha-form {
  display: flex;
  gap: 16px;
}
.linha-form .campo { flex: 1; }

.alerta {
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 13px;
  margin-bottom: 16px;
}
.alerta-erro { background: var(--danger-50); color: var(--danger-500); }
.alerta-sucesso { background: var(--success-50); color: var(--success-500); }

/* Matriz de permissões (tela de Perfis) */

table.matriz-permissoes th, table.matriz-permissoes td {
  text-align: center;
}
table.matriz-permissoes td:first-child,
table.matriz-permissoes th:first-child {
  text-align: left;
}
table.matriz-permissoes input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--teal-500);
}

/* Modal simples usado nas telas de cadastro */

.modal-fundo {
  position: fixed;
  inset: 0;
  background: rgba(16, 24, 32, 0.45);
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 20px;
  overflow-y: auto;
}
.modal-fundo.aberto { display: flex; }

.modal-caixa {
  background: var(--white);
  border-radius: var(--radius);
  width: 100%;
  max-width: 640px;
}

.modal-cabecalho {
  padding: 18px 24px;
  border-bottom: 1px solid var(--line-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-corpo { padding: 24px; max-height: 70vh; overflow-y: auto; }
.modal-rodape {
  padding: 16px 24px;
  border-top: 1px solid var(--line-200);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.fechar-modal {
  background: none;
  border: none;
  font-size: 20px;
  color: var(--ink-500);
  cursor: pointer;
  line-height: 1;
}

/* ---------- Responsivo ---------- */

@media (max-width: 880px) {
  .btn-hamburguer { display: inline-block; }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 30;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    box-shadow: 2px 0 12px rgba(0,0,0,0.2);
  }

  .shell.menu-aberto .sidebar {
    transform: translateX(0);
  }

  .shell.menu-aberto .fundo-sidebar-mobile {
    display: block;
  }

  .topbar .usuario span { display: none; }

  .pagina { padding: 16px; }

  .cabecalho-pagina {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
  .cabecalho-pagina .btn { width: 100%; justify-content: center; }

  .linha-form {
    flex-direction: column;
    gap: 0;
  }
  .linha-form .campo { flex: 1 1 auto !important; }

  table.tabela th, table.tabela td {
    padding: 10px 12px;
    white-space: nowrap;
  }

  .modal-fundo { padding: 0; }
  .modal-caixa { max-width: 100%; min-height: 100vh; border-radius: 0; }

  .login-card { width: 100%; max-width: 340px; padding: 32px 24px; }
}

@media (max-width: 480px) {
  .topbar { padding: 0 12px; }
  .sidebar { width: 82vw; max-width: 280px; }
}

/* ---------- Dashboard ---------- */

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.kpi-card {
  background: var(--white);
  border: 1px solid var(--line-200);
  border-radius: var(--radius);
  padding: 18px 20px;
}

.kpi-card .kpi-valor {
  font-size: 28px;
  font-weight: 700;
  color: var(--ink-900);
  line-height: 1.1;
}

.kpi-card .kpi-label {
  font-size: 12.5px;
  color: var(--ink-500);
  margin-top: 6px;
}

.kpi-card.kpi-alerta .kpi-valor { color: var(--danger-500); }

.dash-grid {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 20px;
  margin-bottom: 24px;
  align-items: start;
}

.dash-card {
  background: var(--white);
  border: 1px solid var(--line-200);
  border-radius: var(--radius);
  padding: 20px;
}

.dash-card h2 {
  font-size: 15px;
  margin-bottom: 16px;
}

.barra-status-linha {
  margin-bottom: 14px;
}
.barra-status-linha:last-child { margin-bottom: 0; }

.barra-status-topo {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  margin-bottom: 6px;
}
.barra-status-topo .nome { display: flex; align-items: center; gap: 8px; }
.barra-status-topo .ponto {
  width: 9px; height: 9px; border-radius: 50%; display: inline-block;
}
.barra-status-topo .contagem { color: var(--ink-500); font-weight: 500; }

.barra-status-trilho {
  background: var(--gray-50);
  border-radius: 6px;
  height: 8px;
  overflow: hidden;
}
.barra-status-preenchida {
  height: 100%;
  border-radius: 6px;
}

.lista-recente { display: flex; flex-direction: column; }
.lista-recente-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line-200);
  font-size: 13.5px;
}
.lista-recente-item:last-child { border-bottom: none; padding-bottom: 0; }
.lista-recente-item:first-child { padding-top: 0; }
.lista-recente-item .principal { min-width: 0; }
.lista-recente-item .principal .titulo { font-weight: 500; color: var(--ink-900); }
.lista-recente-item .principal .sub {
  color: var(--ink-500);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.certificado-alerta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--line-200);
  font-size: 13.5px;
}
.certificado-alerta:last-child { border-bottom: none; }

@media (max-width: 1100px) {
  .kpi-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 880px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .dash-grid { grid-template-columns: 1fr; }
}
/* ---------- Chat / Atendimento WhatsApp ---------- */

.chat-pagina {
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--gray-50);
}

.chat-kpis {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  padding: 20px 20px 0;
  flex-shrink: 0;
}

.chat-kpi {
  background: var(--white);
  border: 1px solid var(--line-200);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.chat-kpi .valor { font-size: 22px; font-weight: 700; }
.chat-kpi .label { font-size: 12px; color: var(--ink-500); margin-top: 2px; }
.chat-kpi.cor-ura .valor { color: var(--ink-500); }
.chat-kpi.cor-aguardando .valor { color: var(--amber-500); }
.chat-kpi.cor-atendimento .valor { color: var(--teal-600); }
.chat-kpi.cor-finalizado .valor { color: var(--success-500); }

.chat-corpo {
  flex: 1;
  display: flex;
  min-height: 0;
  padding: 16px 20px 20px;
  gap: 16px;
}

.chat-lista {
  width: 320px;
  flex-shrink: 0;
  background: var(--white);
  border: 1px solid var(--line-200);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.chat-lista-busca { padding: 12px; border-bottom: 1px solid var(--line-200); }
.chat-lista-busca input {
  width: 100%; padding: 8px 12px; border: 1px solid var(--line-200);
  border-radius: var(--radius); font-size: 13px; font-family: inherit;
}

.chat-lista-itens { flex: 1; overflow-y: auto; }

.chat-item {
  display: flex;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line-200);
  cursor: pointer;
  text-decoration: none;
  color: inherit;
}
.chat-item:hover { background: var(--gray-50); text-decoration: none; }
.chat-item.ativo { background: #E7F3F3; }

.chat-avatar {
  width: 38px; height: 38px; border-radius: 50%;
  background: var(--navy-800); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 600; flex-shrink: 0;
}

.chat-item-info { min-width: 0; flex: 1; }
.chat-item-topo { display: flex; justify-content: space-between; gap: 6px; }
.chat-item-nome { font-size: 13.5px; font-weight: 600; color: var(--ink-900); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-item-hora { font-size: 11px; color: var(--ink-500); flex-shrink: 0; }
.chat-item-preview { font-size: 12.5px; color: var(--ink-500); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.chat-item-status { margin-top: 4px; }

.chat-thread-wrap {
  flex: 1;
  background: var(--white);
  border: 1px solid var(--line-200);
  border-radius: var(--radius);
  overflow: hidden;
}
.chat-thread-wrap iframe { width: 100%; height: 100%; border: none; }

/* Dentro do thread.php */
.thread-pagina { height: 100vh; display: flex; flex-direction: column; background: #EDEEE6; }
.thread-cabecalho {
  flex-shrink: 0; background: var(--white); border-bottom: 1px solid var(--line-200);
  padding: 12px 18px; display: flex; align-items: center; gap: 12px;
}
.thread-cabecalho .nome { font-weight: 600; font-size: 14px; }
.thread-cabecalho .sub { font-size: 12px; color: var(--ink-500); }

.thread-mensagens { flex: 1; overflow-y: auto; padding: 18px; display: flex; flex-direction: column; gap: 8px; }

.bolha { max-width: 62%; padding: 8px 12px; border-radius: 10px; font-size: 13.5px; position: relative; }
.bolha-recebida { align-self: flex-start; background: var(--white); border-top-left-radius: 2px; }
.bolha-enviada { align-self: flex-end; background: #D9F2E6; border-top-right-radius: 2px; }
.bolha .hora { display: block; font-size: 10.5px; color: var(--ink-500); margin-top: 4px; text-align: right; }
.bolha img, .bolha video { max-width: 100%; border-radius: 6px; display: block; }
.bolha audio { max-width: 240px; }
.bolha .doc-link { display: flex; align-items: center; gap: 8px; color: var(--teal-600); }

.thread-composer {
  flex-shrink: 0; background: var(--white); border-top: 1px solid var(--line-200);
  padding: 10px 14px; display: flex; align-items: center; gap: 10px;
}
.thread-composer input[type="text"] {
  flex: 1; border: 1px solid var(--line-200); border-radius: 20px;
  padding: 10px 16px; font-size: 13.5px; font-family: inherit;
}
.thread-composer button.icone {
  background: none; border: none; cursor: pointer; font-size: 19px;
  color: var(--ink-500); padding: 6px;
}
.thread-composer button.icone.gravando { color: var(--danger-500); }
.thread-composer button.enviar {
  background: var(--teal-500); color: #fff; border: none; border-radius: 50%;
  width: 38px; height: 38px; cursor: pointer; font-size: 16px; flex-shrink: 0;
}

.thread-vazio { flex: 1; display: flex; align-items: center; justify-content: center; color: var(--ink-500); font-size: 14px; }

@media (max-width: 880px) {
  .chat-kpis { grid-template-columns: repeat(2, 1fr); padding: 14px 14px 0; }
  .chat-corpo { padding: 12px 14px 14px; }
  .chat-lista { width: 100%; }
  .chat-thread-wrap { display: none; }
  .chat-pagina.tem-selecao .chat-lista { display: none; }
  .chat-pagina.tem-selecao .chat-thread-wrap { display: block; width: 100%; }
  .chat-pagina.tem-selecao .chat-kpis { display: none; }
  .chat-pagina.tem-selecao .chat-corpo { padding: 0; height: 100vh; }
  .chat-pagina.tem-selecao .chat-thread-wrap { border: none; border-radius: 0; }
}
