/* ════════════════════════════════════════════════════════════════
   GNL BRASIL × ZANE — DESIGN SYSTEM
   Tokens extraídos dos protótipos de referência (GNL_Protótipo_*.html)
   fornecidos pelo cliente: paleta teal/navy/laranja/âmbar, tipografia
   Inter, cantos arredondados sóbrios, cards com sombra leve.
   ════════════════════════════════════════════════════════════════ */

:root {
  /* Marca GNL */
  --gnl-brand: #0ABFBC;
  --gnl-brand-dark: #089795;
  --gnl-brand-soft: #4FD4D1;
  --gnl-brand-bg: #E8F9F9;

  --gnl-navy: #1A2332;

  /* Acentos do design system (usados em gráficos/destaques, não em ações primárias) */
  --gnl-accent-orange: #E84E2A;
  --gnl-accent-amber: #F5A623;
  --gnl-accent-indigo: #6366F1;

  /* Marca Zane (parceira de tecnologia) */
  --zane-green: #50B37C;

  /* Superfícies */
  --gnl-bg-page: #F4F5F7;
  --gnl-bg-surface: #FFFFFF;
  --gnl-bg-subtle: #F8FAFC;

  /* Texto */
  --gnl-text-primary: #1A2332;
  --gnl-text-secondary: #627087;
  --gnl-text-tertiary: #9AA5B4;
  --gnl-text-on-brand: #FFFFFF;

  /* Bordas */
  --gnl-border: #E2E8F0;
  --gnl-border-strong: #CBD3DC;

  /* Estados semânticos */
  --gnl-success: #166534;
  --gnl-success-bg: #DCFCE7;
  --gnl-warning: #92400E;
  --gnl-warning-bg: #FEF3C7;
  --gnl-danger: #C41A1A;
  --gnl-danger-bg: #FEE2E2;

  /* Espaçamento / forma */
  --gnl-radius-sm: 6px;
  --gnl-radius-md: 10px;
  --gnl-radius-lg: 14px;
  --gnl-shadow-sm: 0 1px 3px rgba(16, 24, 40, 0.06);
  --gnl-shadow-md: 0 4px 12px rgba(16, 24, 40, 0.08);

  --gnl-sidebar-w: 264px;
  --gnl-sidebar-w-collapsed: 64px;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  overflow: hidden; /* o scroll acontece dentro de cada área, nunca na página */
}

body {
  background: var(--gnl-bg-page);
  color: var(--gnl-text-primary);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* ── Tela de login: única tela que pode rolar a página normalmente ── */
#login-screen { height: 100%; overflow-y: auto; }

/* ── Casca do app ──────────────────────────────────────────────── */
#app-screen {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: var(--gnl-bg-page);
}
#app-content {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.gnl-tab-panel-fixed {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

/* ── Tipografia base ───────────────────────────────────────────── */
.gnl-h1 { font-size: 22px; font-weight: 700; color: var(--gnl-text-primary); letter-spacing: -0.01em; }
.gnl-h2 { font-size: 16px; font-weight: 700; color: var(--gnl-text-primary); }
.gnl-h3 { font-size: 13px; font-weight: 700; color: var(--gnl-text-primary); }
.gnl-eyebrow {
  font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--gnl-text-tertiary);
}
.gnl-body { font-size: 14px; color: var(--gnl-text-secondary); line-height: 1.6; }
.gnl-caption { font-size: 12px; color: var(--gnl-text-tertiary); }

/* ── Top navigation ───────────────────────────────────────────── */
.gnl-topbar {
  background: var(--gnl-bg-surface);
  border-bottom: 1px solid var(--gnl-border);
  border-top: 3px solid var(--gnl-brand);
  flex-shrink: 0;
}
.gnl-topbar-inner { padding: 0 24px; }
.gnl-topbar-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
}
.gnl-brand-mark { display: flex; align-items: center; gap: 12px; }
.gnl-brand-mark img { height: 28px; width: auto; display: block; }
.gnl-brand-divider { width: 1px; height: 22px; background: var(--gnl-border-strong); }
.gnl-powered-by { display: flex; align-items: center; gap: 6px; }
.gnl-powered-by span { font-size: 10px; color: var(--gnl-text-tertiary); font-weight: 600; letter-spacing: .04em; text-transform: uppercase; }
.gnl-powered-by img { height: 15px; width: auto; display: block; opacity: .9; }

.gnl-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--gnl-text-tertiary);
}
.gnl-status-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--gnl-success); }

/* ── Cards ─────────────────────────────────────────────────────── */
.gnl-card {
  background: var(--gnl-bg-surface);
  border: 1px solid var(--gnl-border);
  border-radius: var(--gnl-radius-md);
  box-shadow: var(--gnl-shadow-sm);
}
.gnl-card-pad { padding: 20px; }

/* ── Botões ────────────────────────────────────────────────────── */
.gnl-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  border-radius: var(--gnl-radius-sm);
  padding: 8px 16px;
  cursor: pointer;
  transition: all .15s ease;
  border: 1px solid transparent;
  font-family: inherit;
}
.gnl-btn-primary { background: var(--gnl-brand); color: var(--gnl-text-on-brand); }
.gnl-btn-primary:hover { background: var(--gnl-brand-dark); }
.gnl-btn-primary:disabled { opacity: .5; cursor: default; }

.gnl-btn-secondary {
  background: var(--gnl-bg-surface);
  color: var(--gnl-text-secondary);
  border-color: var(--gnl-border-strong);
}
.gnl-btn-secondary:hover { background: var(--gnl-bg-subtle); color: var(--gnl-text-primary); }

.gnl-btn-ghost {
  background: none;
  color: var(--gnl-text-tertiary);
  border-color: transparent;
}
.gnl-btn-ghost:hover { color: var(--gnl-text-primary); background: var(--gnl-bg-subtle); }

.gnl-icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--gnl-radius-sm);
  border: 1px solid var(--gnl-border);
  background: var(--gnl-bg-surface);
  color: var(--gnl-text-tertiary);
  cursor: pointer;
  transition: all .15s ease;
  flex-shrink: 0;
}
.gnl-icon-btn:hover { border-color: var(--gnl-brand); color: var(--gnl-brand); }

/* ── Inputs ────────────────────────────────────────────────────── */
.gnl-input {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--gnl-border-strong);
  border-radius: var(--gnl-radius-sm);
  font-size: 13px;
  color: var(--gnl-text-primary);
  background: var(--gnl-bg-surface);
  outline: none;
  transition: border-color .15s ease;
  font-family: inherit;
}
.gnl-input:focus { border-color: var(--gnl-brand); }
.gnl-input::placeholder { color: var(--gnl-text-tertiary); }

/* ── Layout de página com sidebar fixa (Chat) ────────────────────── */
.gnl-chat-layout {
  display: flex;
  flex: 1;
  height: 100%;
  min-height: 0;
  position: relative;
}

.gnl-sidebar {
  width: var(--gnl-sidebar-w);
  flex-shrink: 0;
  background: var(--gnl-bg-surface);
  border-right: 1px solid var(--gnl-border);
  display: flex;
  flex-direction: column;
  transition: width .2s ease;
  overflow: hidden;
  height: 100%;
  min-height: 0;
}
.gnl-sidebar.is-collapsed { width: var(--gnl-sidebar-w-collapsed); }

.gnl-sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 14px 10px;
  border-bottom: 1px solid var(--gnl-border);
  flex-shrink: 0;
  min-height: 49px;
}

.gnl-sidebar-body { flex: 1; min-height: 0; overflow-y: auto; scrollbar-width: thin; }
.gnl-sidebar-foot {
  flex-shrink: 0;
  padding: 10px 14px;
  border-top: 1px solid var(--gnl-border);
  display: flex;
  align-items: center;
  gap: 8px;
}

.gnl-chat-main { flex: 1; min-width: 0; min-height: 0; height: 100%; display: flex; flex-direction: column; }
.gnl-chat-canvas { flex: 1; min-height: 0; overflow-y: auto; scrollbar-width: thin; }
.gnl-chat-canvas-inner {
  max-width: 880px;
  width: 100%;
  margin: 0 auto;
  padding: 24px 24px 0;
  display: flex;
  flex-direction: column;
  min-height: 100%;
}

/* ── Histórico: itens da lista ────────────────────────────────── */
.gnl-hist-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: var(--gnl-radius-sm);
  cursor: pointer;
  margin-bottom: 1px;
  position: relative;
  border-left: 2px solid transparent;
}
.gnl-hist-item:hover { background: var(--gnl-bg-subtle); }
.gnl-hist-item.is-active { background: var(--gnl-brand-bg); border-left-color: var(--gnl-brand); }
.gnl-hist-item .conv-actions { display: none; gap: 2px; flex-shrink: 0; }
.gnl-hist-item:hover .conv-actions { display: flex; }

/* ── Mensagens do chat ────────────────────────────────────────── */
.gnl-msg-user {
  max-width: 640px;
  padding: 11px 16px;
  border-radius: var(--gnl-radius-md);
  background: var(--gnl-navy);
  color: #fff;
  font-size: 14px;
  line-height: 1.55;
}
.gnl-msg-assistant {
  max-width: 760px;
  padding: 14px 18px;
  border-radius: var(--gnl-radius-md);
  background: var(--gnl-bg-surface);
  border: 1px solid var(--gnl-border);
  font-size: 14px;
  color: var(--gnl-text-primary);
  line-height: 1.6;
}

/* ── Indicador de uso de ferramenta (consulta ao banco) ─────────── */
.gnl-tool-status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  font-weight: 500;
  color: var(--gnl-text-secondary);
  background: var(--gnl-bg-subtle);
  border: 1px solid var(--gnl-border);
  border-radius: 999px;
  padding: 5px 12px;
  margin-bottom: 10px;
}
.gnl-tool-status.is-running .gnl-tool-dot { animation: gnl-pulse 1s ease-in-out infinite; }
.gnl-tool-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--gnl-brand); flex-shrink: 0; }
.gnl-tool-status.is-error .gnl-tool-dot { background: var(--gnl-danger); }
@keyframes gnl-pulse { 0%,100% { opacity: 1; } 50% { opacity: .3; } }

/* ── Scrollbar discreta ──────────────────────────────────────────── */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--gnl-border-strong); border-radius: 8px; }
::-webkit-scrollbar-track { background: transparent; }

/* ── Tabelas de dados ─────────────────────────────────────────────── */
.gnl-table { width: 100%; border-collapse: collapse; }
.gnl-table th {
  text-align: right;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--gnl-text-tertiary);
  padding: 8px 12px;
  border-bottom: 1px solid var(--gnl-border);
}
.gnl-table th:first-child { text-align: left; }
.gnl-table td {
  text-align: right;
  font-size: 13px;
  color: var(--gnl-text-primary);
  padding: 9px 12px;
  border-bottom: 1px solid var(--gnl-bg-subtle);
}
.gnl-table td:first-child { text-align: left; color: var(--gnl-text-secondary); }
.gnl-table tr:hover td { background: var(--gnl-bg-subtle); }

/* ── Skeleton de loading ──────────────────────────────────────────── */
.gnl-skeleton {
  background: linear-gradient(90deg, var(--gnl-bg-subtle) 25%, var(--gnl-border) 37%, var(--gnl-bg-subtle) 63%);
  background-size: 400% 100%;
  animation: gnl-shimmer 1.4s ease infinite;
  border-radius: var(--gnl-radius-sm);
}
@keyframes gnl-shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

/* ── Responsivo ────────────────────────────────────────────────────── */
@media (max-width: 860px) {
  .gnl-sidebar { position: absolute; top: 0; left: 0; bottom: 0; z-index: 35; box-shadow: var(--gnl-shadow-md); }
  .gnl-sidebar.is-collapsed { width: 0; border-right: none; }
}

/* ── Fallback mínimo de utilitários, caso o CDN do Tailwind falhe ── */
.hidden { display: none !important; }
.flex { display: flex; }
.flex-1 { flex: 1 1 0%; }
.flex-col { flex-direction: column; }
.grid { display: grid; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.min-h-screen { min-height: 100vh; }
.w-full { width: 100%; }
.mx-auto { margin-left: auto; margin-right: auto; }
.text-center { text-align: center; }
