/* Hiperlink Atendimento IA — tema visual
   Paleta: fibra optica / noite de operacao
   --bg-deep:   #0B1220  (quase-preto azulado, fundo geral)
   --bg-panel:  #121C2E  (paineis / cards)
   --bg-raised: #182541  (itens elevados, hover)
   --line:      #24314F  (bordas sutis)
   --text-hi:   #EAF0FB  (texto principal)
   --text-mid:  #9FB0CC  (texto secundario)
   --text-dim:  #647192  (texto terciario)
   --accent:    #37E6C4  (ciano-fibra — sinal, IA, acao positiva)
   --accent-dim:#1B8F7C
   --warn:      #F5A623  (atencao / aguardando)
   --danger:    #FF5C7A  (LOS / luz vermelha / urgente)
*/

* { box-sizing: border-box; }

:root {
  --bg-deep: #0B1220;
  --bg-panel: #121C2E;
  --bg-raised: #182541;
  --line: #24314F;
  --text-hi: #EAF0FB;
  --text-mid: #9FB0CC;
  --text-dim: #647192;
  --accent: #37E6C4;
  --accent-dim: #1B8F7C;
  --warn: #F5A623;
  --danger: #FF5C7A;
  --radius: 10px;
}

html, body {
  height: 100%;
  margin: 0;
  background: var(--bg-deep);
  color: var(--text-hi);
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  font-size: 14px;
}

a { color: inherit; }

/* ---------- Fibra animada de fundo (assinatura visual) ---------- */
.fiber-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
  opacity: 0.35;
}
.fiber-bg svg { width: 100%; height: 100%; }
.fiber-line {
  fill: none;
  stroke: var(--accent);
  stroke-width: 1;
  stroke-dasharray: 6 10;
  opacity: 0.35;
  animation: fiber-flow 6s linear infinite;
}
.fiber-line.d2 { stroke: var(--accent-dim); animation-duration: 9s; opacity: 0.2; }
@keyframes fiber-flow {
  to { stroke-dashoffset: -160; }
}

/* ---------- Login ---------- */
.login-wrap {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--bg-panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 32px 28px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.45);
}
.brand {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 4px;
}
.brand-mark { color: var(--accent); font-weight: 800; letter-spacing: 0.5px; }
.brand-name { font-size: 20px; font-weight: 700; }
.brand-sub { color: var(--text-mid); font-size: 12.5px; margin-bottom: 28px; }

label { display: block; font-size: 12.5px; color: var(--text-mid); margin: 16px 0 6px; }
input[type="email"], input[type="password"], input[type="text"] {
  width: 100%;
  background: var(--bg-raised);
  border: 1px solid var(--line);
  color: var(--text-hi);
  border-radius: 8px;
  padding: 11px 12px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s;
}
input:focus { border-color: var(--accent); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: 8px;
  padding: 11px 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.08s, filter 0.15s;
}
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--accent); color: #06231D; width: 100%; margin-top: 22px; }
.btn-primary:hover { filter: brightness(1.08); }
.btn-ghost { background: transparent; color: var(--text-mid); border: 1px solid var(--line); }
.btn-ghost:hover { color: var(--text-hi); border-color: var(--accent-dim); }

.error-msg {
  color: var(--danger);
  font-size: 12.5px;
  margin-top: 14px;
  min-height: 16px;
}

/* ---------- Painel de atendimento ---------- */
.app-shell {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 220px 320px 1fr 280px;
  height: 100vh;
}

.sidebar {
  background: var(--bg-panel);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
}
.sidebar .brand { padding: 0 6px; }
.nav-group { margin-top: 24px; }
.nav-label { color: var(--text-dim); font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; padding: 0 10px 6px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: 8px; color: var(--text-mid);
  cursor: pointer; font-size: 13.5px; margin-bottom: 2px;
}
.nav-item:hover { background: var(--bg-raised); color: var(--text-hi); }
.nav-item.active { background: var(--bg-raised); color: var(--accent); }
.nav-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-dim); }
.nav-dot.tecnico { background: var(--danger); }
.nav-dot.suporte { background: var(--warn); }
.nav-dot.ia { background: var(--accent); }

/* Luzinha vermelha piscando: sinaliza que aquela fila tem conversa
   aguardando atendente (precisa de tratativa humana). */
.nav-alerta {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--danger);
  margin-left: auto;
  flex-shrink: 0;
  animation: nav-alerta-piscar 1.1s ease-in-out infinite;
}
@keyframes nav-alerta-piscar {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(255, 92, 122, 0.55); }
  50% { opacity: 0.35; box-shadow: 0 0 0 5px rgba(255, 92, 122, 0); }
}

.sidebar-footer { margin-top: auto; padding-top: 16px; border-top: 1px solid var(--line); }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 8px 6px; }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--bg-raised); display:flex; align-items:center; justify-content:center; font-weight:700; color: var(--accent); font-size: 12px; }
.user-chip .name { font-size: 13px; font-weight: 600; }
.user-chip .role { font-size: 11px; color: var(--text-dim); }

.list-col {
  background: var(--bg-deep);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.list-header { padding: 16px; border-bottom: 1px solid var(--line); }
.list-header h2 { margin: 0 0 2px; font-size: 15px; }
.list-header .count { color: var(--text-dim); font-size: 12px; }
.conv-list { overflow-y: auto; flex: 1; }
.conv-item {
  padding: 12px 16px; border-bottom: 1px solid var(--line);
  cursor: pointer; transition: background 0.1s;
}
.conv-item:hover { background: var(--bg-panel); }
.conv-item.active { background: var(--bg-panel); border-left: 3px solid var(--accent); }
.conv-item .top-row { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.conv-item .cliente { font-weight: 600; font-size: 13.5px; }
.conv-item .hora { font-size: 11px; color: var(--text-dim); flex-shrink: 0; }
.conv-item .preview { color: var(--text-mid); font-size: 12.5px; margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.badge {
  display: inline-block; font-size: 10.5px; font-weight: 700; letter-spacing: 0.03em;
  padding: 2px 7px; border-radius: 20px; margin-top: 6px; text-transform: uppercase;
}
.badge.ia { background: rgba(55,230,196,0.12); color: var(--accent); }
.badge.aguardando { background: rgba(245,166,35,0.14); color: var(--warn); }
.badge.humano { background: rgba(80,140,255,0.14); color: #7FA6FF; }
.badge.encerrada { background: rgba(150,160,180,0.12); color: var(--text-dim); }

.chat-col { display: flex; flex-direction: column; background: var(--bg-deep); min-height: 0; }
#chat-active { min-height: 0; }
.chat-header { padding: 16px 20px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; flex-shrink: 0; }
.chat-header .titulo { font-size: 15px; font-weight: 700; }
.chat-header .sub { font-size: 12px; color: var(--text-dim); }
.chat-messages { flex: 1; min-height: 0; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: 62%; padding: 10px 13px; border-radius: 12px; font-size: 13.5px; line-height: 1.45; }
.msg.cliente { align-self: flex-start; background: var(--bg-panel); border: 1px solid var(--line); border-bottom-left-radius: 3px; }
.msg.ia { align-self: flex-end; background: rgba(55,230,196,0.10); border: 1px solid var(--accent-dim); border-bottom-right-radius: 3px; }
.msg.atendente { align-self: flex-end; background: var(--accent); color: #06231D; border-bottom-right-radius: 3px; }
.msg.sistema { align-self: center; background: transparent; color: var(--text-dim); font-size: 11.5px; font-style: italic; }
.msg .autor { font-size: 10.5px; opacity: 0.7; margin-bottom: 3px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em; }

.chat-input { padding: 14px 16px; border-top: 1px solid var(--line); display: flex; gap: 10px; flex-shrink: 0; }
.chat-input input { flex: 1; }
.empty-state { flex: 1; display: flex; align-items: center; justify-content: center; color: var(--text-dim); font-size: 13px; }

.detail-col { background: var(--bg-panel); padding: 18px; overflow-y: auto; }
.detail-col h3 { font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-dim); margin: 0 0 14px; }
.field { margin-bottom: 14px; }
.field .k { font-size: 11px; color: var(--text-dim); margin-bottom: 3px; }
.field .v { font-size: 13.5px; }
.action-btns { display: flex; flex-direction: column; gap: 8px; margin-top: 20px; }

/* ---------- Tela geral de Chamados ---------- */
.chamados-view {
  grid-column: 2 / 5;
  background: var(--bg-deep);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.chamados-filtros {
  display: flex;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.chamados-filtros input, .chamados-filtros select {
  background: var(--bg-raised);
  border: 1px solid var(--line);
  color: var(--text-hi);
  border-radius: 8px;
  padding: 9px 11px;
  font-size: 13px;
  outline: none;
}
.chamados-filtros input { flex: 1; min-width: 140px; }
.chamados-tabela-wrap { flex: 1; min-height: 0; overflow: auto; padding: 0 16px 16px; }
.chamados-tabela { width: 100%; border-collapse: collapse; font-size: 13px; }
.chamados-tabela th {
  text-align: left; position: sticky; top: 0; background: var(--bg-deep);
  color: var(--text-dim); font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em;
  padding: 10px 8px; border-bottom: 1px solid var(--line);
}
.chamados-tabela td { padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.chamados-tabela select { background: var(--bg-raised); color: var(--text-hi); border: 1px solid var(--line); border-radius: 6px; padding: 5px 7px; font-size: 12px; }

.chamado-card {
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 8px;
}
.chamado-card .top-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 4px; }
.chamado-card .tipo { font-size: 13px; font-weight: 600; }
.chamado-card .descricao { font-size: 12px; color: var(--text-mid); margin-bottom: 6px; }
.chamado-card select { width: 100%; }

@media (max-width: 1100px) {
  .app-shell { grid-template-columns: 70px 280px 1fr; }
  .detail-col { display: none; }
  .sidebar .nav-label, .sidebar .nav-item span.label, .user-chip .name, .user-chip .role { display: none; }
}

/* ---------- Modal (perfil / troca de senha) ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(6, 10, 20, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.modal-card {
  background: var(--bg-panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  width: 100%;
  max-width: 380px;
  padding: 22px 24px 26px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.4);
}
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.modal-header h3 { margin: 0; font-size: 16px; }
.modal-close {
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
}
.modal-close:hover { color: var(--text-hi); }
.success-msg {
  color: var(--accent);
  font-size: 12.5px;
  margin-top: 14px;
  min-height: 16px;
}
