:root {
  /* Paleta — DESIGN_SYSTEM.md */
  --primary: #F71E3D;
  --primary-dark: #c4172f;
  --primary-light: #f94d67;
  --secondary: #25373B;
  --secondary-dark: #1B292C;
  --secondary-light: #344D52;
  --bg-base: #F5F5F5;
  --bg-white: #FFFFFF;
  --border-subtle: #E0E0E0;
  --border-light: #EEEEEE;
  --border-primary: rgba(247, 30, 61, 0.32);
  --text-primary: #212121;
  --text-secondary: #757575;
  --text-muted: #9E9E9E;
  --grad-primary: linear-gradient(135deg, #c4172f, #F71E3D, #f94d67);

  /* Aliases */
  --text-gold: var(--primary);
  --grad-gold: var(--grad-primary);
  --border-gold: var(--border-primary);

  /* Derivados sem literais nas regras */
  --text-on-secondary: #FFFFFF;
  --text-on-secondary-muted: color-mix(in srgb, var(--text-on-secondary) 65%, transparent);
  --primary-tint: color-mix(in srgb, var(--primary) 10%, var(--bg-white));
  --primary-tint-strong: color-mix(in srgb, var(--primary) 16%, var(--bg-white));
  --secondary-tint: color-mix(in srgb, var(--secondary-light) 12%, var(--bg-white));
  --focus-ring: color-mix(in srgb, var(--primary) 22%, transparent);
  --glow-primary: color-mix(in srgb, var(--primary) 38%, transparent);
  --glass-bg: color-mix(in srgb, var(--bg-white) 68%, transparent);
  --grid-line: color-mix(in srgb, var(--secondary) 7%, transparent);

  /* Layout */
  --radius: 12px;
  --radius-pill: 999px;
  --shadow-sm: 0 1px 3px color-mix(in srgb, var(--secondary) 8%, transparent);
  --shadow-md: 0 4px 16px color-mix(in srgb, var(--secondary) 10%, transparent);
  --font: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font);
  background: var(--bg-base);
  color: var(--text-primary);
  height: 100vh;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

.app {
  display: flex;
  height: 100vh;
}

/* Utilitários — DESIGN_SYSTEM.md */
.bg-grid {
  background-color: var(--bg-base);
  background-image:
    linear-gradient(to right, var(--grid-line) 1px, transparent 1px),
    linear-gradient(to bottom, var(--grid-line) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(ellipse 90% 80% at 50% 45%, black 30%, transparent 100%);
}

.glass {
  background: var(--glass-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: var(--shadow-md);
}

.btn-gold {
  background: var(--grad-primary);
  border: none;
  color: var(--text-on-secondary);
  cursor: pointer;
  font-family: inherit;
  transition: filter 0.15s, box-shadow 0.15s, transform 0.1s;
}

.btn-gold:hover:not(:disabled) {
  filter: brightness(1.08);
  box-shadow: 0 0 18px var(--glow-primary);
}

.btn-gold:active:not(:disabled) {
  transform: scale(0.97);
}

.btn-gold:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-outline-gold {
  background: transparent;
  border: 1px solid var(--border-gold);
  color: var(--text-on-secondary);
  cursor: pointer;
  font-family: inherit;
  transition: filter 0.15s, box-shadow 0.15s, background 0.15s, border-color 0.15s;
}

.btn-outline-gold:hover {
  filter: brightness(1.08);
  box-shadow: 0 0 14px var(--glow-primary);
  border-color: var(--primary);
  background: color-mix(in srgb, var(--primary) 12%, transparent);
}

.text-grad-gold {
  background: var(--grad-primary);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* Login — dois painéis com slide (login ⇄ interesse comercial) */
.login-screen {
  position: fixed;
  inset: 0;
  z-index: 100;
  overflow: hidden;
  background: var(--bg-base);
}

.login-screen[hidden] {
  display: none !important;
}

.login-branding,
.login-form-panel {
  position: absolute;
  top: 0;
  bottom: 0;
  transition: left 0.7s cubic-bezier(0.4, 0, 0.2, 1), width 0.7s cubic-bezier(0.4, 0, 0.2, 1);
}

.login-branding {
  left: 0;
  width: 52%;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 40px;
  overflow: hidden;
  background: linear-gradient(135deg, var(--secondary-dark) 0%, var(--secondary) 55%, var(--secondary-light) 100%);
  color: var(--text-on-secondary);
}

.login-branding::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.05) 1px, transparent 1px);
  background-size: 40px 40px;
  mask-image: radial-gradient(ellipse 90% 80% at 50% 40%, black 20%, transparent 90%);
  pointer-events: none;
}

.login-branding::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--grad-primary);
}

.login-branding-content {
  position: relative;
  z-index: 1;
}

.login-branding-logo img {
  height: 32px;
  width: auto;
  position: relative;
  z-index: 1;
}

.login-headline {
  font-size: 30px;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.25;
  margin-bottom: 12px;
}

.login-tagline {
  font-size: 13px;
  color: var(--text-on-secondary-muted);
  max-width: 340px;
  line-height: 1.55;
  margin-bottom: 24px;
}

.login-features {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.login-feature {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  color: var(--text-on-secondary);
}

.login-feature-icon {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: rgba(247, 30, 61, 0.15);
  border: 1px solid rgba(247, 30, 61, 0.30);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.login-branding-copyright {
  position: relative;
  z-index: 1;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.35);
}

.login-form-panel {
  left: 52%;
  width: 48%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-screen.state-interest .login-branding {
  left: 48%;
}

.login-screen.state-interest .login-form-panel {
  left: 0;
  width: 48%;
}

.form-card {
  width: 100%;
  max-width: 400px;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border-subtle);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.12), 0 2px 8px rgba(0, 0, 0, 0.06);
}

.form-card[hidden] {
  display: none !important;
}

.form-card-header {
  position: relative;
  padding: 20px 24px 18px;
  background: linear-gradient(135deg, var(--secondary) 0%, var(--secondary-dark) 100%);
  color: var(--text-on-secondary);
}

.form-card-header::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--grad-primary);
}

.form-card-mark {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background: var(--grad-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  margin-bottom: 12px;
}

.form-card-mark.logo-mark {
  background: none;
}

.form-card-header h2 {
  font-size: 20px;
  font-weight: 800;
}

.form-card-sub {
  font-size: 0.82rem;
  color: var(--text-on-secondary-muted);
  margin-top: 4px;
}

.form-card-body {
  background: var(--bg-white);
  padding: 20px 24px 22px;
}

.form-separator {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 18px 0 4px;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.form-separator::before,
.form-separator::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border-light);
}

.form-switch-link {
  display: block;
  text-align: center;
  margin-top: 14px;
  font-size: 0.82rem;
  color: var(--text-muted);
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  width: 100%;
  transition: color 0.15s;
}

.form-switch-link:hover {
  color: var(--primary);
}

.interest-form textarea {
  resize: none;
  min-height: 72px;
}

@media (max-width: 1023px) {
  .login-branding {
    display: none;
  }

  .login-screen.state-interest .login-form-panel,
  .login-form-panel {
    left: 0;
    width: 100%;
  }
}

/* Card pattern */
.card {
  background: var(--bg-white);
  border: 1px solid var(--border-light);
  box-shadow: var(--shadow-md);
  border-radius: var(--radius);
}

.card-header {
  border-bottom: 1px solid var(--border-light);
}

/* Sidebar — sempre var(--secondary), collapse 280px <-> 64px */
.sidebar {
  width: 280px;
  background: var(--secondary);
  border-right: 1px solid var(--secondary-dark);
  display: flex;
  flex-direction: column;
  padding: 20px 16px;
  flex-shrink: 0;
  transition: width 0.3s ease, padding 0.3s ease, transform 0.25s ease;
  overflow: hidden;
}

.sidebar.collapsed {
  width: 64px;
  padding: 20px 12px;
}

.sidebar.collapsed .sidebar-label,
.sidebar.collapsed .sidebar-footer-text,
.sidebar.collapsed .pill-label {
  display: none;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 28px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--secondary-dark);
}

.sidebar.collapsed .sidebar-header {
  flex-direction: column;
  gap: 12px;
}

.brand {
  display: block;
  text-decoration: none;
  min-width: 0;
  overflow: hidden;
}

.brand-logo {
  height: 36px;
  width: auto;
  display: block;
  max-width: 100%;
  object-fit: contain;
}

.brand-logo-icon {
  display: none;
}

.sidebar.collapsed .brand-logo-full {
  display: none;
}

.sidebar.collapsed .brand-logo-icon {
  display: block;
  height: 28px;
  margin: 0 auto;
}

.sidebar-collapse-btn {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: transparent;
  border: none;
  color: var(--text-on-secondary-muted);
  cursor: pointer;
  transition: color 0.15s, background 0.15s, transform 0.2s;
}

.sidebar-collapse-btn:hover {
  color: var(--text-on-secondary);
  background: rgba(255, 255, 255, 0.08);
}

.sidebar.collapsed .sidebar-collapse-btn {
  transform: rotate(180deg);
}

.btn-new {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 500;
  white-space: nowrap;
  margin-bottom: 24px;
}

.sidebar.collapsed .btn-new {
  padding: 10px;
  width: 40px;
}

/* Backdrop + drawer mobile (<1024px) */
.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 90;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.sidebar-backdrop.visible {
  opacity: 1;
  pointer-events: auto;
}

.menu-toggle-btn {
  display: none;
  width: 32px;
  height: 32px;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: transparent;
  border: none;
  color: var(--text-on-secondary);
  cursor: pointer;
  margin-right: 8px;
  flex-shrink: 0;
}

.menu-toggle-btn:hover {
  background: rgba(255, 255, 255, 0.08);
}

@media (max-width: 1023px) {
  .menu-toggle-btn {
    display: flex;
  }

  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 95;
    width: 260px !important;
    padding: 20px 16px !important;
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar.collapsed .sidebar-label,
  .sidebar.collapsed .sidebar-footer-text,
  .sidebar.collapsed .pill-label {
    display: initial;
  }
}

.sidebar-section-history {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  margin-bottom: 20px;
}

.sidebar-section-history[hidden] {
  display: none !important;
}

.sidebar-section-history .sidebar-label {
  flex-shrink: 0;
}

.sidebar-section-fixed {
  flex-shrink: 0;
}

/* Área de rolagem do histórico — label fica fixo fora daqui, degradê nas bordas */
.history-scroll-wrap {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
}

.history-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding-right: 4px;
  scrollbar-width: thin;
  scrollbar-color: color-mix(in srgb, var(--secondary-light) 80%, white) transparent;
}

.history-scroll::-webkit-scrollbar {
  width: 6px;
}

.history-scroll::-webkit-scrollbar-track {
  background: transparent;
}

.history-scroll::-webkit-scrollbar-thumb {
  background: color-mix(in srgb, var(--secondary-light) 80%, white);
  border-radius: 999px;
}

.history-scroll::-webkit-scrollbar-thumb:hover {
  background: color-mix(in srgb, var(--secondary-light) 95%, white);
}

.history-fade {
  position: absolute;
  left: 0;
  right: 6px;
  height: 20px;
  pointer-events: none;
}

.history-fade-top {
  top: 0;
  background: linear-gradient(to bottom, var(--secondary), transparent);
}

.history-fade-bottom {
  bottom: 0;
  background: linear-gradient(to top, var(--secondary), transparent);
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.history-item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  width: 100%;
  text-align: left;
  padding: 10px 14px;
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--secondary-light) 40%, var(--secondary));
  border: 1px solid var(--secondary-dark);
  color: var(--text-on-secondary);
  font-family: inherit;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.history-item:hover {
  border-color: var(--primary);
  box-shadow: 0 0 12px var(--glow-primary);
}

.history-item-title {
  font-size: 0.8125rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.history-item-time {
  font-size: 0.7rem;
  color: var(--text-on-secondary-muted);
}

.sidebar.collapsed .sidebar-section-history {
  display: none;
}

.sidebar-label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-on-secondary-muted);
  margin-bottom: 10px;
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid var(--secondary-dark);
  font-size: 0.78rem;
  line-height: 1.5;
  color: var(--text-on-secondary-muted);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.sidebar-footer-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar.collapsed .sidebar-footer {
  align-items: center;
}

/* Role badge — variante topbar (fundo escuro) e sidebar (fundo escuro translúcido) */
.role-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: rgba(247, 30, 61, 0.15);
  border: 1px solid rgba(247, 30, 61, 0.30);
  color: var(--text-on-secondary);
  white-space: nowrap;
}

.sidebar.collapsed #sidebar-role-badge {
  display: none;
}

/* Pills / chips — bg-base */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: inherit;
  font-size: 0.8125rem;
  font-weight: 500;
  line-height: 1.2;
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s, transform 0.1s;
  white-space: nowrap;
  position: relative;
  overflow: hidden;
  text-decoration: none; /* .pill também é usado como <a> (link do painel admin) */
}

/* Sidebar pills — sobre fundo escuro */
.sidebar .pill {
  width: 100%;
  justify-content: flex-start;
  padding: 10px 14px;
  text-align: left;
  background: color-mix(in srgb, var(--secondary-light) 40%, var(--secondary));
  border: 1px solid var(--secondary-dark);
  color: var(--text-on-secondary);
}

.sidebar .pill:hover {
  border-color: var(--primary);
  box-shadow: 0 0 12px var(--glow-primary);
}

.sidebar .pill:active {
  transform: scale(0.98);
  border: 2px solid var(--primary);
}

.sidebar .pill:active::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--grad-primary);
}

/* Colapsada: só o círculo do ícone fica visível (evita anel duplicado) */
.sidebar.collapsed .pill {
  justify-content: center;
  padding: 4px;
  background: transparent;
  border-color: transparent;
}

.sidebar.collapsed .pill:hover {
  background: rgba(255, 255, 255, 0.06);
}

.pill-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 700;
  flex-shrink: 0;
}

.sidebar .pill-icon-help {
  background: color-mix(in srgb, var(--secondary-light) 60%, var(--secondary));
  color: var(--text-on-secondary);
}

.sidebar .pill-icon-admin {
  background: var(--grad-primary);
  color: var(--text-on-secondary);
}

/* .pill define display, que sempre vence a regra nativa do atributo hidden
   (author beats user-agent) — sem isso, admin-panel-link.hidden=true não
   esconderia o botão de operadores/leitura. */
#admin-panel-link[hidden] { display: none; }

/* Meta pills */
.pill-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
}

.pill-meta {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px 5px 8px;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border-subtle);
  background: var(--bg-base);
  color: var(--text-secondary);
  cursor: default;
  letter-spacing: 0.01em;
}

.pill-meta .pill-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

.pill-meta.type-code {
  background: var(--secondary-tint);
  color: var(--secondary);
  border-color: color-mix(in srgb, var(--secondary) 20%, transparent);
}
.pill-meta.type-code .pill-dot { background: var(--secondary); }

.pill-meta.type-vehicle {
  background: var(--primary-tint);
  color: var(--primary);
  border-color: var(--border-primary);
}
.pill-meta.type-vehicle .pill-dot { background: var(--primary); }

.pill-meta.type-application {
  background: color-mix(in srgb, var(--secondary) 6%, var(--bg-white));
  color: var(--secondary);
  border-color: color-mix(in srgb, var(--secondary) 14%, transparent);
}
.pill-meta.type-application .pill-dot { background: var(--secondary); }

.pill-meta.type-general {
  background: var(--bg-base);
  color: var(--text-muted);
  border-color: var(--border-subtle);
}
.pill-meta.type-general .pill-dot { background: var(--text-muted); }

.pill-meta.pill-confidence {
  font-weight: 500;
}

.pill-meta.pill-confidence .conf-bar {
  width: 40px;
  height: 4px;
  background: var(--border-subtle);
  border-radius: 2px;
  overflow: hidden;
}

.pill-meta.pill-confidence .conf-fill {
  height: 100%;
  background: var(--grad-primary);
  border-radius: 2px;
  transition: width 0.3s ease;
}

.pill-meta.pill-found {
  background: var(--primary-tint);
  color: var(--primary);
  border-color: var(--border-primary);
}
.pill-meta.pill-found .pill-dot { background: var(--primary); }

.pill-meta.pill-not-found {
  background: var(--bg-base);
  color: var(--text-secondary);
  border-color: var(--border-subtle);
}
.pill-meta.pill-not-found .pill-dot { background: var(--text-muted); }

/* Main chat */
.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* Topbar — sempre var(--secondary), flutuante */
.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 22px;
  margin: 12px 16px 0;
  background: var(--secondary);
  border-radius: 16px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.18), 0 1px 4px rgba(0, 0, 0, 0.10);
}

.header-title {
  display: flex;
  align-items: center;
  min-width: 0;
}

.header-title h1 {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-on-secondary);
  letter-spacing: -0.01em;
}

.header-sub {
  font-size: 0.8rem;
  color: var(--text-on-secondary-muted);
  margin-top: 2px;
}

.status-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--primary-light);
  flex-shrink: 0;
}

.status-dot.loading {
  background: var(--primary);
  animation: pulse 1.2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.85); }
}

.status {
  font-size: 0.8rem;
  color: var(--text-on-secondary-muted);
  font-weight: 500;
}

.status.loading {
  color: var(--primary-light);
}

/* Messages */
.messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px 0 32px;
}

.welcome {
  text-align: center;
  padding: 48px 24px 60px;
  max-width: 640px;
  margin: 0 auto;
}

.welcome-badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  margin-bottom: 20px;
  background: var(--bg-white);
  border: 1px solid var(--border-primary);
}

.welcome h2 {
  color: var(--text-primary);
  font-size: 1.65rem;
  margin-bottom: 10px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.25;
}

.welcome > p {
  color: var(--text-secondary);
  font-size: 0.95rem;
  line-height: 1.6;
  max-width: 480px;
  margin: 0 auto;
}

.message {
  display: flex;
  gap: 14px;
  padding: 20px 28px;
  max-width: 860px;
  margin: 0 auto;
  width: 100%;
}

.message.user {
  background: var(--bg-white);
  border-bottom: 1px solid var(--border-light);
  box-shadow: var(--shadow-sm);
}

.message.assistant {
  background: transparent;
}

.avatar {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  flex-shrink: 0;
  font-weight: 600;
  color: var(--text-on-secondary);
}

.message.user .avatar {
  background: var(--secondary);
}

.message.assistant .avatar {
  background: none;
}

.avatar-logo {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.message-body {
  flex: 1;
  min-width: 0;
  padding-top: 4px;
}

.message-content {
  line-height: 1.7;
  word-break: break-word;
  color: var(--text-primary);
  font-size: 0.9375rem;
}

.message-content strong {
  font-weight: 700;
}

.message-content ul {
  margin: 6px 0 6px 20px;
}

.message-content li {
  margin-bottom: 2px;
}

/* Cards estruturados de resultado de busca */
.part-cards {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 12px;
}

.part-card {
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  background: var(--bg-white);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.part-card-header {
  padding: 10px 14px;
  background: var(--secondary-tint);
  color: var(--secondary);
  font-weight: 700;
  font-size: 0.875rem;
  line-height: 1.5;
  border-bottom: 1px solid var(--border-light);
}

.part-card-code {
  display: inline-block;
  padding: 2px 8px;
  margin: 0 2px;
  border-radius: 6px;
  background: var(--primary-tint-strong);
  color: var(--primary-dark);
  font-family: "Consolas", "SFMono-Regular", Menlo, monospace;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.part-card-section {
  padding: 8px 14px;
  border-bottom: 1px solid var(--border-light);
}

.part-card-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.part-card-line {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.part-card-more {
  font-size: 0.75rem;
  color: var(--primary);
  font-weight: 500;
  margin-top: 2px;
}

.part-card-footer {
  padding: 8px 14px;
  text-align: right;
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.message-meta {
  margin-top: 4px;
}

.typing {
  display: flex;
  gap: 5px;
  padding: 6px 0;
}

.typing span {
  width: 8px;
  height: 8px;
  background: var(--primary);
  border-radius: 50%;
  opacity: 0.4;
  animation: bounce 1.4s infinite ease-in-out both;
}

.typing span:nth-child(1) { animation-delay: -0.32s; }
.typing span:nth-child(2) { animation-delay: -0.16s; }

@keyframes bounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.3; }
  40% { transform: scale(1); opacity: 1; }
}

/* Input — flutuante, sem fundo/borda própria */
.input-area {
  padding: 16px 28px 24px;
}

.input-form {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  max-width: 860px;
  margin: 0 auto;
  background: var(--bg-base);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  padding: 12px 14px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.input-form:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

#user-input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.9375rem;
  resize: none;
  max-height: 200px;
  line-height: 1.5;
  outline: none;
}

#user-input::placeholder {
  color: var(--text-muted);
}

#send-btn {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.disclaimer {
  text-align: center;
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 12px;
  max-width: 860px;
  margin-left: auto;
  margin-right: auto;
}

.error-msg {
  color: var(--primary);
}

@media (max-width: 768px) {
  .chat-header {
    padding: 12px 16px;
    margin: 8px 8px 0;
  }

  .header-sub {
    display: none;
  }

  .message {
    padding: 16px;
  }

  .input-area {
    padding: 12px 16px 20px;
  }

  .welcome h2 {
    font-size: 1.35rem;
  }
}

/* Login */
.login-form,
.interest-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.login-form label,
.interest-form label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.login-form input,
.interest-form input,
.interest-form textarea {
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  font: inherit;
  color: var(--text-primary);
}

.login-form input:focus,
.interest-form input:focus,
.interest-form textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

.login-error {
  color: var(--primary-dark);
  font-size: 0.85rem;
  margin: 0;
}

.btn-login {
  width: 100%;
  margin-top: 0.25rem;
  padding: 0.75rem;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.user-label {
  font-size: 0.8rem;
  color: var(--text-on-secondary-muted);
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.btn-header {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: rgba(255, 255, 255, 0.45);
  border-radius: 8px;
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
}

.btn-header:hover {
  color: #f87171;
  background: rgba(248, 113, 113, 0.10);
}

/* Avatar — sempre gradiente, círculo com iniciais */
.avatar-badge {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-on-secondary);
  background: var(--grad-primary);
  flex-shrink: 0;
}

/* Botão de logout dentro da sidebar (fundo escuro, com texto) */
.sidebar-logout {
  display: flex;
  align-items: center;
  gap: 8px;
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.45);
  font-size: 0.78rem;
  font-family: inherit;
  cursor: pointer;
  padding: 0;
  transition: color 0.15s;
}

.sidebar-logout:hover {
  color: #f87171;
}

/* Modal "Como usar" — mesmo padrão visual do form-card do login */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 200;
}

.modal-backdrop[hidden] {
  display: none !important;
}

.modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 201;
  width: 100%;
  max-width: 480px;
  max-height: calc(100vh - 48px);
  overflow: hidden;
  border-radius: var(--radius);
  border: 1px solid var(--border-subtle);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.18), 0 2px 8px rgba(0, 0, 0, 0.08);
}

.modal[hidden] {
  display: none !important;
}

.modal .form-card-header {
  padding-right: 48px;
}

.modal-close {
  position: absolute;
  top: 14px;
  right: 16px;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: transparent;
  border: none;
  color: var(--text-on-secondary-muted);
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
}

.modal-close:hover {
  color: var(--text-on-secondary);
  background: rgba(255, 255, 255, 0.08);
}

.how-to-text {
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

.how-to-text + .how-to-text {
  margin-top: 12px;
}

.how-to-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 14px 0;
}

.how-to-list li {
  font-size: 0.875rem;
  color: var(--text-primary);
  line-height: 1.5;
  padding: 10px 12px;
  background: var(--bg-base);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
}

.how-to-list em {
  color: var(--text-secondary);
  font-style: normal;
}

@media (max-width: 1023px) {
  .modal {
    max-width: calc(100% - 32px);
  }
}

/* Toast */
.toast-container {
  position: fixed;
  top: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 340px;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: var(--bg-white);
  border: 1px solid var(--border-light);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.14);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 0.85rem;
  color: var(--text-primary);
  animation: toast-in 0.2s ease;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

.toast-icon {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  margin-top: 1px;
}

.toast.error .toast-icon { color: var(--primary); }
.toast.success .toast-icon { color: #16a34a; }

.toast-message {
  flex: 1;
  line-height: 1.4;
}

.toast-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  flex-shrink: 0;
  padding: 0;
  line-height: 1;
}

.toast-close:hover {
  color: var(--text-primary);
}
