/* ============================================================
   PATTERN ENGINE — Design System
   Paleta: preto profundo, cinza estrutural, branco cirúrgico
   Tipografia: mono exclusivo
   Filosofia: brutalismo funcional
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@300;400;700&display=swap');

:root {
  --bg:           #080809;
  --surface:      #0d0d0f;
  --panel:        #0f0f11;
  --panel-alt:    #111114;
  --border:       #1c1c20;
  --border-light: #252529;
  --accent:       #e8e8ec;
  --accent-muted: #3a3a40;
  --accent-dim:   #232328;
  --text:         #6a6a72;
  --text-mid:     #9a9aa4;
  --text-bright:  #dddde6;
  --text-faint:   #3a3a40;

  /* Semânticas */
  --ok:     #10b981;
  --warn:   #f59e0b;
  --err:    #ef4444;
  --info:   #3b82f6;
  --purple: #8b5cf6;
  --cyan:   #06b6d4;

  --font-mono: 'JetBrains Mono', 'Fira Code', ui-monospace, monospace;
  --header-h: 48px;
  --panel-w:  400px;
  --radius:   0px;
}

/* ---- Reset ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100vh;
  width: 100vw;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.5;
  letter-spacing: -0.01em;
  -webkit-font-smoothing: antialiased;
}

/* ============================================================
   HEADER
   ============================================================ */

header {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: var(--header-h);
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 20px;
  z-index: 1000;
  gap: 0;
}

.header-inner {
  display: flex;
  align-items: center;
  width: 100%;
  justify-content: space-between;
}

.logo {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.15em;
  color: var(--text-bright);
  text-decoration: none;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  gap: 10px;
  user-select: none;
}

.logo::before {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  background: var(--accent);
  flex-shrink: 0;
}

.logo-sub {
  font-size: 10px;
  font-weight: 400;
  color: var(--text-faint);
  letter-spacing: 0.05em;
  padding-left: 10px;
  border-left: 1px solid var(--border);
  margin-left: 4px;
}

/* ============================================================
   NAV
   ============================================================ */

nav {
  display: flex;
  border: 1px solid var(--border);
}

nav a {
  color: var(--text);
  text-decoration: none;
  text-transform: uppercase;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  padding: 7px 16px;
  border-right: 1px solid var(--border);
  transition: color 0.1s, background 0.1s;
  white-space: nowrap;
}

nav a:last-child { border-right: none; }

nav a.active {
  color: var(--bg);
  background: var(--accent);
}

nav a:hover:not(.active) {
  color: var(--text-bright);
  background: var(--accent-dim);
}

/* ============================================================
   LAYOUT
   ============================================================ */

.layout {
  display: flex;
  position: absolute;
  top: var(--header-h);
  bottom: 0; left: 0; right: 0;
}

/* Painel do grafo / área principal */
.graph-panel {
  flex: 1;
  position: relative;
  overflow: hidden;
  background: var(--bg);
  background-image: radial-gradient(var(--border) 1px, transparent 0);
  background-size: 36px 36px;
}

#graph { width: 100%; height: 100%; }

/* Painel lateral */
.side-panel {
  width: var(--panel-w);
  min-width: 320px;
  background: var(--panel);
  border-left: 1px solid var(--border);
  overflow-y: auto;
  overflow-x: hidden;
  padding: 20px;
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ============================================================
   CARDS
   ============================================================ */

.card {
  border: 1px solid var(--border);
  padding: 16px;
  background: var(--surface);
  flex-shrink: 0;
}

/* ============================================================
   TIPOGRAFIA
   ============================================================ */

h2 {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-bright);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 12px;
}

h3 {
  font-size: 10px;
  font-weight: 700;
  color: var(--text);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}

h3::before {
  content: '';
  display: inline-block;
  width: 3px;
  height: 10px;
  background: var(--accent-muted);
  flex-shrink: 0;
}

h4 {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-mid);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
}

p {
  font-size: 11px;
  color: var(--text);
  line-height: 1.6;
}

.muted {
  color: var(--text-faint);
  font-size: 10px;
}

small {
  font-size: 9px;
  color: var(--text);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ============================================================
   FORMULÁRIOS
   ============================================================ */

textarea {
  width: 100%;
  height: 100px;
  background: var(--bg);
  color: var(--text-bright);
  border: 1px solid var(--border);
  padding: 10px 12px;
  margin-bottom: 10px;
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.5;
  outline: none;
  resize: none;
  display: block;
}

textarea:focus {
  border-color: var(--accent-muted);
  background: var(--surface);
}

textarea::placeholder {
  color: var(--text-faint);
}

input[type="text"],
input[type="search"],
select {
  background: var(--bg);
  color: var(--text-bright);
  border: 1px solid var(--border);
  padding: 7px 10px;
  font-family: var(--font-mono);
  font-size: 11px;
  outline: none;
  width: 100%;
}

input:focus, select:focus {
  border-color: var(--accent-muted);
}

select option {
  background: var(--panel);
}

label {
  font-size: 9px;
  color: var(--text);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  display: block;
  margin-bottom: 4px;
}

/* ============================================================
   BOTÕES
   ============================================================ */

button {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-mid);
  padding: 8px 16px;
  font-size: 10px;
  font-weight: 700;
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  cursor: pointer;
  transition: color 0.1s, background 0.1s, border-color 0.1s;
  white-space: nowrap;
}

button:hover {
  border-color: var(--accent-muted);
  color: var(--text-bright);
  background: var(--accent-dim);
}

button.primary {
  border-color: var(--accent);
  color: var(--accent);
}

button.primary:hover {
  background: var(--accent);
  color: var(--bg);
}

button:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

button.btn-full { width: 100%; }

.btn-row {
  display: flex;
  gap: 8px;
}

/* ============================================================
   STATS / MÉTRICAS
   ============================================================ */

.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border: 1px solid var(--border);
  overflow: hidden;
}

.stat {
  display: flex;
  flex-direction: column;
  padding: 14px 16px;
  border-right: 1px solid var(--border);
}

.stat:last-child { border-right: none; }

.stat span {
  font-size: 22px;
  color: var(--text-bright);
  font-weight: 300;
  line-height: 1;
}

.stat label {
  font-size: 9px;
  color: var(--text);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-top: 6px;
}

/* ============================================================
   LEGEND / TOOLBAR
   ============================================================ */

.toolbar {
  position: absolute;
  top: 16px;
  left: 16px;
  pointer-events: none;
  z-index: 10;
}

.legend {
  display: flex;
  flex-direction: column;
  gap: 6px;
  pointer-events: auto;
  background: var(--panel);
  border: 1px solid var(--border);
  padding: 10px 12px;
}

.legend span {
  font-size: 9px;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.legend i {
  width: 8px;
  height: 2px;
  display: inline-block;
  flex-shrink: 0;
}

/* ============================================================
   LISTAS / ITEMS
   ============================================================ */

.list-item {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-top: none;
  font-size: 11px;
  color: var(--text);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.list-item:first-child { border-top: 1px solid var(--border); }

.list-item:hover {
  background: var(--accent-dim);
  color: var(--text-bright);
  cursor: pointer;
}

/* ============================================================
   EXPERIMENTOS / STEPS
   ============================================================ */

.step {
  padding: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  margin-bottom: 6px;
  color: var(--text);
  transition: border-color 0.15s;
}

.step h4 { margin-bottom: 6px; }

.step.active {
  border-color: var(--accent-muted);
  color: var(--text-bright);
  background: var(--accent-dim);
}

.step.active h4 { color: var(--text-bright); }

.step.done {
  border-color: var(--text-faint);
  opacity: 0.5;
}

.step-status {
  font-size: 10px;
  color: var(--text);
}

/* ============================================================
   PRE / CODE
   ============================================================ */

pre, code {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-bright);
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 10px 12px;
  overflow-x: auto;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

/* ============================================================
   NODE DETAIL
   ============================================================ */

#node-detail {
  color: var(--text);
  font-size: 11px;
  line-height: 1.6;
}

#node-detail strong {
  color: var(--text-bright);
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  display: block;
  margin-top: 10px;
  margin-bottom: 2px;
}

#node-detail strong:first-child { margin-top: 0; }

/* ============================================================
   OBSERVER — ESPECÍFICO
   ============================================================ */

#insights-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.insight-item {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-left: 2px solid var(--accent-muted);
  font-size: 10px;
  color: var(--text);
  line-height: 1.5;
}

/* ============================================================
   GENESIS — ESPECÍFICO
   ============================================================ */

#genesis-panel {
  display: flex;
  flex-direction: column;
}

.genesis-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
  flex-shrink: 0;
}

#genesis-frame {
  flex: 1;
  border: none;
  background: #000;
  width: 100%;
  display: block;
}

/* ============================================================
   CANVAS — ESPECÍFICO
   ============================================================ */

#experiment-view {
  padding: 20px;
  height: 100%;
  overflow-y: auto;
}

#empty-state {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  flex-direction: column;
  gap: 12px;
  color: var(--text-faint);
}

#empty-state h3 {
  color: var(--text-faint);
  font-size: 10px;
}

#empty-state h3::before { background: var(--text-faint); }

/* ============================================================
   FILTERS
   ============================================================ */

.filter-row {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
  align-items: flex-end;
}

.filter-row > * { flex: 1; }

/* ============================================================
   RESULT FIELDS
   ============================================================ */

.field {
  margin-bottom: 10px;
}

.field label {
  font-size: 9px;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 3px;
  display: block;
}

.field p {
  font-size: 11px;
  color: var(--text-bright);
  line-height: 1.5;
  word-break: break-word;
}

/* ============================================================
   ESTADOS
   ============================================================ */

.hidden { display: none !important; }

.tag {
  display: inline-block;
  padding: 2px 6px;
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border: 1px solid currentColor;
}

.tag-ok     { color: var(--ok); }
.tag-warn   { color: var(--warn); }
.tag-err    { color: var(--err); }
.tag-info   { color: var(--info); }

/* ============================================================
   SCROLLBAR
   ============================================================ */

::-webkit-scrollbar { width: 3px; height: 3px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); }
::-webkit-scrollbar-thumb:hover { background: var(--accent-muted); }

/* ============================================================
   GRAPH — SVG OVERRIDES
   ============================================================ */

.node-label {
  font-family: var(--font-mono);
  font-size: 9px;
  fill: var(--text);
  pointer-events: none;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.link {
  stroke-opacity: 0.4;
}

.link:hover {
  stroke-opacity: 0.9;
}

/* Extract narrative + results */
.narrative {
  font-style: italic;
  color: #a0c4ff;
  border-left: 3px solid #4a7fbd;
  padding: 8px 12px;
  margin-bottom: 12px;
  line-height: 1.6;
  background: rgba(74, 127, 189, 0.08);
  border-radius: 0 4px 4px 0;
}
.decomposition {
  font-family: monospace;
  font-size: 0.85em;
  color: #ffb38f;
  border-left: 3px solid #e67e22;
  padding: 8px 12px;
  margin-bottom: 12px;
  line-height: 1.6;
  background: rgba(230, 126, 34, 0.08);
  border-radius: 0 4px 4px 0;
}
.patterns-extracted {
  color: #b8f0b8;
  font-family: monospace;
  font-size: 0.85em;
  line-height: 1.7;
}
.orbit-warn {
  color: #ffd080;
  font-size: 0.85em;
  margin-bottom: 8px;
}
