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

:root {
  --bg:        #0d0f14;
  --surface:   #12151e;
  --surface2:  #1a1e2e;
  --surface3:  #222640;
  --border:    #2a2f44;
  --accent:    #5b7fff;
  --accent2:   #7c5cfc;
  --text:      #dde2f0;
  --muted:     #6b7494;
  --success:   #3ecf8e;
  --warning:   #f0a429;
  --danger:    #f06060;
}

html, body {
  height: 100%;
  font-family: 'Inter', sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
}

/* ═══════════════════════════════════
   LAYOUT PRINCIPAL
═══════════════════════════════════ */
.app {
  display: grid;
  grid-template-rows: 52px 1fr;
  grid-template-columns: 280px 1fr;
  grid-template-areas:
    "header header"
    "sidebar chat";
  height: 100dvh;
  transition: grid-template-columns .25s ease;
}
.app.sidebar-hidden {
  grid-template-columns: 0px 1fr;
}

/* ── HEADER ── */
header {
  grid-area: header;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  z-index: 10;
}

.logo {
  width: 30px; height: 30px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 700; color: #fff; flex-shrink: 0;
}
header h1 { font-size: 14px; font-weight: 600; }

.sidebar-toggle {
  background: none; border: none; cursor: pointer;
  color: var(--muted); font-size: 16px;
  padding: 4px 6px; border-radius: 6px;
  transition: color .2s, background .2s;
  flex-shrink: 0;
}
.sidebar-toggle:hover { color: var(--text); background: var(--surface2); }

.header-fields {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 16px;
}
.field-group { display: flex; align-items: center; gap: 6px; }
.field-group label { font-size: 11px; color: var(--muted); white-space: nowrap; }
.field-group input {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 12px; font-family: inherit;
  padding: 5px 10px;
  outline: none;
  transition: border .2s;
}

#tenantInput { width: 120px; }
.field-group input:focus { border-color: var(--accent); }

#connectBtn {
  padding: 5px 14px;
  border-radius: 8px;
  border: none;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #fff;
  font-size: 12px; font-family: inherit; font-weight: 500;
  cursor: pointer;
  transition: opacity .2s;
}
#connectBtn:hover { opacity: .85; }
.new-chat-header-btn {
  padding: 5px 10px;
  border-radius: 8px;
  border: 1px solid var(--accent);
  background: transparent;
  color: var(--accent);
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: all .2s;
  line-height: 1;
}
.new-chat-header-btn:hover {
  background: var(--accent);
  color: #fff;
}

/* ── MAIN SIDEBAR ── */
.main-sidebar {
  grid-area: sidebar;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: opacity .2s ease;
}
.app.sidebar-hidden .main-sidebar {
  opacity: 0;
  pointer-events: none;
}

.thread-item {
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.thread-item:hover {
  background: var(--surface2);
  color: var(--text);
}
.thread-item.active {
  background: rgba(91, 127, 255, 0.1);
  color: var(--accent);
  font-weight: 500;
}
.thread-delete-btn,
.thread-edit-btn {
  background: none;
  border: none;
  opacity: 0;
  cursor: pointer;
  transition: all 0.2s;
  border-radius: 4px;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
}
.thread-item:hover .thread-delete-btn,
.thread-item:hover .thread-edit-btn {
  opacity: 0.6;
}
.thread-item:hover .thread-delete-btn:hover {
  opacity: 1;
  background: rgba(240, 96, 96, 0.15);
}
.thread-item:hover .thread-edit-btn:hover {
  opacity: 1;
  background: rgba(91, 127, 255, 0.15);
}
.new-chat-btn:hover { background: var(--surface2) !important; }

.sidebar-header {
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.sidebar-header span { font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }

/* master checkbox (selecionar todos) */
.master-check, .folder-check {
  appearance: none; -webkit-appearance: none;
  width: 14px; height: 14px; border-radius: 4px;
  border: 1.5px solid var(--border);
  background: var(--surface2);
  cursor: pointer; flex-shrink: 0;
  transition: background .15s, border .15s;
  position: relative;
}
.master-check:checked, .folder-check:checked {
  background: var(--accent);
  border-color: var(--accent);
}
.master-check:checked::after, .folder-check:checked::after {
  content: '✓'; position: absolute;
  top: -1px; left: 1px;
  font-size: 10px; color: #fff; font-weight: 700;
}
.master-check:indeterminate, .folder-check:indeterminate {
  background: var(--surface3);
  border-color: var(--accent);
}
.master-check:indeterminate::after, .folder-check:indeterminate::after {
  content: '−'; position: absolute;
  top: -2px; left: 2px;
  font-size: 12px; color: var(--accent); font-weight: 700;
}

.sidebar-actions { display: flex; align-items: center; gap: 2px; }

.refresh-btn, .collapse-btn {
  background: none; border: none; cursor: pointer;
  color: var(--muted); font-size: 13px;
  padding: 2px 5px; border-radius: 4px;
  transition: color .2s;
}
.refresh-btn:hover { color: var(--accent); }
.collapse-btn:hover { color: var(--text); }

.doc-list, .threads-list {
  flex: 1;
  overflow-y: auto;
}
.doc-list { padding: 8px 0; }
.doc-list::-webkit-scrollbar, .threads-list::-webkit-scrollbar { width: 3px; }
.doc-list::-webkit-scrollbar-thumb, .threads-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.doc-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 16px;
  border-radius: 0;
  cursor: default;
  transition: background .15s;
  animation: fadeIn .2s ease;
}
.doc-item:hover { background: var(--surface2); }
.doc-item:hover .doc-menu-btn { opacity: 1; }
@keyframes fadeIn { from { opacity: 0; transform: translateX(-6px); } to { opacity: 1; transform: none; } }

.doc-icon { font-size: 14px; flex-shrink: 0; }

.doc-info { flex: 1; overflow: hidden; cursor: pointer; border-radius: 6px; padding: 2px 4px; transition: background .15s; }
.doc-info:hover { background: var(--surface2); }
.doc-name {
  font-size: 12px; font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.doc-status-label { font-size: 10px; color: var(--muted); margin-top: 1px; }

/* checkbox de seleção */
.doc-check {
  appearance: none; -webkit-appearance: none;
  width: 15px; height: 15px; border-radius: 4px;
  border: 1.5px solid var(--border);
  background: var(--surface2);
  cursor: pointer; flex-shrink: 0;
  transition: background .15s, border .15s;
  position: relative;
}
.doc-check:checked {
  background: var(--accent);
  border-color: var(--accent);
}
.doc-check:checked::after {
  content: '✓'; position: absolute;
  top: -1px; left: 1px;
  font-size: 11px; color: #fff; font-weight: 700;
}

/* status badges */
.status-dot {
  width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
}
.status-dot.vectorized { background: var(--success); }
.status-dot.processing { background: var(--warning); animation: pulse 1.2s infinite; }
.status-dot.pending    { background: var(--muted); }
.status-dot.error      { background: var(--danger); }

@keyframes pulse {
  0%,100% { opacity: 1; transform: scale(1); }
  50%      { opacity: .5; transform: scale(.7); }
}

/* ── FOLDERS (PASTAS) ── */
.folder-group { margin-bottom: 8px; }
.folder-header {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 12px; cursor: pointer;
  background: var(--surface2); border-radius: 6px;
  margin: 0 12px 4px 12px; font-size: 12px;
  transition: background 0.2s; user-select: none;
}
.folder-header:hover { background: var(--surface3); }
.folder-content { padding-left: 4px; display: block; }
.folder-content.collapsed { display: none; }
.folder-header .folder-title { flex: 1; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.folder-header .folder-count { color: var(--muted); font-size: 11px; }

.folder-del-btn { transition: opacity 0.2s; opacity: 0.5; }
.folder-header:hover .folder-del-btn { opacity: 1; }
.folder-del-btn:hover { transform: scale(1.1); }

.new-folder-card {
  margin: 12px; padding: 12px;
  border: 1.5px dashed var(--border);
  border-radius: 8px;
  text-align: center; color: var(--muted);
  cursor: pointer; font-size: 13px; font-weight: 600;
  transition: all 0.2s; user-select: none;
}
.new-folder-card:hover {
  background: var(--surface2);
  color: var(--text); border-color: var(--accent);
}
.header-plus-btn {
  background: none; border: none; cursor: pointer; color: var(--muted);
  font-size: 18px; transition: color 0.15s; line-height: 1; font-weight: bold;
}
.header-plus-btn:hover { color: var(--text); }

/* menu de ações (3 pontinhos) */
.doc-menu-btn {
  background: none; border: none; color: var(--muted);
  font-size: 16px; cursor: pointer; padding: 2px 6px;
  border-radius: 6px; opacity: 0; flex-shrink: 0;
  transition: opacity .15s, color .15s, background .15s;
  line-height: 1;
}
.doc-menu-btn:hover { color: var(--text); background: var(--surface3); }

.doc-menu-wrap { position: relative; }

.doc-menu-dropdown {
  position: absolute; right: 0; top: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 4px;
  z-index: 100;
  min-width: 130px;
  box-shadow: 0 8px 24px rgba(0,0,0,.4);
  animation: popIn .15s ease;
}
@keyframes popIn {
  from { opacity: 0; transform: scale(.95) translateY(-4px); }
  to   { opacity: 1; transform: none; }
}
.doc-menu-item {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; border-radius: 7px;
  font-size: 12px; cursor: pointer;
  transition: background .15s;
}
.doc-menu-item:hover { background: var(--surface3); }
.doc-menu-item.danger { color: var(--danger); }
.doc-menu-item.danger:hover { background: rgba(240,96,96,.1); }

.sidebar-empty {
  padding: 32px 16px;
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.7;
}

.sidebar-footer {
  padding: 10px 16px;
  border-top: 1px solid var(--border);
  font-size: 10px;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
}

/* botão de upload */
.upload-btn {
  display: flex; align-items: center; justify-content: center;
  gap: 6px; width: calc(100% - 32px); margin: 8px 16px;
  padding: 8px 12px;
  border-radius: 8px; border: 1px dashed var(--border);
  background: none; color: var(--muted);
  font-size: 12px; font-family: inherit;
  cursor: pointer; transition: border .2s, color .2s, background .2s;
}
.upload-btn:hover { border-color: var(--accent); color: var(--accent); background: rgba(91,127,255,.06); }
.upload-btn:disabled { opacity: .4; cursor: default; }

.paste-btn {
  display: flex; align-items: center; justify-content: center;
  gap: 6px; width: calc(100% - 32px); margin: 0 16px 8px;
  padding: 7px 12px;
  border-radius: 8px; border: 1px solid var(--border);
  background: none; color: var(--muted);
  font-size: 12px; font-family: inherit;
  cursor: pointer; transition: border .2s, color .2s, background .2s;
}
.paste-btn:hover { border-color: var(--accent); color: var(--accent); background: rgba(91,127,255,.06); }

/* Modal de colar texto */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.6); backdrop-filter: blur(4px);
  z-index: 200; display: flex; align-items: center; justify-content: center;
  animation: fadeIn .15s ease;
}
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px;
  width: 480px; max-width: calc(100vw - 32px);
  display: flex; flex-direction: column; gap: 14px;
  box-shadow: 0 20px 60px rgba(0,0,0,.5);
  animation: slideUp .2s ease;
}
.modal h3 { font-size: 14px; font-weight: 600; }
.modal label { font-size: 11px; color: var(--muted); display: block; margin-bottom: 4px; }
.modal input[type=text] {
  width: 100%; background: var(--surface2);
  border: 1px solid var(--border); border-radius: 8px;
  color: var(--text); font-family: inherit; font-size: 13px;
  padding: 8px 12px; outline: none; transition: border .2s;
}
.modal input[type=text]:focus { border-color: var(--accent); }
.modal textarea {
  width: 100%; min-height: 160px; background: var(--surface2);
  border: 1px solid var(--border); border-radius: 8px;
  color: var(--text); font-family: inherit; font-size: 12.5px;
  padding: 10px 12px; outline: none; resize: vertical;
  line-height: 1.6; transition: border .2s;
}
.modal textarea:focus { border-color: var(--accent); }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; }
.modal-cancel {
  background: none; border: 1px solid var(--border); color: var(--muted);
  font-family: inherit; font-size: 12px; padding: 7px 16px;
  border-radius: 8px; cursor: pointer; transition: border .2s, color .2s;
}
.modal-cancel:hover { border-color: var(--danger); color: var(--danger); }
.modal-confirm {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  border: none; color: #fff;
  font-family: inherit; font-size: 12px; font-weight: 500; padding: 7px 18px;
  border-radius: 8px; cursor: pointer; transition: opacity .2s;
}
.modal-confirm:hover { opacity: .85; }
.modal-confirm:disabled { opacity: .4; cursor: default; }

.upload-progress {
  margin: 0 16px 8px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 11px;
  color: var(--muted);
  display: none;
  gap: 8px;
  align-items: center;
}
.upload-progress.visible { display: flex; }
.upload-progress .spin { animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── CHAT ── */
.chat-area {
  grid-area: chat;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
}

#messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
}
#messages::-webkit-scrollbar { width: 4px; }
#messages::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.msg {
  display: flex;
  gap: 8px;
  max-width: 95%;
  animation: slideUp .2s ease;
}
@keyframes slideUp {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: none; }
}
.msg.user { align-self: flex-end; flex-direction: row-reverse; }
.msg.ai   { align-self: flex-start; }


.bubble {
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 13.5px;
  line-height: 1.6;
  max-width: 100%;
  word-break: break-word;
}
.msg.user .bubble {
  background: #1a2340;
  border: 1px solid rgba(91,127,255,.2);
  border-radius: 14px 4px 14px 14px;
}
.msg.ai .bubble {
  background: transparent;
  border: none;
  padding: 4px 0;
}
.bubble strong { color: #fff; }
.bubble p { margin: 0 0 8px 0; }
.bubble p:last-child { margin-bottom: 0; }
.bubble ul, .bubble ol { margin: 4px 0 8px 0; padding-left: 18px; }
.bubble li { margin-bottom: 2px; }

/* Cards de Conteúdo (Entregáveis longos), Tabelas e Códigos */
.content-card, .table-wrapper, .code-block-wrapper {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 8px;
  margin: 12px 0;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  overflow-x: auto;
}

/* Evita o efeito "Card dentro de Card" quando a IA colocar tabelas ou códigos dentro do <card> principal */
.content-card .table-wrapper,
.content-card .code-block-wrapper {
  margin: 8px 0 !important;
  border: none !important;
  box-shadow: none !important;
  border-left: none !important;
  background: rgba(0, 0, 0, 0.1) !important;
  border-radius: 6px !important;
}

.content-card {
  padding: 16px;
  font-family: var(--font-family, 'Inter', sans-serif);
  color: var(--text);
}

.md-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  text-align: left;
}
.md-table th {
  background: var(--surface2);
  padding: 10px 14px;
  font-weight: 600;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  white-space: nowrap;
}
.md-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}
.md-table tr:last-child td {
  border-bottom: none;
}
.md-table tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

/* fontes — chips clícaveis */
.snippets { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.snip-label { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; }
.snippet-chip {
  display: inline-flex; align-items: center; gap: 5px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 3px 10px;
  font-size: 11px; color: var(--accent);
  cursor: pointer;
  transition: background .15s, border .15s;
}
.snippet-chip:hover { background: var(--surface3); border-color: var(--accent); }
.snippet-chip .chip-icon { font-size: 10px; }

/* modal de documento */
.doc-modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.65); backdrop-filter: blur(4px);
  z-index: 300; display: flex; align-items: center; justify-content: center;
  animation: fadeIn .15s ease;
}
.doc-modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  width: 580px; max-width: calc(100vw - 32px);
  max-height: 80vh;
  display: flex; flex-direction: column;
  box-shadow: 0 24px 64px rgba(0,0,0,.5);
  animation: slideUp .2s ease;
  overflow: hidden;
}
.doc-modal-header {
  padding: 18px 22px 14px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px;
}
.doc-modal-header h3 { flex: 1; font-size: 13px; font-weight: 600; }
.doc-modal-close {
  background: none; border: none; color: var(--muted);
  font-size: 18px; cursor: pointer; padding: 2px 6px;
  border-radius: 6px; transition: color .15s;
}
.doc-modal-close:hover { color: var(--danger); }
.doc-modal-meta {
  padding: 12px 22px;
  display: flex; gap: 8px; flex-wrap: wrap;
  border-bottom: 1px solid var(--border);
}
.doc-meta-tag {
  font-size: 10px; background: var(--surface2);
  border: 1px solid var(--border); border-radius: 6px;
  padding: 2px 8px; color: var(--muted);
}
.doc-meta-tag span { color: var(--text); font-weight: 500; }
.doc-modal-body {
  flex: 1; overflow-y: auto;
  padding: 16px 22px;
  font-size: 12.5px; line-height: 1.8;
  color: var(--muted);
  white-space: pre-wrap; word-break: break-word;
}
.doc-modal-body::-webkit-scrollbar { width: 4px; }
.doc-modal-body::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

/* metrics */
.metrics { margin-top: 8px; display: flex; gap: 8px; flex-wrap: wrap; }
.metric-tag {
  font-size: 10px; color: var(--muted);
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: 6px; padding: 2px 8px;
}

/* typing */
.typing .bubble { padding: 14px 18px; }
.dots { display: flex; gap: 4px; }
.dots span {
  width: 6px; height: 6px; background: var(--muted);
  border-radius: 50%; animation: bounce .9s infinite;
}
.dots span:nth-child(2) { animation-delay: .15s; }
.dots span:nth-child(3) { animation-delay: .3s; }
@keyframes bounce { 0%,80%,100%{transform:translateY(0)} 40%{transform:translateY(-6px)} }

/* empty */
.empty {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 10px; flex: 1; color: var(--muted);
  text-align: center; padding: 40px; pointer-events: none;
}
.empty .icon { font-size: 40px; }
.empty p { font-size: 13px; line-height: 1.7; }

/* ── INPUT ── */
.chat-input {
  padding: 14px 20px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.input-row {
  display: flex; gap: 10px; align-items: flex-end;
  max-width: 840px; margin: 0 auto;
}
textarea {
  flex: 1; background: var(--surface2);
  border: 1px solid var(--border); border-radius: 12px;
  color: var(--text); font-family: inherit; font-size: 13.5px;
  padding: 10px 14px; resize: none; outline: none;
  line-height: 1.5; max-height: 130px; transition: border .2s;
}
textarea:focus { border-color: var(--accent); }
textarea::placeholder { color: var(--muted); }

#sendBtn {
  width: 40px; height: 40px; border-radius: 10px; border: none;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #fff; font-size: 16px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; transition: opacity .2s, transform .1s;
}
#sendBtn:hover { opacity: .85; }
#sendBtn:active { transform: scale(.93); }
#sendBtn:disabled { opacity: .35; cursor: default; }

.new-chat-btn {
  background: var(--surface2); border: 1px solid var(--border);
  color: var(--text); font-size: 16px; width: 34px; height: 34px;
  border-radius: 8px; cursor: pointer; display: flex;
  align-items: center; justify-content: center;
  transition: background .2s, border .2s; margin-left: 8px;
}
.new-chat-btn:hover { background: var(--surface3); border-color: var(--muted); }

/* Botões do PDF/Relatório */
.btn-pdf-outline {
  background: transparent; color: var(--text); border: 1px solid var(--border);
  padding: 6px 12px; border-radius: 6px; cursor: pointer; font-size: 11.5px; font-weight: 600;
  display: flex; gap: 6px; align-items: center; transition: all 0.2s;
}
.btn-pdf-outline:hover { background: var(--surface3); border-color: var(--muted); }
.btn-pdf-outline svg { width: 14px; height: 14px; }

.btn-pdf-primary {
  background: var(--accent); color: #fff; border: none;
  padding: 6px 12px; border-radius: 6px; cursor: pointer; font-size: 11.5px; font-weight: 600;
  display: flex; gap: 6px; align-items: center; transition: all 0.2s;
}
.btn-pdf-primary:hover { opacity: 0.85; box-shadow: 0 2px 8px rgba(91,127,255,0.4); }
.btn-pdf-primary svg { width: 14px; height: 14px; }

/* @ Mentions Dropdown */
.mention-dropdown {
  position: absolute;
  bottom: 100%;
  left: 0;
  margin-bottom: 8px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  max-height: 200px;
  overflow-y: auto;
  width: 300px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.5);
  display: none;
  z-index: 100;
}
.mention-dropdown.active {
  display: block;
}
.mention-item {
  padding: 10px 12px;
  font-size: 12px;
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}
.mention-item:last-child {
  border-bottom: none;
}
.mention-item:hover, .mention-item.selected {
  background: var(--surface3);
  color: var(--accent);
}
.mention-item-icon {
  font-size: 14px;
}
.input-row { position: relative; } /* Para o dropdown ancorar certo */

/* Notebook LM Citations */
.citation-badge {
  display: inline-flex; align-items: center; justify-content: center;
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--surface3); border: 1px solid var(--border);
  color: var(--accent); font-size: 10px; font-weight: 600;
  margin-left: 4px; cursor: pointer; transition: all .15s ease;
  vertical-align: super; text-decoration: none !important;
}
.citation-badge:hover {
  background: var(--accent); color: #fff; border-color: var(--accent);
  transform: translateY(-1px);
}

/* tenant not set warning */
.no-tenant {
  display: flex; align-items: center; justify-content: center;
  gap: 8px; padding: 12px 20px; font-size: 12px; color: var(--warning);
  background: rgba(240,164,41,.06); border-bottom: 1px solid rgba(240,164,41,.15);
}

/* Blocos de Código e Inline Code */
.inline-code {
  color: var(--text);
  font-family: 'Fira Code', 'Courier New', monospace;
  font-size: 0.95em;
}

.code-block-wrapper {
  margin: 12px 0;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--bg);
}

.code-header {
  background: var(--surface2);
  padding: 6px 12px;
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  font-weight: 600;
  border-bottom: 1px solid var(--border);
  letter-spacing: 0.5px;
}

.code-block-wrapper pre {
  margin: 0;
  padding: 14px;
  overflow-x: auto;
  font-family: 'Fira Code', 'Courier New', monospace;
  font-size: 13px;
  line-height: 1.5;
  color: #e2e8f0;
}

.code-block-wrapper pre::-webkit-scrollbar { height: 6px; }
.code-block-wrapper pre::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

/* Mobile Responsiveness */
@media (max-width: 800px) {
  .app {
    grid-template-columns: 1fr !important;
    grid-template-areas:
      "header"
      "chat" !important;
  }
  header { padding: 0 10px; }
  .header-title { display: none; }
  .header-fields { gap: 6px; }
  #tenantInput, #sessionInput { width: 90px; }
  
  /* Gaveta Lateral (Mobile) */
  .main-sidebar {
    position: absolute;
    top: 52px;
    left: -100%;
    width: 280px;
    height: calc(100dvh - 52px);
    z-index: 1000;
    transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  }
  .main-sidebar.open { left: 0; }
  
  /* Backdrop para clique fora */
  .mobile-backdrop {
    display: none;
    position: absolute;
    top: 52px; left: 0; width: 100vw; height: calc(100dvh - 52px);
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(2px);
    z-index: 999;
  }
  .mobile-backdrop.active { display: block; }
  
  /* Ajustes do Header no Mobile para não cortar */
  #tenantInput, #sessionInput { width: 75px; font-size: 11px; padding: 6px; }
  #connectBtn { padding: 6px 10px; font-size: 11px; }
  .new-chat-header-btn { padding: 4px 8px; font-size: 14px; }
  
  /* Ajustes do Chat Input e Topbar */
  .chat-input { padding: 10px 12px; }
  .input-row { gap: 6px; }
  #mentionBtn { width: 38px !important; height: 38px !important; }
  #sendBtn { width: 38px !important; height: 38px !important; }
  textarea { font-size: 13px; padding: 10px 12px; }
  .mention-dropdown { width: calc(100vw - 24px); max-width: 320px; }
  .chat-topbar-title { max-width: 50% !important; font-size: 13px !important; }
  .chat-topbar-agent { font-size: 10px !important; padding: 3px 6px !important; }
  
  .chat-footer { padding: 12px; }
  .bubble { max-width: calc(100% - 15px); }
  .doc-modal { width: 95vw; }
}

/* ── TOAST NOTIFICATIONS ── */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 9999;
  pointer-events: none;
}

.toast {
  background: var(--surface2);
  border-left: 4px solid var(--accent);
  color: var(--text);
  padding: 14px 20px;
  border-radius: 8px;
  font-size: 13px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  gap: 12px;
  transform: translateX(120%);
  transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.3s ease;
  pointer-events: auto;
  max-width: 380px;
}

.toast.show {
  transform: translateX(0);
  opacity: 1;
}

.toast.error {
  border-left-color: var(--danger);
}

.toast.success {
  border-left-color: var(--success);
}
