:root {
  --bg: #0b0f14;
  --surface: #11161d;
  --surface-2: #161d26;
  --border: #232c38;
  --text: #e6edf3;
  --muted: #8b98a9;
  --primary: #22c55e;
  --primary-strong: #16a34a;
  --danger: #ef4444;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}

a { color: var(--primary); }

h1, h2 { line-height: 1.2; }

.muted { color: var(--muted); font-size: 0.9rem; }

/* Marca */
.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
  color: var(--text);
  font-weight: 700;
  font-size: 1.1rem;
}
.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  border-radius: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
}

/* Botões */
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.6rem 1rem;
  border-radius: var(--radius);
  border: 1px solid transparent;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.button-primary { background: var(--primary); color: #04140a; }
.button-primary:hover { background: var(--primary-strong); }
.button-outline { background: transparent; border-color: var(--border); color: var(--text); }
.button-outline:hover { background: var(--surface-2); }
.button-danger { background: var(--danger); color: #fff; }
.button-icon { background: transparent; border-color: var(--border); color: var(--text); padding: 0.4rem 0.7rem; }
.button-block { width: 100%; }
.link-button {
  background: none;
  border: none;
  color: var(--primary);
  cursor: pointer;
  font: inherit;
  font-size: 0.85rem;
  padding: 0;
  white-space: nowrap;
}

/* Topbar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 10;
}

/* Autenticação */
.auth-body { min-height: 100vh; display: grid; place-items: center; padding: 2rem 1rem; }
.auth-shell {
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  gap: 3rem;
  max-width: 980px;
  width: 100%;
  align-items: center;
}
.auth-hero h1 { font-size: 2.2rem; margin: 1rem 0 0.5rem; }
.auth-hero p { color: var(--muted); }
.hero-list { color: var(--muted); padding-left: 1.2rem; }
.hero-list li { margin: 0.4rem 0; }

.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.5rem;
}
.tabs { display: flex; gap: 0.5rem; margin-bottom: 1.25rem; }
.tab {
  flex: 1;
  padding: 0.55rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.tab.active { background: var(--surface-2); color: var(--text); border-color: var(--primary); }

.field { margin-bottom: 1rem; }
.field label { display: block; font-size: 0.9rem; margin-bottom: 0.35rem; }
.field input {
  width: 100%;
  padding: 0.65rem 0.8rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
}
.field input:focus { outline: 2px solid var(--primary); outline-offset: 1px; }
.password-row { display: flex; gap: 0.6rem; align-items: center; }

.terms-check { margin: 0.25rem 0 1rem; }
.checkbox-label { display: flex; gap: 0.55rem; align-items: flex-start; font-size: 0.9rem; color: var(--muted); cursor: pointer; }
.checkbox-label input { margin-top: 0.3rem; accent-color: var(--primary); }

.form-error {
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid var(--danger);
  color: #fca5a5;
  border-radius: var(--radius);
  padding: 0.6rem 0.8rem;
  font-size: 0.9rem;
}
.auth-note { margin-top: 1rem; font-size: 0.8rem; color: var(--muted); text-align: center; }

/* Termos */
.terms-shell { max-width: 760px; margin: 0 auto; padding: 2rem 1.25rem 4rem; }
.terms-meta { color: var(--muted); font-size: 0.9rem; }
.terms-list section { margin-top: 2rem; }
.terms-list h2 { font-size: 1.15rem; margin-bottom: 0.5rem; }
.terms-list p { color: var(--muted); margin: 0.4rem 0; }

/* App / conversa */
.app-body { height: 100vh; overflow: hidden; }
.app-shell { display: grid; grid-template-columns: 280px 1fr; height: 100vh; }
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.sidebar-nav { display: flex; flex-direction: column; gap: 0.35rem; flex: 1; }
.sidebar-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.55rem 0.7rem;
  border-radius: var(--radius);
  border: none;
  background: transparent;
  color: var(--muted);
  font: inherit;
  cursor: pointer;
  text-decoration: none;
}
.sidebar-item:hover, .sidebar-item.active { background: var(--surface-2); color: var(--text); }
.sidebar-foot { display: flex; flex-direction: column; gap: 0.35rem; border-top: 1px solid var(--border); padding-top: 0.75rem; }

.chat { display: flex; flex-direction: column; min-width: 0; }
.chat-topbar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.chat-topbar h1 { font-size: 1.05rem; margin: 0; }
#toggle-sidebar { display: none; }

.messages { flex: 1; overflow-y: auto; padding: 1.5rem; display: flex; flex-direction: column; gap: 1rem; }
.message { max-width: 720px; padding: 0.85rem 1rem; border-radius: 14px; }
.message p { margin: 0; }
.message-assistant { background: var(--surface-2); border: 1px solid var(--border); align-self: flex-start; }
.message-user { background: rgba(34, 197, 94, 0.14); border: 1px solid var(--primary); align-self: flex-end; }

.suggestions { display: flex; flex-wrap: wrap; gap: 0.5rem; padding: 0 1.5rem 0.75rem; }
.chip {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  border-radius: 999px;
  padding: 0.4rem 0.9rem;
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
}
.chip:hover { color: var(--text); border-color: var(--primary); }

.composer { display: flex; gap: 0.6rem; padding: 0.9rem 1.5rem 1.25rem; border-top: 1px solid var(--border); background: var(--surface); }
.composer input {
  flex: 1;
  padding: 0.7rem 0.9rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
}
.composer input:focus { outline: 2px solid var(--primary); outline-offset: 1px; }

/* Configurações */
.settings-shell { max-width: 720px; margin: 0 auto; padding: 2rem 1.25rem 4rem; display: flex; flex-direction: column; gap: 1.25rem; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 1.25rem; }
.card h2 { margin-top: 0; font-size: 1.1rem; }
.switch-row { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: 0.6rem 0; color: var(--muted); }
.switch-row input { accent-color: var(--primary); width: 1.1rem; height: 1.1rem; }
.row { display: flex; flex-wrap: wrap; gap: 0.6rem; margin-top: 0.75rem; }

/* Responsivo */
@media (max-width: 860px) {
  .auth-shell { grid-template-columns: 1fr; gap: 1.75rem; }
  .auth-hero h1 { font-size: 1.7rem; }
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 280px;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    z-index: 20;
  }
  .sidebar.open { transform: translateX(0); }
  #toggle-sidebar { display: inline-flex; }
}

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