/* ---------------------------------------------------------------------------
   wai-uw · UserWorker — design system "cool monochrome" (dr-page) + soft
   elevation. Tokens em oklch. Tipografia Nunito (corpo), Playfair Display
   (titulos), DM Serif Display (marca), Lato (enfase), Roboto Mono (rotulos).
--------------------------------------------------------------------------- */

:root {
  --background: oklch(0.99 0 0);
  --foreground: oklch(0.15 0 0);
  --card: oklch(1 0 0);
  --card-foreground: oklch(0.15 0 0);
  --primary: oklch(0.15 0 0);
  --primary-foreground: oklch(0.99 0 0);
  --secondary: oklch(0.95 0 0);
  --secondary-foreground: oklch(0.15 0 0);
  --muted: oklch(0.92 0 0);
  --muted-foreground: oklch(0.5 0 0);
  --accent: oklch(0.88 0 0);
  --accent-foreground: oklch(0.15 0 0);
  --destructive: oklch(0.577 0.245 27.325);
  --destructive-foreground: oklch(0.985 0 0);
  --border: oklch(0.88 0 0);
  --input: oklch(0.88 0 0);
  --ring: oklch(0.15 0 0);

  --ok: oklch(0.66 0.11 170);
  --andamento: oklch(0.7 0.1 85);

  --radius-sm: 0.5rem;
  --radius-md: 0.75rem;
  --radius-lg: 1rem;
  --radius-xl: 1.25rem;
  --radius-2xl: 1.5rem;

  --shadow-xs: 0 1px 2px rgba(26, 26, 26, 0.04);
  --shadow-sm: 0 1px 2px rgba(26, 26, 26, 0.05), 0 2px 6px rgba(26, 26, 26, 0.04);
  --shadow-md: 0 2px 4px rgba(26, 26, 26, 0.05), 0 6px 16px rgba(26, 26, 26, 0.06);
  --shadow-card: 0 1px 2px rgba(26, 26, 26, 0.04), 0 8px 24px rgba(26, 26, 26, 0.06);
  --shadow-card-hover: 0 4px 8px rgba(26, 26, 26, 0.05), 0 12px 32px rgba(26, 26, 26, 0.08);

  --font-sans: "Nunito", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-serif: "Playfair Display", ui-serif, Georgia, serif;
  --font-display: "DM Serif Display", ui-serif, Georgia, serif;
  --font-emphasis: "Lato", ui-sans-serif, system-ui, sans-serif;
  --font-mono: "Roboto Mono", ui-monospace, "SF Mono", monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --background: oklch(0.1 0 0);
    --foreground: oklch(0.98 0 0);
    --card: oklch(0.12 0 0);
    --card-foreground: oklch(0.98 0 0);
    --primary: oklch(0.98 0 0);
    --primary-foreground: oklch(0.1 0 0);
    --secondary: oklch(0.2 0 0);
    --secondary-foreground: oklch(0.98 0 0);
    --muted: oklch(0.2 0 0);
    --muted-foreground: oklch(0.6 0 0);
    --accent: oklch(0.25 0 0);
    --accent-foreground: oklch(0.98 0 0);
    --destructive: oklch(0.396 0.141 25.723);
    --border: oklch(0.25 0 0);
    --input: oklch(0.25 0 0);
    --ring: oklch(0.98 0 0);
    --ok: oklch(0.7 0.12 165);
    --andamento: oklch(0.72 0.1 80);
    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.24);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.28), 0 2px 6px rgba(0, 0, 0, 0.22);
    --shadow-md: 0 2px 4px rgba(0, 0, 0, 0.3), 0 6px 16px rgba(0, 0, 0, 0.32);
    --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.26), 0 8px 24px rgba(0, 0, 0, 0.32);
    --shadow-card-hover: 0 4px 8px rgba(0, 0, 0, 0.3), 0 12px 32px rgba(0, 0, 0, 0.4);
  }
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--background);
  color: var(--foreground);
  font-family: var(--font-sans);
  font-weight: 300;
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
}

strong,
b {
  font-family: var(--font-emphasis);
  font-weight: 600;
}

::selection {
  background: color-mix(in oklab, var(--foreground) 16%, transparent);
}

header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  background: color-mix(in oklab, var(--card) 72%, transparent);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.marca {
  display: flex;
  align-items: baseline;
  gap: 10px;
  font-family: var(--font-display);
  font-size: 20px;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.marca .eyebrow {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted-foreground);
}

header select {
  flex: 1;
  max-width: 440px;
  background: var(--card);
  color: var(--foreground);
  border: 1px solid var(--input);
  border-radius: var(--radius-md);
  padding: 8px 12px;
  font: inherit;
  font-family: var(--font-emphasis);
  font-weight: 400;
  box-shadow: var(--shadow-xs);
}

.conexao {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.04em;
  color: var(--muted-foreground);
  white-space: nowrap;
}

main {
  flex: 1;
  display: grid;
  grid-template-columns: 268px 1fr 312px;
  gap: 16px;
  padding: 16px;
  min-height: 0;
}

.painel {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-height: 0;
  overflow-y: auto;
}

.cartao {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 16px;
  box-shadow: var(--shadow-card);
  transition: box-shadow 0.3s ease;
}

.cartao:hover {
  box-shadow: var(--shadow-card-hover);
}

.cartao h2 {
  margin: 0 0 12px;
  font-family: var(--font-serif);
  font-weight: 500;
  font-size: 20px;
  letter-spacing: -0.01em;
}

.cartao h3 {
  margin: 0 0 10px;
  font-family: var(--font-emphasis);
  font-weight: 700;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--muted-foreground);
}

.linha {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  padding: 5px 0;
  font-size: 13px;
}

.linha span {
  color: var(--muted-foreground);
  font-family: var(--font-emphasis);
  font-weight: 400;
}

.linha b {
  font-family: var(--font-mono);
  font-weight: 400;
  font-size: 12px;
  letter-spacing: 0.01em;
}

.acoes {
  display: flex;
  gap: 8px;
  margin-top: 14px;
}

button {
  background: var(--primary);
  color: var(--primary-foreground);
  border: 0;
  border-radius: var(--radius-md);
  padding: 8px 14px;
  cursor: pointer;
  font-family: var(--font-emphasis);
  font-weight: 400;
  font-size: 13px;
  box-shadow: var(--shadow-xs);
  transition: opacity 0.2s ease, transform 0.15s ease, box-shadow 0.2s ease;
}

button:hover {
  opacity: 0.9;
}

button:active {
  transform: translateY(1px);
}

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

.lista {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 340px;
  overflow-y: auto;
}

.lista li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border-radius: var(--radius-md);
  cursor: pointer;
  font-size: 13px;
  transition: background 0.2s ease;
}

.lista li:hover {
  background: var(--muted);
}

.lista .nome {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lista .meta,
.lista .tipo {
  color: var(--muted-foreground);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.02em;
}

.badge {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.04em;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--andamento);
  color: var(--primary-foreground);
}

.badge.ok {
  background: var(--ok);
  color: var(--primary-foreground);
}

.badge.erro {
  background: var(--destructive);
  color: var(--destructive-foreground);
}

.conversa-area {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
}

.conversa {
  flex: 1;
  overflow-y: auto;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 18px;
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.msg {
  padding: 11px 14px;
  border-radius: var(--radius-md);
  white-space: pre-wrap;
  max-width: 82%;
  line-height: 1.6;
}

.msg.user {
  align-self: flex-end;
  background: var(--primary);
  color: var(--primary-foreground);
  border-bottom-right-radius: 0.25rem;
}

.msg.assistant {
  align-self: flex-start;
  background: var(--secondary);
  color: var(--secondary-foreground);
  border: 1px solid var(--border);
  border-bottom-left-radius: 0.25rem;
}

.msg.evento {
  align-self: center;
  background: transparent;
  color: var(--muted-foreground);
  font-family: var(--font-mono);
  font-size: 11px;
  max-width: 100%;
}

.fontes {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.02em;
  color: var(--muted-foreground);
}

.entrada {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

.entrada textarea {
  flex: 1;
  resize: none;
  min-height: 52px;
  background: var(--card);
  color: var(--foreground);
  border: 1px solid var(--input);
  border-radius: var(--radius-md);
  padding: 11px 13px;
  font: inherit;
  font-weight: 300;
  box-shadow: var(--shadow-xs);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.entrada textarea:focus,
.filtro input:focus {
  outline: none;
  border-color: var(--ring);
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--ring) 16%, transparent);
}

.entrada button {
  height: 52px;
  padding: 0 20px;
  border-radius: var(--radius-md);
}

.filtro {
  display: flex;
  gap: 6px;
  margin-bottom: 10px;
}

.filtro input {
  flex: 1;
  background: var(--card);
  color: var(--foreground);
  border: 1px solid var(--input);
  border-radius: var(--radius-md);
  padding: 7px 10px;
  font: inherit;
  font-weight: 300;
  box-shadow: var(--shadow-xs);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.filtro button {
  background: var(--secondary);
  color: var(--secondary-foreground);
  border: 1px solid var(--border);
  padding: 7px 12px;
}

@media (max-width: 1100px) {
  main {
    grid-template-columns: 1fr;
    overflow-y: auto;
  }
  .conversa {
    min-height: 50vh;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}