/* style.css — design do protótipo.
 *
 * Baseado no sistema de referência do usuário:
 * https://styles.refero.design/style/e4b9d41a-8165-47dd-818a-5f6810046ea9
 * ("Pirsch Analytics" — papel-caderno quente: fundo creme, hairlines de tinta
 * em vez de sombra, um unico amarelo como destaque, DM Sans exclusiva).
 *
 * Adaptações deliberadas ao traduzir uma landing page para uma ferramenta
 * de dados densa (tabela, matriz de adjacência, sliders):
 *   - Escala tipográfica do original (base 16-18px) é grande demais para
 *     tabela/matriz; mantive a familia e as proporcoes, encolhi a base.
 *   - Radius 24px do original vira pílula em botões pequenos (✕, ▲▼); usei
 *     radius menor nesses para nao virarem circulos sem afordancia de botao.
 *   - Hairline de 1px preto puro em toda linha de tabela ficaria pesado
 *     visualmente — usei preto em baixa opacidade para divisores internos,
 *     preto solido so nas bordas de cartao/botao/input (as superficies que
 *     o sistema original realmente delimita com hairline).
 *   - O sistema original nao define paleta categorica (é analytics, nao
 *     arquitetura); os 6 tons de tipo de ambiente sao extensao minha na
 *     mesma familia "aquarela sobre papel" — nunca usam o amarelo/verde de
 *     acento, que ficam reservados para CTA e status (regra do sistema).
 */

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:opsz,wght@9..40,400;9..40,500;9..40,700&display=swap');

:root {
  --bg: #f8f5ed;          /* Cream Paper */
  --surface: #f8f5ed;     /* cartoes = mesmo tom da pagina; so a hairline separa */
  --surface-2: #f1ede2;   /* superficie levemente mais funda (rail, thumbnails) */
  --surface-input: #ffffff; /* excecao: campo de formulario ganha branco para leitura em tabela densa */
  --ink: #14120f;
  --border: rgba(20, 18, 15, 0.14);   /* divisor interno (linha de tabela, grade da matriz) */
  --border-strong: rgba(20, 18, 15, 0.62); /* hairline de superficie (cartao, botao, input) */
  --text: #14120f;
  --text-dim: #6f6a5f;    /* Graphite */
  --text-faint: #9c9587;
  --accent: #ffda6e;      /* Sunshine Highlight — unico acento, so em CTA primaria */
  --accent-ink: #14120f;  /* texto sobre amarelo e sempre escuro, nunca branco */
  --accent-soft: rgba(255, 218, 110, 0.4);
  --danger: #a8402f;      /* excecao funcional: erro de P0 precisa de cor propria */
  --danger-soft: #f3e1dc;
  --ok: #6ece9d;           /* Mint Signal — reservado para status/sucesso */
  --ok-ink: #14120f;
  --ok-soft: #e2f2e9;

  --entrada: #e3ecdf;
  --social: #f3e3c2;
  --intimo: #ecdcd6;
  --servico: #d9e2ea;
  --circulacao: #e7e3da;
  --vazio: #d7e6d1;

  --radius-lg: 20px;   /* cartao */
  --radius: 12px;      /* botao padrao, pilulas de aba */
  --radius-sm: 6px;    /* input (exato do sistema de referencia) */
  --radius-xs: 8px;    /* botao pequeno / icone — 24px viraria circulo sem afordancia */
  --radius-pill: 9999px; /* tag/chip — "fully rounded" do sistema */
  font-family: 'DM Sans', -apple-system, "Segoe UI", Inter, "Nunito Sans", sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  font-feature-settings: "ss03" 1, "ss04" 1;
}

/* --- Layout raiz --- */
.app { display: flex; height: 100vh; overflow: hidden; }

.rail {
  width: 240px;
  flex: none;
  background: var(--surface-2);
  border-right: 1px solid var(--border-strong);
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
}
.brand {
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -0.01em;
  padding: 0 8px 16px;
  color: var(--text);
}
.brand small { display: block; font-weight: 500; font-size: 11px; color: var(--text-faint); margin-top: 2px; }

.rail-item {
  display: flex; align-items: center; gap: 9px;
  padding: 9px 10px;
  border-radius: var(--radius-xs);
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  background: none;
  text-align: left;
  width: 100%;
}
.rail-item:hover { border-color: var(--border-strong); }
.rail-item.active { background: var(--surface); border-color: var(--border-strong); color: var(--text); }
.rail-item .n {
  width: 20px; height: 20px; border-radius: 7px;
  background: var(--surface); border: 1px solid var(--border-strong); color: var(--text-dim);
  font-size: 10px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; flex: none;
}
.rail-item.active .n { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.rail-item.done .n { background: var(--ok); border-color: var(--ok); color: var(--ok-ink); }

.rail-io { display: flex; flex-direction: column; gap: 4px; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border-strong); }
.rail-io .btn { text-align: center; font-size: 11.5px; }

.rail-foot { margin-top: auto; padding: 10px 8px 0; font-size: 11px; color: var(--text-faint); border-top: 1px solid var(--border-strong); padding-top: 12px; }

.main { flex: 1; overflow-y: auto; }
.page { max-width: 980px; margin: 0 auto; padding: 34px 40px 80px; }
.page h1 { font-size: 22px; font-weight: 700; margin: 0 0 4px; letter-spacing: -0.012em; }
.page .sub { color: var(--text-dim); font-size: 13px; margin: 0 0 26px; }

/* --- Cards --- */
.card {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 18px 22px;
  margin-bottom: 16px;
}
.card h2 { font-size: 12.5px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-dim); margin: 0 0 14px; font-weight: 700; }
.card h2 .hint { text-transform: none; letter-spacing: 0; font-weight: 400; color: var(--text-faint); font-size: 12px; margin-left: 8px; }

/* flex-start, nao flex-end: toda .row tem pelo menos um campo com .note
   (uma legenda abaixo do input) e outros sem. Com flex-end, o campo mais
   alto (o que tem nota) empurra as CAIXAS dos vizinhos mais baixos para
   baixo, desalinhando os inputs entre si — a nota so deveria ocupar espaco
   embaixo do proprio campo, nunca mexer na linha dos outros. Com flex-start,
   os rotulos (todos de uma linha, mesma altura) alinham no topo, e as caixas
   de input/select ficam automaticamente na mesma altura logo abaixo — a nota
   flutua livre por baixo, sem afetar ninguem. */
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-start; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field label { font-size: 11.5px; color: var(--text-dim); font-weight: 600; }
.field .note { font-size: 11px; color: var(--text-faint); font-weight: 400; }
.field input, .field select, .field textarea {
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 7px 9px;
  font-size: 13px;
  background: var(--surface-input);
  color: var(--text);
  font-family: inherit;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--ink); box-shadow: 0 0 0 3px var(--accent-soft);
}
.field input[type=number] { width: 90px; }
.field input.w-full, .field select.w-full, .field textarea.w-full { width: 100%; }
.field.grow { flex: 1; }
.check { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--text-dim); }
.check input { width: auto; }

/* --- Botões --- */
button { font-family: inherit; cursor: pointer; }
.btn {
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  padding: 8px 14px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 700; }
.btn.primary:hover { filter: brightness(0.96); }
.btn.primary:disabled { background: var(--border); border-color: var(--border); color: var(--text-faint); cursor: not-allowed; }
.btn.danger { color: var(--danger); }
.btn.danger:hover { background: var(--danger-soft); }
.btn.ghost { border-color: transparent; background: none; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.sm { padding: 5px 9px; font-size: 12px; border-radius: var(--radius-xs); }
.btn.block { width: 100%; justify-content: center; }

/* --- Tabela de ambientes --- */
table.ambientes { width: 100%; border-collapse: collapse; font-size: 12.5px; }
table.ambientes th {
  text-align: left; font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--text-faint); font-weight: 700; padding: 0 8px 8px; border-bottom: 1px solid var(--border-strong);
}
table.ambientes td { padding: 5px 8px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.ambientes tr:last-child td { border-bottom: none; }
table.ambientes input, table.ambientes select { border: 1px solid transparent; background: transparent; padding: 5px 6px; border-radius: 5px; font-size: 12.5px; width: 100%; }
table.ambientes input:hover, table.ambientes select:hover { background: var(--surface-2); }
table.ambientes input:focus, table.ambientes select:focus { outline: none; background: var(--surface-input); border-color: var(--ink); box-shadow: 0 0 0 2px var(--accent-soft); }
table.ambientes input[type=number] { width: 64px; }
.tipo-chip { display: inline-block; padding: 1px 8px; border-radius: var(--radius-pill); font-size: 10.5px; font-weight: 700; border: 1px solid var(--border-strong); }
.badge-sugerido { color: var(--text-dim); font-size: 9px; font-weight: 700; vertical-align: super; margin-left: 2px; border: 1px solid var(--border-strong); border-radius: var(--radius-pill); padding: 0 4px; }
.reorder { display: flex; flex-direction: column; flex: none; }
.reorder .btn { padding: 0 4px; line-height: 12px; font-size: 8px; border: none; color: var(--text-faint); border-radius: 4px; }
.reorder .btn:hover { color: var(--text); background: var(--surface-2); }
.reorder .btn:disabled { opacity: 0.3; cursor: default; }
.reorder .btn:disabled:hover { background: none; }

/* --- Matriz de adjacência --- */
.matriz-wrap { overflow-x: auto; }
table.matriz { border-collapse: collapse; font-size: 11.5px; }
table.matriz th, table.matriz td { padding: 2px; text-align: center; }
table.matriz th.rot {
  height: 90px; white-space: nowrap; vertical-align: bottom; padding-bottom: 4px;
}
table.matriz th.rot > div { transform: rotate(-40deg); transform-origin: bottom left; width: 20px; }
table.matriz th.row-label { text-align: right; padding-right: 8px; white-space: nowrap; font-weight: 600; }
table.matriz select.grau {
  width: 30px; height: 26px; border: 1px solid var(--border-strong); border-radius: var(--radius-xs); font-size: 13px; text-align: center;
  appearance: none; cursor: pointer; font-weight: 700; background: var(--surface-input);
}
table.matriz td.diag { background: repeating-linear-gradient(45deg, var(--border), var(--border) 2px, transparent 2px, transparent 6px); }
.legenda-grau { display: flex; gap: 14px; margin-top: 12px; flex-wrap: wrap; font-size: 11.5px; color: var(--text-dim); }
.legenda-grau span { display: inline-flex; align-items: center; gap: 5px; }
.legenda-grau i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }

/* --- Sliders de peso --- */
.pesos-grid { display: grid; grid-template-columns: 1fr; gap: 14px; }
.peso-row { display: grid; grid-template-columns: 130px 1fr 44px; align-items: center; gap: 10px; }
.peso-row label { font-size: 12.5px; font-weight: 600; }
.peso-row .pct { font-size: 12.5px; font-weight: 700; color: var(--text); text-align: right; }
input[type=range] { width: 100%; accent-color: var(--accent); }
.pesos-soma { font-size: 11.5px; color: var(--text-faint); margin-top: 4px; }

/* --- Avisos P0 --- */
.avisos { display: flex; flex-direction: column; gap: 8px; }
.aviso { border-radius: var(--radius-xs); padding: 10px 12px; font-size: 12.5px; display: flex; gap: 9px; border: 1px solid var(--border-strong); }
.aviso.erro { background: var(--danger-soft); color: #6b2216; border-color: var(--danger); }
.aviso.leve { background: var(--surface); color: var(--text); }
.aviso b { display: block; margin-bottom: 2px; }
.aviso .fix { color: inherit; opacity: 0.75; font-size: 11.5px; }

/* --- Geração / resultados --- */
.gen-bar { display: flex; align-items: center; gap: 14px; margin-bottom: 20px; }
.spinner {
  width: 15px; height: 15px; border-radius: 50%;
  border: 2px solid var(--border-strong); border-top-color: var(--accent);
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.diag-line { font-size: 12px; color: var(--text-dim); }

.opcoes-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.opcao-card {
  background: var(--surface); border: 1.5px solid var(--border-strong); border-radius: var(--radius-lg);
  padding: 12px; cursor: pointer; transition: border-color .12s, transform .12s;
}
.opcao-card:hover { border-color: var(--ink); transform: translateY(-1px); }
.opcao-card.sel { border-color: var(--ink); border-width: 2px; box-shadow: 3px 3px 0 var(--accent); }
.opcao-card .top { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 6px; }
.opcao-card .nota { font-size: 21px; font-weight: 700; color: var(--text); }
.opcao-card .rank { font-size: 10.5px; color: var(--text-faint); font-weight: 700; }
.opcao-card svg { width: 100%; height: auto; display: block; background: var(--surface-2); border-radius: var(--radius-sm); }
.opcao-card .eixos { display: flex; gap: 5px; margin-top: 8px; font-size: 9.5px; }
.opcao-card .eixos span { flex: 1; text-align: center; padding: 2px 0; border-radius: 5px; background: var(--surface-2); color: var(--text-dim); font-weight: 700; }
.opcao-card.pouco-diverso { opacity: 0.68; }
.opcao-card .flag { font-size: 9.5px; color: var(--text-faint); margin-top: 4px; }

/* --- Detalhe da opção selecionada --- */
.detalhe-grid { display: grid; grid-template-columns: 1.3fr 1fr; gap: 20px; align-items: start; }
.plantas-tabs { display: flex; gap: 6px; margin-bottom: 10px; }
.plantas-tabs button { padding: 5px 12px; border-radius: var(--radius-pill); border: 1px solid var(--border-strong); background: var(--surface); font-size: 12px; font-weight: 500; }
.plantas-tabs button.active { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 700; }
.planta-box { background: var(--surface-2); border: 1px solid var(--border-strong); border-radius: var(--radius-lg); padding: 10px; }
.planta-box svg { width: 100%; height: auto; display: block; }

.justif h3 { font-size: 12px; text-transform: uppercase; letter-spacing: 0.03em; color: var(--text-dim); margin: 16px 0 8px; }
.justif h3:first-child { margin-top: 0; }
.justif .resumo { font-size: 13.5px; font-weight: 600; margin-bottom: 4px; }
.chiplist { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font-size: 11.5px; padding: 3px 10px; border-radius: var(--radius-pill); border: 1px solid var(--border-strong); }
.chip.forte { background: var(--ok-soft); color: #1c4d34; border-color: var(--ok); }
.chip.fraco { background: var(--danger-soft); color: #6b2216; border-color: var(--danger); }
.ressalvas { margin: 0; padding-left: 16px; font-size: 12.5px; color: var(--text-dim); }
.ressalvas li { margin-bottom: 4px; }

.eixos-detalhe { display: grid; grid-template-columns: 1fr; gap: 8px; margin-top: 4px; }
.eixo-bar { display: grid; grid-template-columns: 90px 1fr 32px; align-items: center; gap: 8px; font-size: 11.5px; }
.eixo-bar .track { height: 6px; background: var(--border); border-radius: 4px; overflow: hidden; }
.eixo-bar .fill { height: 100%; background: var(--accent); }

.empty-state { text-align: center; padding: 60px 20px; color: var(--text-faint); }
.empty-state .big { font-size: 34px; margin-bottom: 10px; }

.section-actions { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.tipo-legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: 11px; color: var(--text-dim); margin-top: 10px; }
.tipo-legend span { display: inline-flex; align-items: center; gap: 5px; }
.tipo-legend i { width: 10px; height: 10px; border-radius: 3px; border: 1px solid var(--border-strong); }
