/* ============================================================
   ProxyIA WebUI — Dark Premium Theme
   Paleta: #0a0a0f (bg), #7c3aed (accent violeta), glassmorphism
   Fonte: Inter (Google Fonts)
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

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

:root {
  --bg-base:       #0a0a0f;
  --bg-surface:    #12121a;
  --bg-elevated:   #1a1a26;
  --bg-glass:      rgba(255, 255, 255, 0.04);
  --bg-glass-hover:rgba(255, 255, 255, 0.07);

  --accent:        #7c3aed;
  --accent-light:  #9d64f7;
  --accent-dim:    rgba(124, 58, 237, 0.15);
  --accent-glow:   rgba(124, 58, 237, 0.35);

  --text-primary:  #f0f0f8;
  --text-secondary:#9494b0;
  --text-muted:    #5a5a72;

  --border:        rgba(255, 255, 255, 0.08);
  --border-accent: rgba(124, 58, 237, 0.4);

  --user-bubble:   rgba(124, 58, 237, 0.18);
  --ai-bubble:     rgba(255, 255, 255, 0.04);

  --danger:        #ef4444;
  --danger-dim:    rgba(239, 68, 68, 0.15);
  --success:       #22c55e;

  --sidebar-w:     280px;
  --radius:        12px;
  --radius-sm:     8px;
  --radius-lg:     16px;

  --transition:    0.2s ease;
  --shadow-sm:     0 2px 8px rgba(0,0,0,0.4);
  --shadow-md:     0 4px 20px rgba(0,0,0,0.5);
  --shadow-glow:   0 0 30px rgba(124, 58, 237, 0.2);
}

html, body {
  height: 100%;
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg-base);
  color: var(--text-primary);
  font-size: 15px;
  line-height: 1.6;
  overflow: hidden;
}

/* Scrollbar estilizado */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ─── Layout Principal ───────────────────────────────────────── */
#app {
  display: flex;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
}

/* ─── Sidebar ────────────────────────────────────────────────── */
#sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  transition: transform var(--transition);
  overflow: hidden;
}

.sidebar-header {
  padding: 20px 16px 16px;
  border-bottom: 1px solid var(--border);
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.logo-icon {
  width: 34px;
  height: 34px;
  background: linear-gradient(135deg, var(--accent), var(--accent-light));
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  box-shadow: var(--shadow-glow);
}

.logo-text {
  font-size: 17px;
  font-weight: 700;
  background: linear-gradient(135deg, #f0f0f8, var(--accent-light));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

#btn-new-chat {
  width: 100%;
  padding: 9px 14px;
  background: var(--accent-dim);
  border: 1px solid var(--border-accent);
  border-radius: var(--radius-sm);
  color: var(--accent-light);
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: background var(--transition), box-shadow var(--transition);
}

#btn-new-chat:hover {
  background: rgba(124, 58, 237, 0.28);
  box-shadow: var(--shadow-glow);
}

#btn-new-chat svg { flex-shrink: 0; }

/* Lista de conversas */
.sidebar-conversations {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.conversations-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 8px 8px 4px;
}

.conv-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition);
  position: relative;
  group: true;
}

.conv-item:hover { background: var(--bg-glass-hover); }
.conv-item.active { background: var(--accent-dim); }
.conv-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 20%;
  height: 60%;
  width: 2px;
  background: var(--accent);
  border-radius: 99px;
}

.conv-icon {
  font-size: 14px;
  flex-shrink: 0;
  opacity: 0.6;
}

.conv-title {
  flex: 1;
  font-size: 13.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-secondary);
}

.conv-item.active .conv-title { color: var(--text-primary); }

.conv-delete {
  opacity: 0;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 3px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  transition: opacity var(--transition), color var(--transition), background var(--transition);
  flex-shrink: 0;
}

.conv-item:hover .conv-delete { opacity: 1; }
.conv-delete:hover { color: var(--danger); background: var(--danger-dim); }

/* Sidebar footer — configurações */
.sidebar-footer {
  padding: 12px;
  border-top: 1px solid var(--border);
}

#btn-settings {
  width: 100%;
  padding: 9px 14px;
  background: var(--bg-glass);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: background var(--transition), color var(--transition);
}

#btn-settings:hover {
  background: var(--bg-glass-hover);
  color: var(--text-primary);
}

/* ─── Chat Area ──────────────────────────────────────────────── */
#chat-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg-base);
  position: relative;
}

/* Background decorativo */
#chat-area::before {
  content: '';
  position: absolute;
  top: -150px;
  right: -150px;
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, rgba(124,58,237,0.08) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}

/* Header do chat */
#chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  border-bottom: 1px solid var(--border);
  background: rgba(18, 18, 26, 0.8);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  position: relative;
  z-index: 1;
  flex-shrink: 0;
}

#chat-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 400px;
}

.model-badge {
  display: flex;
  align-items: center;
  gap: 8px;
}

#model-select {
  background: var(--bg-glass);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 12.5px;
  padding: 5px 10px;
  cursor: pointer;
  outline: none;
  transition: border-color var(--transition);
  max-width: 220px;
}

#model-select:hover, #model-select:focus {
  border-color: var(--border-accent);
  color: var(--text-primary);
}

#model-select option {
  background: var(--bg-elevated);
  color: var(--text-primary);
}

/* Mensagens */
#messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  position: relative;
  z-index: 1;
}

/* Estado vazio */
.empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 16px;
  padding: 40px;
  animation: fadeIn 0.4s ease;
}

.empty-icon {
  width: 64px;
  height: 64px;
  background: var(--accent-dim);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  box-shadow: var(--shadow-glow);
}

.empty-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
}

.empty-subtitle {
  font-size: 14px;
  color: var(--text-muted);
  max-width: 320px;
  line-height: 1.7;
}

/* Bolhas de mensagem */
.message {
  display: flex;
  gap: 12px;
  animation: slideUp 0.3s ease;
  max-width: 820px;
}

.message.user {
  align-self: flex-end;
  flex-direction: row-reverse;
  max-width: 70%;
}

.message.assistant { align-self: flex-start; }

.msg-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
  margin-top: 2px;
}

.message.user .msg-avatar {
  background: linear-gradient(135deg, var(--accent), var(--accent-light));
  box-shadow: 0 0 12px var(--accent-glow);
}

.message.assistant .msg-avatar {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
}

.msg-body { flex: 1; min-width: 0; }

.msg-meta {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 5px;
  font-weight: 500;
}

.message.user .msg-meta { text-align: right; }

.msg-content {
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 14.5px;
  line-height: 1.75;
  word-wrap: break-word;
}

.message.user .msg-content {
  background: var(--user-bubble);
  border: 1px solid var(--border-accent);
  border-radius: var(--radius) 4px var(--radius) var(--radius);
}

.message.assistant .msg-content {
  background: var(--ai-bubble);
  border: 1px solid var(--border);
  border-radius: 4px var(--radius) var(--radius) var(--radius);
}

/* Markdown styles dentro das mensagens */
.msg-content p { margin-bottom: 10px; }
.msg-content p:last-child { margin-bottom: 0; }
.msg-content h1, .msg-content h2, .msg-content h3 {
  margin: 16px 0 8px;
  font-weight: 600;
}
.msg-content ul, .msg-content ol {
  padding-left: 20px;
  margin-bottom: 10px;
}
.msg-content li { margin-bottom: 4px; }
.msg-content code {
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  background: rgba(255,255,255,0.08);
  padding: 2px 6px;
  border-radius: 4px;
}
.msg-content pre {
  background: rgba(0,0,0,0.5);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
  overflow-x: auto;
  margin: 10px 0;
}
.msg-content pre code {
  background: none;
  padding: 0;
  font-size: 13px;
}
.msg-content blockquote {
  border-left: 3px solid var(--accent);
  padding-left: 12px;
  margin: 10px 0;
  color: var(--text-secondary);
}
.msg-content a { color: var(--accent-light); text-decoration: none; }
.msg-content a:hover { text-decoration: underline; }
.msg-content table { width: 100%; border-collapse: collapse; margin: 10px 0; }
.msg-content th, .msg-content td {
  padding: 8px 12px;
  border: 1px solid var(--border);
  text-align: left;
}
.msg-content th { background: rgba(255,255,255,0.05); font-weight: 600; }
.msg-content strong { color: var(--text-primary); font-weight: 600; }

/* Cursor de streaming */
.streaming-cursor::after {
  content: '▊';
  color: var(--accent-light);
  animation: blink 0.8s step-end infinite;
}

/* ─── Input Area ─────────────────────────────────────────────── */
#input-area {
  padding: 16px 24px 20px;
  background: rgba(10, 10, 15, 0.8);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
  position: relative;
  z-index: 1;
  flex-shrink: 0;
}

.input-wrapper {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 10px 14px;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.input-wrapper:focus-within {
  border-color: var(--border-accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

#message-input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 14.5px;
  line-height: 1.6;
  resize: none;
  max-height: 160px;
  min-height: 24px;
  overflow-y: auto;
  padding: 2px 0;
}

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

#btn-send {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, var(--accent), var(--accent-light));
  border: none;
  border-radius: 10px;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: opacity var(--transition), transform var(--transition), box-shadow var(--transition);
  box-shadow: 0 2px 8px var(--accent-glow);
}

#btn-send:hover { opacity: 0.9; transform: scale(1.04); }
#btn-send:active { transform: scale(0.97); }
#btn-send:disabled { opacity: 0.3; cursor: not-allowed; transform: none; }

.input-hint {
  font-size: 11.5px;
  color: var(--text-muted);
  text-align: center;
  margin-top: 8px;
}

/* ─── Modal de Configurações ─────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  animation: fadeIn 0.2s ease;
}

.modal-overlay.hidden { display: none; }

.modal {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 520px;
  max-width: calc(100vw - 32px);
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-md), var(--shadow-glow);
  animation: slideUp 0.25s ease;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
}

.modal-header h2 {
  font-size: 16px;
  font-weight: 600;
}

#btn-close-settings {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 5px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  transition: color var(--transition), background var(--transition);
}

#btn-close-settings:hover { color: var(--text-primary); background: var(--bg-glass-hover); }

.modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.form-group { display: flex; flex-direction: column; gap: 6px; }

.form-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
}

.form-input, .form-textarea, .form-select {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 14px;
  padding: 9px 12px;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
  width: 100%;
}

.form-input:focus, .form-textarea:focus, .form-select:focus {
  border-color: var(--border-accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.form-textarea {
  resize: vertical;
  min-height: 90px;
  line-height: 1.6;
  font-size: 13.5px;
}

.form-hint {
  font-size: 12px;
  color: var(--text-muted);
}

.form-select option { background: var(--bg-elevated); }

.modal-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.btn-secondary {
  padding: 8px 16px;
  background: var(--bg-glass);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 13.5px;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
}

.btn-secondary:hover { background: var(--bg-glass-hover); color: var(--text-primary); }

.btn-primary {
  padding: 8px 20px;
  background: linear-gradient(135deg, var(--accent), var(--accent-light));
  border: none;
  border-radius: var(--radius-sm);
  color: white;
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  box-shadow: 0 2px 8px var(--accent-glow);
  transition: opacity var(--transition), transform var(--transition);
}

.btn-primary:hover { opacity: 0.9; transform: translateY(-1px); }

/* ─── Toast ──────────────────────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 200;
}

.toast {
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 500;
  color: white;
  box-shadow: var(--shadow-md);
  animation: slideUp 0.3s ease;
}

.toast.success { background: var(--success); }
.toast.error   { background: var(--danger); }
.toast.info    { background: var(--accent); }

/* ─── Loading spinner ────────────────────────────────────────── */
.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,0.2);
  border-top-color: var(--accent-light);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}

/* ─── Animações ──────────────────────────────────────────────── */
@keyframes fadeIn  { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes blink   { 50% { opacity: 0; } }
@keyframes spin    { to { transform: rotate(360deg); } }

/* ─── Responsivo ─────────────────────────────────────────────── */
@media (max-width: 640px) {
  :root { --sidebar-w: 100vw; }

  #sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100%;
    z-index: 50;
    transform: translateX(-100%);
  }

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

  #chat-header { padding: 12px 16px; }
  #messages    { padding: 16px; }
  #input-area  { padding: 12px 16px 16px; }
}

/* ─── Status de conexão ──────────────────────────────────────── */
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 6px var(--success);
  animation: pulse 2s ease-in-out infinite;
  flex-shrink: 0;
}

.status-dot.error { background: var(--danger); box-shadow: 0 0 6px var(--danger); animation: none; }
.status-dot.loading { background: #f59e0b; box-shadow: 0 0 6px #f59e0b; }


@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.4; }
}

/* ─── v2: Sidebar Colapsável (Feature 15) ────────────────────── */
#sidebar {
  transition: width 0.25s ease, min-width 0.25s ease, opacity 0.2s ease;
}

#sidebar.collapsed {
  width: 0;
  min-width: 0;
  overflow: hidden;
  opacity: 0;
  border-right: none;
}

#btn-toggle-sidebar {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color var(--transition), background var(--transition);
  flex-shrink: 0;
}

#btn-toggle-sidebar:hover {
  color: var(--text-primary);
  background: var(--bg-glass-hover);
}

/* ─── v2: Thinking Animation (Feature 17) ───────────────────── */
.thinking {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 4px 0;
}

.thinking .dot {
  width: 7px;
  height: 7px;
  background: var(--accent-light);
  border-radius: 50%;
  animation: bounce 1.2s ease-in-out infinite;
  opacity: 0.7;
}

.thinking .dot:nth-child(2) { animation-delay: 0.2s; }
.thinking .dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes bounce {
  0%, 80%, 100% { transform: translateY(0);   opacity: 0.4; }
  40%           { transform: translateY(-6px); opacity: 1;   }
}

/* ─── v2: Botões de Ação nas Mensagens (Features 1, 2, 4) ───── */
.msg-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 5px;
  font-weight: 500;
}

.message.user .msg-meta { flex-direction: row-reverse; }

.msg-actions {
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity var(--transition);
}

.message:hover .msg-actions { opacity: 1; }

.msg-action-btn {
  background: var(--bg-glass);
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
  line-height: 1;
}

.msg-action-btn:hover {
  background: var(--bg-glass-hover);
  color: var(--text-primary);
  border-color: var(--border-accent);
}

/* ─── v2: Stop Button (Feature 3) ───────────────────────────── */
#btn-stop {
  width: 36px;
  height: 36px;
  background: var(--danger-dim);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: 10px;
  color: var(--danger);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 15px;
  transition: background var(--transition), transform var(--transition);
}

#btn-stop:hover {
  background: rgba(239, 68, 68, 0.25);
  transform: scale(1.04);
}

#btn-stop.hidden, #btn-send.hidden { display: none; }

/* ─── v2: File Upload (Feature 7) ───────────────────────────── */
#btn-file-upload {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 6px;
  font-size: 17px;
  display: flex;
  align-items: center;
  transition: color var(--transition), background var(--transition);
  flex-shrink: 0;
}

#btn-file-upload:hover {
  color: var(--accent-light);
  background: var(--accent-dim);
}

#file-preview {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: var(--accent-dim);
  border: 1px solid var(--border-accent);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  font-size: 12.5px;
  color: var(--accent-light);
}

#file-preview.hidden { display: none; }

#file-preview-name {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#btn-remove-file {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  padding: 0 2px;
  transition: color var(--transition);
}

#btn-remove-file:hover { color: var(--danger); }

/* ─── v2: Tags / Pastas (Feature 10) ────────────────────────── */
.tags-section {
  padding: 8px 8px 4px;
  border-top: 1px solid var(--border);
  margin-top: 4px;
}

.tag-filter-item {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  color: var(--text-secondary);
  transition: background var(--transition), color var(--transition);
  position: relative;
}

.tag-filter-item:hover { background: var(--bg-glass-hover); color: var(--text-primary); }
.tag-filter-item.active { background: var(--accent-dim); color: var(--text-primary); }

.tag-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
}

.tag-name { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.tag-delete-btn {
  opacity: 0;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  padding: 0 2px;
  border-radius: 3px;
  transition: opacity var(--transition), color var(--transition);
}

.tag-filter-item:hover .tag-delete-btn { opacity: 1; }
.tag-delete-btn:hover { color: var(--danger); }

#btn-new-tag {
  width: 100%;
  padding: 6px 8px;
  background: none;
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-family: inherit;
  font-size: 12.5px;
  cursor: pointer;
  margin-top: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: border-color var(--transition), color var(--transition), background var(--transition);
}

#btn-new-tag:hover {
  border-color: var(--border-accent);
  color: var(--accent-light);
  background: var(--accent-dim);
}

/* Dots de tags nas conversas */
.conv-tags-row {
  display: flex;
  gap: 3px;
  align-items: center;
  flex-shrink: 0;
}

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

.conv-tag-btn {
  opacity: 0;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 13px;
  padding: 2px 3px;
  border-radius: 4px;
  transition: opacity var(--transition), background var(--transition);
  flex-shrink: 0;
}

.conv-item:hover .conv-tag-btn { opacity: 1; }
.conv-tag-btn:hover { background: var(--bg-glass-hover); }

/* Menu flutuante de tags */
.tag-assign-menu {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  min-width: 160px;
  z-index: 200;
  overflow: hidden;
  animation: slideUp 0.15s ease;
}

.tag-assign-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  font-size: 13px;
  cursor: pointer;
  color: var(--text-secondary);
  transition: background var(--transition), color var(--transition);
}

.tag-assign-item:hover   { background: var(--bg-glass-hover); color: var(--text-primary); }
.tag-assign-item.assigned{ color: var(--accent-light); }

.tag-check { margin-left: auto; font-size: 12px; }

/* ─── v2: Edição de mensagem — highlight no input ───────────── */
#message-input.editing {
  border-color: var(--accent) !important;
  box-shadow: 0 0 0 2px var(--accent-dim) !important;
}

/* ─── v2: Stream status ──────────────────────────────────────── */
.stream-stopped {
  display: block;
  color: var(--text-muted);
  font-size: 12px;
  margin-top: 8px;
  font-style: italic;
}

.stream-error { color: var(--danger); }

/* ─── v2: Empty conv message ─────────────────────────────────── */
.conv-empty-msg {
  padding: 12px 8px;
  font-size: 12.5px;
  color: var(--text-muted);
  text-align: center;
}

/* ─── v3: Pastas e Projetos ─────────────────────────────────── */
.folders-section {
  padding: 8px 8px 4px;
  border-top: 1px solid var(--border);
  margin-top: 4px;
}

.folders-section .section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
  padding: 0 4px;
}

#btn-new-folder {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 3px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition), color var(--transition);
}
#btn-new-folder:hover {
  background: var(--bg-glass-hover);
  color: var(--accent-light);
}

.folder-item {
  margin-bottom: 5px;
}

.folder-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  background: var(--bg-glass);
  transition: background var(--transition), border-color var(--transition);
  border: 1px solid transparent;
}

.folder-header:hover {
  background: var(--bg-glass-hover);
  border-color: var(--border);
}

.folder-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
  font-size: 13.5px;
  color: var(--text-secondary);
  flex: 1;
  overflow: hidden;
}

.folder-title span:last-child {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.folder-chevron {
  font-size: 10px;
  color: var(--text-muted);
  transition: transform var(--transition);
  width: 12px;
  display: inline-block;
  text-align: center;
}

.folder-item.collapsed .folder-chevron {
  transform: rotate(-90deg);
}

.folder-actions {
  display: flex;
  gap: 2px;
}

.folder-action-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 13px;
  padding: 3px 5px;
  border-radius: 4px;
  transition: color var(--transition), background var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.folder-action-btn:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.1);
}

.folder-action-btn.btn-delete-folder:hover {
  color: var(--danger);
  background: var(--danger-dim);
}

.folder-conversations {
  padding-left: 14px;
  margin-top: 4px;
  border-left: 1px dashed var(--border);
  transition: max-height 0.25s ease-out, opacity 0.2s ease;
}

.folder-item.collapsed .folder-conversations {
  display: none;
}

/* ─── v3: Seletor de Pasta no Header ────────────────────────── */
.folder-selector-wrapper {
  margin-left: 12px;
  margin-right: auto;
  position: relative;
}

.header-action-btn {
  background: var(--bg-glass);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-secondary);
  padding: 6px 12px;
  font-size: 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: background var(--transition), border-color var(--transition), color var(--transition);
}

.header-action-btn:hover {
  background: var(--bg-glass-hover);
  border-color: var(--border-accent);
  color: var(--text-primary);
}

/* Menu Dropdown de Seleção de Pasta */
.folder-dropdown-menu {
  position: absolute;
  top: 105%;
  left: 0;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  min-width: 200px;
  z-index: 200;
  overflow: hidden;
  animation: slideUp 0.15s ease;
}

.folder-dropdown-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  font-size: 13.5px;
  cursor: pointer;
  color: var(--text-secondary);
  transition: background var(--transition), color var(--transition);
}

.folder-dropdown-item:hover {
  background: var(--bg-glass-hover);
  color: var(--text-primary);
}

.folder-dropdown-item.active {
  color: var(--accent-light);
  background: var(--accent-dim);
  font-weight: 500;
}

/* ─── v3: Modal de Gerenciamento de Regras ──────────────────── */
.rules-list-container {
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  max-height: 180px;
  overflow-y: auto;
  margin-bottom: 20px;
}

.rule-list-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.01);
  transition: background var(--transition);
}

.rule-list-item:hover {
  background: rgba(255, 255, 255, 0.03);
}

.rule-list-item:last-child {
  border-bottom: none;
}

.rule-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow: hidden;
}

.rule-filename {
  font-weight: 500;
  font-size: 13px;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rule-size {
  font-size: 11px;
  color: var(--text-muted);
}

.add-rule-section h3 {
  font-size: 14px;
  color: var(--text-primary);
  margin-bottom: 12px;
}

.tabs-control {
  display: flex;
  gap: 4px;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--border);
}

.tab-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-weight: 500;
  font-size: 13px;
  cursor: pointer;
  padding: 8px 12px;
  border-bottom: 2px solid transparent;
  transition: color var(--transition), border-color var(--transition);
}

.tab-btn:hover {
  color: var(--text-secondary);
}

.tab-btn.active {
  color: var(--accent-light);
  border-bottom-color: var(--accent);
}

.upload-rule-dropzone {
  border: 2px dashed var(--border);
  border-radius: var(--radius-sm);
  padding: 24px;
  text-align: center;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.01);
  transition: border-color var(--transition), background var(--transition);
}

.upload-rule-dropzone:hover {
  border-color: var(--accent);
  background: var(--accent-dim);
}

.upload-rule-dropzone p {
  font-size: 13px;
  color: var(--text-secondary);
}

.upload-rule-dropzone p span {
  color: var(--accent-light);
  font-weight: 500;
}

.file-types {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 6px;
}

.tab-content.hidden {
  display: none;
}


