/* ── BASE & LAYOUT ─────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  height: 100%;
}

body {
  font-family: 'Crimson Pro', Georgia, serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  min-height: 100dvh;
  height: var(--app-height, 100dvh);
  width: 100%;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: rgba(0,0,0,0.1); }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--gold-dim); }

/* ── TOPBAR ──────────────────────────────────────────────────── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
  gap: 12px;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-cross {
  font-size: 18px;
  color: var(--gold);
}

.topbar-title {
  font-family: 'Playfair Display', serif;
  font-size: 16px;
  color: var(--gold);
  letter-spacing: 0.05em;
  line-height: 1.2;
}

.topbar-subtitle {
  font-size: 10px;
  color: var(--text-muted);
  letter-spacing: 0.15em;
  text-transform: uppercase;
  margin-top: 1px;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ── MAIN LAYOUT ─────────────────────────────────────────────── */
.main {
  display: flex;
  flex: 1;
  min-height: 0; /* Destrava a rolagem dos containers internos */
  overflow: hidden;
}

/* ── SIDEBAR ─────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-new {
  margin: 12px 12px 8px;
  padding: 8px 12px;
  border: 1px dashed var(--border2);
  border-radius: var(--radius);
  background: none;
  color: var(--text-muted);
  font-family: 'Crimson Pro', serif;
  font-size: 13px;
  cursor: pointer;
  text-align: center;
  transition: color 0.2s, border-color 0.2s;
  flex-shrink: 0;
}
.sidebar-new:hover { color: var(--gold); border-color: var(--gold-dim); }

.sidebar-list {
  flex: 1;
  overflow-y: auto;
  padding: 4px 0;
  scrollbar-width: thin;
  scrollbar-color: var(--scrollbar) transparent;
}

.sidebar-empty {
  padding: 16px;
  font-size: 11px;
  color: var(--text-muted);
  text-align: center;
  font-family: 'JetBrains Mono', monospace;
}

.sidebar-item {
  padding: 9px 14px;
  cursor: pointer;
  border-left: 2px solid transparent;
  transition: background 0.15s, border-color 0.15s;
}
.sidebar-item:hover { background: rgba(0,0,0,0.03); }
.sidebar-item.active {
  border-left-color: var(--gold-dim);
  background: var(--gold-glow);
}

.sidebar-item-title {
  font-size: 12px;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.4;
}
.sidebar-item.active .sidebar-item-title { color: var(--gold); }

.sidebar-item-sub {
  font-size: 9px;
  color: var(--text-muted);
  margin-top: 2px;
  font-family: 'JetBrains Mono', monospace;
  opacity: 0.8;
}

/* ── CHAT PANEL ──────────────────────────────────────────────── */
.chat-panel {
  display: flex;
  flex-direction: column;
  flex: 1;
  border-right: 1px solid var(--border);
  min-width: 0;
  overflow: hidden;
}

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  scrollbar-width: thin;
  scrollbar-color: var(--scrollbar) transparent;
}

/* ── EMPTY STATE ─────────────────────────────────────────────── */
.empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  color: var(--text-muted);
  pointer-events: none;
}
.empty-cross { font-size: 28px; color: var(--border2); }
.empty-text {
  font-family: 'Playfair Display', serif;
  font-style: italic;
  font-size: 15px;
  text-align: center;
  max-width: 340px;
  line-height: 1.6;
}

/* ── DEBUG PANEL ───────────────────────────────────── */
.debug-panel {
  width: var(--debug-w);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: #f0ede6;
  overflow: hidden;
  height: 100%; /* Força altura total */
}

/* Ajustes finos para modo escuro */
[data-theme="dark"] .debug-panel { background: #0c0a08; }
[data-theme="dark"] .sidebar-item:hover { background: rgba(255,255,255,0.02); }
