/* ============================================================
   CausaOS — Design System premium (app-shell)
   Tema claro institucional · Inter · navy/ciano/verde
   Objetivo: nível de Linear/Stripe/Notion/Harvey — sair do "caseiro".
   ============================================================ */

/* Fonte: Inter se instalada; senão Segoe UI/system (limpo). Sem @import EXTERNO
   (Google Fonts etc. travam o render). O @import abaixo é LOCAL (mesma pasta),
   custo desprezível: traz os componentes legados (.nx-*) para que TODA tela use
   apenas este arquivo como porta de entrada. As telas .nx- serão migradas para
   o visual novo nas Ondas 2-3; até lá, este import as mantém funcionando. */

@import url('nexo-ui.css');   /* Onda 1 F1/F2 — componentes legados; porta única = causaos-ui.css */

:root {
  /* Marca */
  --navy: #002060;
  --navy-700: #0a2f7a;
  --ciano: #1BA5DC;
  --ciano-600: #1690c2;
  --verde: #1D9E75;
  --amber: #E08A00;
  --vermelho: #D64545;

  /* Neutros */
  --bg: #F6F8FC;
  --surface: #FFFFFF;
  --surface-2: #F9FBFE;
  --line: #E7ECF3;
  --line-2: #EEF2F8;
  --ink: #0F1B2D;
  --ink-2: #46566B;
  --ink-3: #7A8AA0;

  /* Tokens */
  --radius: 14px;
  --radius-sm: 9px;
  --radius-pill: 999px;
  --shadow-sm: 0 1px 2px rgba(16,27,45,.06), 0 1px 3px rgba(16,27,45,.05);
  --shadow: 0 4px 14px rgba(16,27,45,.07);
  --shadow-lg: 0 18px 48px rgba(16,27,45,.16);
  --sidebar-w: 258px;
  --topbar-h: 64px;
  --ring: 0 0 0 3px rgba(27,165,220,.22);

  /* Onda 1 F3 — cores que estavam soltas no meio do CSS, agora nomeadas */
  --white: #ffffff;
  --side-ink: #c4d1ea;       /* texto dos itens do menu lateral */
  --side-ink-dim: #8fa3cc;   /* subtítulo da marca / apoio na lateral */
  --side-label: #6f86b6;     /* rótulos de seção do menu */
  --side-foot: #7e93c0;      /* rodapé "powered" da lateral */
  --side-strong: #b9c8e6;    /* texto claro de destaque sobre o navy */
  --line-strong: #d7e0ee;    /* borda do card em hover */
  /* fundos/bordas dos estados padrão (usados na F4) */
  --vermelho-bg: #fdecec;  --vermelho-line: #f6caca;  --vermelho-escuro: #a32d2d; /* texto: AA sobre -bg */
  --verde-bg:    #e9f7f1;  --verde-line:    #bfe6d6;  --verde-escuro:    #0f6e56; /* texto: AA sobre -bg */
  --amber-bg:    #faeeda;  --amber-line:    #f0d9a6;  --amber-escuro:    #854f0b; /* texto: AA sobre -bg */
  --ciano-escuro: #0b5a78;  /* texto ciano: AA sobre fundos ciano-claros */
  /* fonte mono (números, nº de processo) */
  --mono: 'SFMono-Regular', 'Consolas', 'Roboto Mono', monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: 'Inter', -apple-system, Segoe UI, Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  font-size: 14.5px;
  line-height: 1.5;
}
a { color: inherit; text-decoration: none; }
::selection { background: rgba(27,165,220,.22); }

/* ----------------------------------- App shell */
.shell { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }

/* ----------------------------------- Sidebar */
.sidebar {
  background: linear-gradient(180deg, #001a52 0%, var(--navy) 60%, #001642 100%);
  color: #cdd8ee;
  display: flex; flex-direction: column;
  padding: 20px 14px;
  position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 11px; padding: 6px 8px 2px; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 9px; flex: none;
  background: linear-gradient(135deg, var(--ciano), #4fc3f0);
  display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 17px;
  box-shadow: 0 6px 16px rgba(27,165,220,.45);
}
.brand-name { font-weight: 800; font-size: 18px; color: #fff; letter-spacing: -.3px; }
.brand-name b { color: var(--ciano); }
.brand-tag { font-size: 11px; color: var(--side-ink-dim); margin: 6px 10px 16px; line-height: 1.35; }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: .9px; color: var(--side-label); margin: 14px 12px 6px; font-weight: 600; }
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 12px; border-radius: 10px; color: var(--side-ink); font-weight: 500;
  cursor: pointer; transition: background .14s, color .14s; position: relative;
}
.nav-item svg { width: 18px; height: 18px; flex: none; opacity: .85; }
.nav-item:hover { background: rgba(255,255,255,.07); color: #fff; }
.nav-item.active { background: rgba(27,165,220,.18); color: #fff; }
.nav-item.active::before { content:''; position:absolute; left:0; top:6px; bottom:6px; width:4px; border-radius:0 4px 4px 0; background: var(--ciano); }
.nav-badge { margin-left: auto; background: var(--ciano); color:#fff; font-size: 10.5px; font-weight: 700; padding: 1px 7px; border-radius: var(--radius-pill); }

.sidebar-foot { margin-top: auto; padding-top: 14px; }
.powered { font-size: 11px; color: var(--side-foot); text-align: center; padding: 10px 0 12px; border-top: 1px solid rgba(255,255,255,.09); }
.powered b { color: var(--side-strong); font-weight: 600; }

/* ----------------------------------- Main */
.main { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  height: var(--topbar-h); background: rgba(255,255,255,.82); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 16px; padding: 0 28px; position: sticky; top: 0; z-index: 20;
}
.page-title { font-size: 18px; font-weight: 700; letter-spacing: -.3px; }
.search {
  margin-left: 8px; flex: 1; max-width: 460px; display: flex; align-items: center; gap: 9px;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; color: var(--ink-3);
}
.search input { border: 0; background: transparent; outline: none; width: 100%; font: inherit; color: var(--ink); }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.icon-btn { width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); display: grid; place-items: center; color: var(--ink-2); cursor: pointer; }
.icon-btn:hover { background: var(--surface-2); }
.avatar { width: 38px; height: 38px; border-radius: var(--radius-pill); background: linear-gradient(135deg, var(--navy), var(--ciano)); color:#fff; display:grid; place-items:center; font-weight:700; font-size:13px; }

.content { padding: 30px 28px 60px; max-width: 1180px; width: 100%; margin: 0 auto; }
.hello { font-size: 24px; font-weight: 800; letter-spacing: -.5px; }
.hello-sub { color: var(--ink-2); margin-top: 3px; margin-bottom: 24px; }

/* Stats strip */
.stats { display: grid; grid-template-columns: repeat(4,1fr); gap: 14px; margin-bottom: 26px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow-sm); }
.stat .v { font-size: 26px; font-weight: 800; letter-spacing: -.5px; }
.stat .l { font-size: 12.5px; color: var(--ink-3); margin-top: 2px; }
.stat .v.amber { color: var(--amber); } .stat .v.ciano { color: var(--ciano-600); } .stat .v.verde { color: var(--verde); }

/* Action cards */
.actions { display: grid; grid-template-columns: 1.6fr 1fr 1fr; gap: 16px; margin-bottom: 30px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); transition: box-shadow .16s, transform .16s, border-color .16s; }
.card:hover { box-shadow: var(--shadow); transform: translateY(-2px); border-color: var(--line-strong); }
.card-primary {
  grid-row: span 1; padding: 26px; cursor: pointer; color:#fff; border: 0;
  background: radial-gradient(120% 140% at 0% 0%, #0a2f7a 0%, var(--navy) 55%, #001233 100%);
  display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden;
}
.card-primary::after { content:''; position:absolute; right:-40px; bottom:-40px; width:160px; height:160px; border-radius:50%; background: radial-gradient(circle, rgba(27,165,220,.5), transparent 70%); }
.card-primary .big { font-size: 21px; font-weight: 800; letter-spacing: -.4px; margin-bottom: 6px; }
.card-primary .sm { color: var(--side-strong); font-size: 13px; max-width: 80%; }
.cta-plus { width: 46px; height: 46px; border-radius: 12px; background: rgba(255,255,255,.16); display:grid; place-items:center; margin-bottom: 16px; }
.card-secondary { padding: 22px; cursor: pointer; display: flex; flex-direction: column; gap: 10px; }
.card-ico { width: 42px; height: 42px; border-radius: 11px; display:grid; place-items:center; }
.card-ico.ciano { background: rgba(27,165,220,.12); color: var(--ciano-600); }
.card-ico.verde { background: rgba(29,158,117,.12); color: var(--verde); }
.card-secondary .t { font-weight: 700; font-size: 15px; }
.card-secondary .d { font-size: 12.5px; color: var(--ink-3); }

/* Section */
.section-head { display: flex; align-items: center; margin: 8px 0 14px; }
.section-head h2 { font-size: 15px; font-weight: 700; margin: 0; }
.section-head a { margin-left: auto; font-size: 13px; color: var(--ciano-600); font-weight: 600; }

/* Case list */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); overflow: hidden; }
.row { display: grid; grid-template-columns: 1fr auto auto auto; align-items: center; gap: 14px; padding: 15px 20px; border-bottom: 1px solid var(--line-2); cursor: pointer; transition: background .12s; }
.row:last-child { border-bottom: 0; }
.row:hover { background: var(--surface-2); }
.row .title { font-weight: 600; }
.row .meta { font-size: 12.5px; color: var(--ink-3); margin-top: 2px; }
.badge { font-size: 11.5px; font-weight: 600; padding: 3px 10px; border-radius: var(--radius-pill); white-space: nowrap; }
.badge.azul { background: rgba(0,32,96,.08); color: var(--navy); }
.badge.laranja { background: rgba(224,138,0,.13); color: var(--amber); }
.badge.verde { background: rgba(29,158,117,.13); color: var(--verde); }
.badge.cinza { background: #eef2f8; color: var(--ink-2); }
.prazo { font-size: 12.5px; font-weight: 600; color: var(--ink-2); text-align: right; }
.prazo.urgente { color: var(--vermelho); }

/* Floating assistant */
.assistant { position: fixed; right: 26px; bottom: 26px; z-index: 50; }
.assistant-bubble {
  height: 58px; border-radius: 999px; cursor: pointer; border: 0;
  padding: 0 22px 0 18px; gap: 11px;
  background: linear-gradient(135deg, var(--ciano), var(--navy));
  box-shadow: 0 12px 30px rgba(0,32,96,.4); display: inline-flex; align-items: center; color: #fff;
  font: 700 14.5px/1 Arial, sans-serif; transition: transform .15s, box-shadow .15s;
}
.assistant-bubble:hover { transform: translateY(-2px) scale(1.03); box-shadow: 0 16px 36px rgba(0,32,96,.45); }
.assistant-bubble svg { flex: none; }
.assistant-bubble-label { white-space: nowrap; }
/* Em telas estreitas, volta a ser só o ícone (economiza espaço) */
@media (max-width: 560px) {
  .assistant-bubble { padding: 0; width: 56px; justify-content: center; }
  .assistant-bubble-label { display: none; }
}

@media (max-width: 1000px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .actions { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(2,1fr); }
}

/* =====================================================================
   Onda 1 F4 — ESTADOS PADRÃO (vazio · carregando · erro · sucesso)
   Toda lista/tela/formulário usa estes blocos. Uso:
     <div class="state">…</div>                 (vazio)
     <div class="state state--carregando">…</div>
     <div class="state state--erro">…</div>
     <div class="state state--ok">…</div>
   ===================================================================== */
.state {
  display: flex; flex-direction: column; align-items: center;
  text-align: center; gap: 10px; padding: 46px 28px;
}
.state-ico {
  width: 56px; height: 56px; border-radius: 16px; display: grid; place-items: center;
  background: var(--surface-2); border: 1px solid var(--line); color: var(--ink-3);
}
.state-ico svg { width: 26px; height: 26px; }
.state-title { font-size: 16px; font-weight: 700; color: var(--ink); }
.state-sub   { font-size: 13px; color: var(--ink-2); max-width: 360px; line-height: 1.5; }
.state-actions { margin-top: 6px; display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }

.state--erro .state-ico { background: var(--vermelho-bg); border-color: var(--vermelho-line); color: var(--vermelho); }
.state--ok   .state-ico { background: var(--verde-bg);    border-color: var(--verde-line);    color: var(--verde); }
.state--carregando .state-ico { background: transparent; border: 0; }

/* Carregando — spinner */
.spinner {
  width: 30px; height: 30px; border: 3px solid var(--line);
  border-top-color: var(--ciano); border-radius: 50%; animation: spin .65s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Carregando — esqueleto (placeholder cinza que "respira") */
.skeleton {
  background: linear-gradient(90deg, var(--line-2) 25%, var(--surface-2) 37%, var(--line-2) 63%);
  background-size: 400% 100%; border-radius: 8px; animation: shimmer 1.3s ease infinite;
}
.skeleton + .skeleton { margin-top: 10px; }
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }

@media (prefers-reduced-motion: reduce) {
  .spinner, .skeleton { animation-duration: .001ms !important; }
}

/* =====================================================================
   Onda 2 — PRIMITIVAS DE FORMULÁRIO (oficiais, visual novo)
   Botão, campo, abas e mensagem. Reutilizáveis em login, cadastro e
   todas as telas. Substituem progressivamente as peças legadas .nx-*.
   ===================================================================== */

/* Campos */
.field { margin-bottom: 16px; }
.label { display: block; font-size: 13px; font-weight: 500; color: var(--ink-2); margin-bottom: 6px; }
.input {
  width: 100%; font: inherit; font-size: 14.5px; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 11px 13px; transition: border-color .15s, box-shadow .15s;
}
.input::placeholder { color: var(--ink-3); }
.input:hover { border-color: var(--line-strong); }
.input:focus { outline: none; border-color: var(--ciano); box-shadow: var(--ring); }
.input[aria-invalid="true"] { border-color: var(--vermelho); }
.hint { font-size: 12px; color: var(--ink-3); margin-top: 5px; }

/* Botões */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: inherit; font-size: 14px; font-weight: 500; line-height: 1;
  padding: 11px 18px; border-radius: var(--radius-sm); border: 1px solid transparent;
  cursor: pointer; white-space: nowrap;
  transition: background .15s, border-color .15s, box-shadow .15s, transform .05s;
}
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: var(--ring); }
.btn:disabled { opacity: .6; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--ciano); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--ciano-600); }
.btn-navy { background: var(--navy); color: #fff; }
.btn-navy:hover:not(:disabled) { background: var(--navy-700); }
.btn-ghost { background: transparent; color: var(--ink-2); border-color: var(--line); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); color: var(--ink); }
.btn-block { width: 100%; }
.btn-lg { padding: 13px 20px; font-size: 15px; }
.btn-sm { padding: 8px 13px; font-size: 13px; }
/* spinner pequeno para dentro de botão (estado carregando) */
.btn .spin {
  width: 16px; height: 16px; border: 2px solid rgba(255,255,255,.45);
  border-top-color: #fff; border-radius: 50%; animation: spin .6s linear infinite;
}

/* Abas / segmented control */
.seg { display: flex; gap: 5px; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 4px; }
.seg-item {
  flex: 1; text-align: center; padding: 9px 8px; cursor: pointer;
  font-weight: 500; font-size: 13px; color: var(--ink-2);
  background: transparent; border: 0; border-radius: var(--radius-sm);
  transition: background .15s, color .15s;
}
.seg-item:focus-visible { outline: none; box-shadow: var(--ring); }
.seg-item.ativo { color: var(--navy); background: var(--surface); box-shadow: var(--shadow-sm); }

/* Mensagem inline de formulário (erro / sucesso) */
.formmsg { padding: 10px 13px; border-radius: var(--radius-sm); font-size: 13px; font-weight: 500; border: 1px solid transparent; }
.formmsg--erro  { background: var(--vermelho-bg); color: var(--vermelho-escuro); border-color: var(--vermelho-line); }
.formmsg--ok    { background: var(--verde-bg);    color: var(--verde-escuro);    border-color: var(--verde-line); }
.formmsg--aviso { background: var(--amber-bg);    color: var(--amber-escuro);    border-color: var(--amber-line); }
.is-hidden { display: none !important; }

/* =====================================================================
   Onda 2 N2 — FOCO VISÍVEL E TECLADO no app-shell
   Tudo que é clicável também é alcançável por Tab, com anel visível.
   ===================================================================== */
.nav-item { outline: none; }
.nav-item:focus-visible { box-shadow: 0 0 0 2px var(--ciano); }
.icon-btn:focus-visible, .avatar:focus-visible { outline: none; box-shadow: var(--ring); }
.search:focus-within { border-color: var(--ciano); box-shadow: var(--ring); }
.card[role="button"] { outline: none; }
.card[role="button"]:focus-visible { box-shadow: var(--ring); border-color: var(--ciano); }
.assistant-bubble:focus-visible { outline: none; box-shadow: 0 0 0 4px rgba(27,165,220,.45); }

/* =====================================================================
   B2 — Telas EM CONSTRUÇÃO escondidas durante o teste com advogado.
   Intimações e Clientes/Propostas ainda não têm backend (são demo).
   Escondê-las evita que o advogado clique e nada aconteça.
   REVERTER quando o backend existir: apagar este bloco
   (e a classe "demo-oculto" dos itens em painel-matriz.html).
   ===================================================================== */
.nav-item[data-nav="intimacoes.html"],
.nav-item[data-nav="clientes.html"],
.stat[data-nav="clientes.html"],
.demo-oculto { display: none !important; }

/* =====================================================================
   Ditado por voz (voz.js) — botão de microfone
   ===================================================================== */
.voz-btn {
  display: inline-grid; place-items: center; width: 40px; height: 40px; flex: none;
  border: 1px solid var(--line); border-radius: 10px; background: var(--surface);
  color: var(--ink-2); cursor: pointer; padding: 0;
  transition: background .14s, color .14s, border-color .14s;
}
.voz-btn:hover { background: var(--surface-2); color: var(--navy); border-color: var(--line-strong); }
.voz-btn:focus-visible { outline: none; box-shadow: var(--ring); }
.voz-btn.gravando {
  background: #fde8e8; color: #b42318; border-color: #f3b4b4;
  animation: voz-pulse 1.1s ease-in-out infinite;
}
@keyframes voz-pulse {
  0%,100% { box-shadow: 0 0 0 0 rgba(220,38,38,.35); }
  50%     { box-shadow: 0 0 0 6px rgba(220,38,38,0); }
}
