:root {
  --bg-main: #090d16;
  --bg-surface: #0f172a;
  --bg-surface-elevated: #1e293b;
  --bg-glass: rgba(15, 23, 42, 0.75);
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-focus: rgba(16, 185, 129, 0.4);
  
  --primary: #10b981;
  --primary-hover: #059669;
  --primary-glow: rgba(16, 185, 129, 0.25);
  --accent: #06b6d4;
  --accent-purple: #8b5cf6;
  --danger: #ef4444;
  --warning: #f59e0b;

  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-full: 9999px;

  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s ease;
  --shadow-glow: 0 0 25px rgba(16, 185, 129, 0.15);
  --shadow-card: 0 10px 30px -5px rgba(0, 0, 0, 0.5), 0 0 0 1px var(--border-subtle);
}

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

* {
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.18) transparent;
}

::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 9999px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(16, 185, 129, 0.4);
}

body {
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  background-color: var(--bg-main);
  color: var(--text-main);
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background-image: 
    radial-gradient(circle at 15% 15%, rgba(16, 185, 129, 0.05) 0%, transparent 40%),
    radial-gradient(circle at 85% 85%, rgba(6, 182, 212, 0.05) 0%, transparent 40%);
}

.hidden {
  display: none !important;
}

/* Input de arquivo nativo — fica oculto; a dropzone é clicável por cima */
.hidden-input {
  display: none !important;
}

code, pre {
  font-family: 'JetBrains Mono', monospace;
}

/* ==================== TELA DE LOGIN ==================== */
.auth-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at center, #0e1726 0%, #060911 100%);
  z-index: 1000;
  padding: 20px;
}

.auth-card {
  width: 100%;
  max-width: 440px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 40px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6), 0 0 40px rgba(16, 185, 129, 0.1);
  position: relative;
  overflow: hidden;
  backdrop-filter: blur(12px);
  animation: fadeInScale 0.4s ease forwards;
}

.auth-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--primary), var(--accent), var(--accent-purple));
}

.brand-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.25);
  padding: 4px 12px;
  border-radius: var(--radius-full);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--primary);
  margin-bottom: 20px;
}

.pulse-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--primary);
  box-shadow: 0 0 8px var(--primary);
  animation: pulse 2s infinite;
}

.brand-header {
  margin-bottom: 28px;
}

.brand-icon {
  width: 52px;
  height: 52px;
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.2), rgba(6, 182, 212, 0.1));
  border: 1px solid rgba(16, 185, 129, 0.3);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  color: var(--primary);
  margin-bottom: 16px;
  box-shadow: var(--shadow-glow);
}

.brand-header h1 {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 6px;
  background: linear-gradient(120deg, #ffffff 40%, var(--text-muted));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-header p {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.input-group {
  margin-bottom: 18px;
}

.input-group label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.input-group label i {
  color: var(--primary);
  margin-right: 4px;
}

.input-group input, .styled-select {
  width: 100%;
  padding: 13px 16px;
  background: rgba(10, 15, 26, 0.8);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-main);
  font-size: 0.95rem;
  font-family: inherit;
  transition: all var(--transition-fast);
  outline: none;
}

.input-group input:focus, .styled-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.alert-box {
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  margin-bottom: 18px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #fca5a5;
}

.btn-primary {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: linear-gradient(135deg, var(--primary), var(--primary-hover));
  color: #042f20;
  border: none;
  padding: 14px 20px;
  border-radius: var(--radius-md);
  font-size: 0.95rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--transition-fast);
  box-shadow: 0 4px 15px rgba(16, 185, 129, 0.3);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(16, 185, 129, 0.4);
}

.auth-footer {
  margin-top: 24px;
  text-align: center;
  font-size: 0.78rem;
  color: var(--text-dim);
}

/* ==================== APLICAÇÃO PRINCIPAL ==================== */
.app-layout {
  display: flex;
  flex-direction: column;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
}

/* Header */
.app-header {
  height: 64px;
  border-bottom: 1px solid var(--border-subtle);
  background: rgba(11, 17, 30, 0.85);
  backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  z-index: 100;
}

.header-left, .header-center, .header-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.brand-mini {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mini i {
  color: var(--primary);
  font-size: 1.3rem;
  filter: drop-shadow(0 0 6px var(--primary));
}

.brand-name {
  font-weight: 800;
  letter-spacing: 0.04em;
  font-size: 1.05rem;
}

.badge-status {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  gap: 6px;
}

.badge-status.online {
  background: rgba(16, 185, 129, 0.12);
  color: var(--primary);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.badge-status i {
  font-size: 0.45rem;
}

.model-picker-wrapper {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  padding: 6px 14px;
  border-radius: var(--radius-full);
  font-size: 0.82rem;
  color: var(--text-muted);
}

.model-picker-wrapper select {
  background: transparent;
  border: none;
  color: var(--text-main);
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  outline: none;
}

.model-picker-wrapper select option {
  background: var(--bg-surface);
  color: var(--text-main);
}

.btn-secondary {
  background: var(--bg-surface-elevated);
  color: var(--text-main);
  border: 1px solid var(--border-subtle);
  padding: 8px 16px;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all var(--transition-fast);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.2);
}

/* Botão do menu (hambúrguer): oculto no desktop, visível apenas no mobile.
   CORREÇÃO: antes o style="display:none" inline vencia o CSS e o botão
   nunca aparecia no celular — impossível abrir o menu de conversas/pastas. */
#btn-sidebar-toggle {
  display: none;
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid transparent;
  padding: 8px 14px;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all var(--transition-fast);
}

.btn-ghost:hover {
  color: var(--danger);
  background: rgba(239, 68, 68, 0.1);
}

/* ==================== CORPO & SIDEBAR ==================== */
.app-body {
  display: flex;
  flex: 1;
  overflow: hidden;
  min-height: 0;
}

.sidebar {
  width: 360px;
  border-right: 1px solid var(--border-subtle);
  background: rgba(13, 19, 33, 0.96);
  display: flex;
  flex-direction: column;
  padding: 12px;
  gap: 10px;
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  min-height: 0;
}

/* Botão Novo Chat */
.btn-new-chat {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-shrink: 0;
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.2), rgba(6, 182, 212, 0.15));
  border: 1px solid rgba(16, 185, 129, 0.4);
  color: #a7f3d0;
  padding: 8px 14px;
  border-radius: var(--radius-md);
  font-size: 0.82rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--transition-fast);
  box-shadow: 0 4px 15px rgba(16, 185, 129, 0.1);
}

.btn-new-chat:hover {
  background: linear-gradient(135deg, var(--primary), var(--primary-hover));
  color: #042f20;
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(16, 185, 129, 0.3);
}

/* Abas da Sidebar */
.sidebar-tabs {
  display: flex;
  gap: 4px;
  background: rgba(255, 255, 255, 0.03);
  padding: 2px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.sidebar-tab {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 6px 5px;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  font-family: inherit;
  font-size: 0.74rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  min-width: 0;
}

/* Rótulo da aba em linha única (sem quebrar em 2 linhas) */
.sidebar-tab span:not(.tab-badge) {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-tab:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.05);
}

.sidebar-tab.active {
  background: var(--bg-surface-elevated);
  color: var(--primary);
  font-weight: 700;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.tab-badge {
  background: rgba(16, 185, 129, 0.2);
  color: var(--primary);
  border: 1px solid rgba(16, 185, 129, 0.4);
  font-size: 0.65rem;
  padding: 0 5px;
  border-radius: var(--radius-full);
  flex-shrink: 0;
}

.tab-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
}

/* ABA 1: LISTA DE CHATS */
.chats-section-header, .folders-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-dim);
  letter-spacing: 0.05em;
  margin-bottom: 8px;
  padding: 0 4px;
  flex-shrink: 0;
}

.badge-subtle {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-muted);
  padding: 2px 7px;
  border-radius: var(--radius-full);
  font-size: 0.7rem;
}

.chats-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-right: 4px;
}

.chat-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
  flex-shrink: 0;
}

.chat-item:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.15);
}

.chat-item.active {
  background: rgba(16, 185, 129, 0.08);
  border-color: rgba(16, 185, 129, 0.4);
  box-shadow: 0 0 12px rgba(16, 185, 129, 0.1);
}

.chat-item-icon {
  color: var(--primary);
  font-size: 0.95rem;
}

.chat-item-info {
  flex: 1;
  min-width: 0;
}

.chat-item-title {
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-item-meta {
  font-size: 0.68rem;
  color: var(--text-dim);
  margin-top: 2px;
}

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

.chat-item:hover .chat-item-actions,
.chat-item.active .chat-item-actions {
  opacity: 1;
}

.btn-item-action {
  background: transparent;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  padding: 4px;
  font-size: 0.8rem;
  border-radius: 4px;
}

.btn-item-action:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.1);
}

.btn-item-action.delete:hover {
  color: var(--danger);
  background: rgba(239, 68, 68, 0.15);
}

/* ABA 2: PASTAS E ARQUIVOS */
.btn-tool-sm {
  background: rgba(16, 185, 129, 0.12);
  color: var(--primary);
  border: 1px solid rgba(16, 185, 129, 0.3);
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all var(--transition-fast);
}

.btn-tool-sm:hover {
  background: var(--primary);
  color: #042f20;
}

.upload-folder-selector {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.03);
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  margin-bottom: 8px;
  flex-shrink: 0;
}

.upload-folder-selector label {
  font-size: 0.72rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.upload-folder-selector select {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--primary);
  font-weight: 700;
  font-size: 0.78rem;
  font-family: inherit;
  cursor: pointer;
  outline: none;
}

.upload-folder-selector select option {
  background: var(--bg-surface);
  color: var(--text-main);
}

/* Upload Dropzone */
.upload-dropzone {
  border: 1.5px dashed rgba(16, 185, 129, 0.3);
  background: rgba(16, 185, 129, 0.03);
  border-radius: var(--radius-md);
  padding: 14px 10px;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition-normal);
  position: relative;
  overflow: hidden;
  margin-bottom: 12px;
  flex-shrink: 0;
}

.upload-dropzone:hover, .upload-dropzone.dragover {
  border-color: var(--primary);
  background: rgba(16, 185, 129, 0.08);
}

.drop-icon {
  font-size: 1.4rem;
  color: var(--primary);
  margin-bottom: 4px;
  display: inline-block;
}

.drop-text {
  font-size: 0.78rem;
  color: var(--text-main);
}

.drop-formats {
  font-size: 0.65rem;
  color: var(--text-dim);
}

.upload-progress {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: rgba(255, 255, 255, 0.1);
}

.progress-bar-fill {
  height: 100%;
  width: 0%;
  background: var(--primary);
}

/* Árvore de Pastas */
.folders-tree {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-right: 4px;
}

.folder-block {
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.02);
  overflow: hidden;
  transition: border-color var(--transition-fast);
  /* CORREÇÃO DE SCROLL: impede que o flexbox esprema o bloco da pasta.
     Sem isso, o overflow:hidden clipava os arquivos e a árvore nunca
     transbordava — logo, nunca havia barra de rolagem. */
  flex-shrink: 0;
}

.folder-block:hover {
  border-color: rgba(255, 255, 255, 0.15);
}

.folder-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.03);
  cursor: pointer;
  user-select: none;
}

.folder-toggle-btn {
  color: var(--text-dim);
  font-size: 0.75rem;
  transition: transform var(--transition-fast);
}

.folder-block.open .folder-toggle-btn {
  transform: rotate(90deg);
}

.folder-icon {
  color: var(--warning);
  font-size: 0.9rem;
}

.folder-name {
  flex: 1;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.folder-badge-count {
  font-size: 0.68rem;
  color: var(--text-dim);
  background: rgba(255, 255, 255, 0.06);
  padding: 1px 6px;
  border-radius: var(--radius-full);
}

.folder-select-all {
  accent-color: var(--primary);
  cursor: pointer;
}

.folder-delete-btn {
  background: transparent;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  padding: 2px 4px;
  font-size: 0.75rem;
}

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

.folder-content {
  display: none;
  flex-direction: column;
  gap: 4px;
  padding: 8px;
  background: rgba(0, 0, 0, 0.2);
}

.folder-block.open .folder-content {
  display: flex;
}

.folder-file-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid transparent;
  transition: all var(--transition-fast);
}

.folder-file-item:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--border-subtle);
}

.folder-file-item.active {
  border-color: rgba(16, 185, 129, 0.35);
  background: rgba(16, 185, 129, 0.06);
}

.file-checkbox {
  accent-color: var(--primary);
  cursor: pointer;
}

.file-name-text {
  flex: 1;
  font-size: 0.78rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-size-tag {
  font-size: 0.65rem;
  color: var(--text-dim);
}

.file-actions {
  display: flex;
  gap: 4px;
}

.btn-file-tool {
  background: transparent;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  padding: 2px;
  font-size: 0.72rem;
}

.btn-file-tool:hover {
  color: var(--text-main);
}

.btn-file-tool.delete:hover {
  color: var(--danger);
}

.folder-empty-tip {
  padding: 10px;
  text-align: center;
  font-size: 0.72rem;
  color: var(--text-dim);
}

.sidebar-footer {
  border-top: 1px solid var(--border-subtle);
  padding-top: 10px;
  flex-shrink: 0;
}

.file-summary {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.7rem;
  color: var(--text-dim);
  line-height: 1.3;
}

.file-summary i {
  color: var(--primary);
}

/* ==================== ÁREA DE CHAT ==================== */
.chat-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
  background: var(--bg-main);
  overflow: hidden;
  position: relative;
}

/* Barra de Metadados do Chat */
.chat-meta-bar {
  padding: 10px 24px;
  border-bottom: 1px solid var(--border-subtle);
  background: rgba(15, 23, 42, 0.4);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.chat-title-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.chat-title-group h3 {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-main);
}

.btn-icon-xs {
  background: transparent;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  padding: 4px;
  font-size: 0.85rem;
  border-radius: 4px;
}

.btn-icon-xs:hover {
  color: var(--primary);
  background: rgba(16, 185, 129, 0.1);
}

.context-bar-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.25);
  color: var(--primary);
  padding: 4px 12px;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 600;
}

/* Mensagens */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  scroll-behavior: smooth;
}

.welcome-hero {
  max-width: 680px;
  margin: auto;
  text-align: center;
  padding: 40px 20px;
}

.hero-icon {
  width: 68px;
  height: 68px;
  margin: 0 auto 20px;
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.15), rgba(6, 182, 212, 0.1));
  border: 1px solid rgba(16, 185, 129, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  color: var(--primary);
  box-shadow: var(--shadow-glow);
}

.welcome-hero h2 {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  margin-bottom: 12px;
}

.welcome-hero p {
  color: var(--text-muted);
  font-size: 0.92rem;
  line-height: 1.6;
  margin-bottom: 28px;
}

.quick-prompts {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
}

.prompt-chip {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  padding: 10px 16px;
  border-radius: var(--radius-full);
  font-size: 0.82rem;
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all var(--transition-fast);
}

.prompt-chip:hover {
  background: var(--bg-surface-elevated);
  border-color: var(--primary);
  color: var(--text-main);
  transform: translateY(-2px);
}

.prompt-chip i {
  color: var(--primary);
}

/* Mensagens de Chat */
.message-row {
  display: flex;
  gap: 16px;
  max-width: 880px;
  width: 100%;
  margin: 0 auto;
  animation: fadeIn 0.3s ease forwards;
}

.message-avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 0.95rem;
}

.message-row.user .message-avatar {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--accent);
}

.message-row.model .message-avatar {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.2), rgba(6, 182, 212, 0.2));
  border: 1px solid rgba(16, 185, 129, 0.4);
  color: var(--primary);
  box-shadow: 0 0 12px rgba(16, 185, 129, 0.2);
}

.message-content-wrapper {
  flex: 1;
  min-width: 0;
}

.message-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.message-sender {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-main);
}

.message-time {
  font-size: 0.7rem;
  color: var(--text-dim);
}

.message-body {
  font-size: 0.95rem;
  line-height: 1.65;
  color: #e2e8f0;
}

.message-row.user .message-body {
  background: rgba(30, 41, 59, 0.6);
  border: 1px solid var(--border-subtle);
  padding: 14px 18px;
  border-radius: var(--radius-md);
  color: #f8fafc;
}

.message-body h1, .message-body h2, .message-body h3, .message-body h4 {
  margin: 18px 0 10px;
  color: #ffffff;
  font-weight: 700;
}

.message-body p {
  margin-bottom: 12px;
}

.message-body p:last-child {
  margin-bottom: 0;
}

.message-body ul, .message-body ol {
  margin: 10px 0 14px 24px;
}

.message-body li {
  margin-bottom: 6px;
}

.message-body blockquote {
  border-left: 3px solid var(--primary);
  padding-left: 14px;
  color: var(--text-muted);
  margin: 14px 0;
}

.message-body pre {
  background: #0f172a;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 14px;
  overflow-x: auto;
  margin: 14px 0;
  position: relative;
}

.message-body code {
  background: rgba(255, 255, 255, 0.08);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.88em;
  color: #38bdf8;
}

.message-body pre code {
  background: transparent;
  padding: 0;
  color: inherit;
}

.typing-cursor::after {
  content: '▋';
  color: var(--primary);
  animation: blink 0.8s infinite;
}

/* Chat Input Wrapper */
.chat-input-wrapper {
  padding: 16px 24px 20px;
  background: linear-gradient(180deg, transparent 0%, rgba(9, 13, 22, 0.95) 40%);
}

.chat-form {
  max-width: 880px;
  margin: 0 auto;
}

.input-container {
  display: flex;
  align-items: flex-end;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 8px 12px 8px 16px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
  transition: border-color var(--transition-fast);
}

.input-container:focus-within {
  border-color: var(--primary);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3), 0 0 0 2px var(--primary-glow);
}

.input-container textarea {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-main);
  font-family: inherit;
  font-size: 0.95rem;
  resize: none;
  max-height: 180px;
  min-height: 38px;
  line-height: 1.5;
  padding: 8px 0;
  outline: none;
}

.input-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.btn-tool {
  background: transparent;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  padding: 8px;
  border-radius: var(--radius-sm);
  font-size: 1rem;
  transition: all var(--transition-fast);
}

.btn-tool:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.06);
}

.btn-send {
  background: linear-gradient(135deg, var(--primary), var(--primary-hover));
  color: #042f20;
  border: none;
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-fast);
  box-shadow: 0 0 15px rgba(16, 185, 129, 0.3);
}

.btn-send:hover {
  transform: scale(1.05);
  box-shadow: 0 0 20px rgba(16, 185, 129, 0.5);
}

.btn-send:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

.input-hints {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.72rem;
  color: var(--text-dim);
  margin-top: 8px;
  padding: 0 6px;
}

.status-ready {
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 4px;
}

/* ==================== MODAL ==================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.2s ease;
}

.modal-card {
  width: 100%;
  max-width: 580px;
  max-height: 90vh;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
}

.modal-card-sm {
  max-width: 440px;
}

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

.modal-title {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-main);
}

.modal-title i {
  color: var(--primary);
}

.btn-icon {
  background: transparent;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  padding: 4px;
  font-size: 0.85rem;
}

.btn-icon:hover {
  color: var(--text-main);
}

.modal-body {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}

.modal-desc {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 16px;
}

.modal-body textarea {
  width: 100%;
  background: var(--bg-main);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 12px;
  color: var(--text-main);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.88rem;
  resize: vertical;
  outline: none;
}

.modal-body textarea:focus {
  border-color: var(--primary);
}

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

/* ==================== GOOGLE CALENDAR / AGENDA MODAL ==================== */
#modal-agenda .modal-card-calendar {
  max-width: 1200px;
  width: 95vw;
  height: 88vh;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  background: #0d1322;
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.7), 0 0 30px rgba(16, 185, 129, 0.15);
}

.badge-ai-sync {
  font-size: 0.68rem;
  padding: 3px 8px;
  background: rgba(16, 185, 129, 0.12);
  color: var(--primary);
  border: 1px solid rgba(16, 185, 129, 0.3);
  border-radius: var(--radius-full);
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.calendar-header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.cal-nav-buttons {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.04);
  padding: 3px 8px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
}

.cal-current-label {
  font-weight: 700;
  font-size: 0.92rem;
  color: var(--text-main);
  min-width: 140px;
  text-align: center;
  user-select: none;
}

.btn-cal-action {
  background: linear-gradient(135deg, var(--primary), var(--primary-hover));
  color: #042f20 !important;
  font-weight: 800;
  border: none;
}
.btn-cal-action:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.calendar-layout-body {
  flex: 1;
  display: flex;
  overflow: hidden;
  min-height: 0;
}

/* Coluna do Grid do Calendário */
.calendar-grid-column {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 16px;
  overflow-y: auto;
  min-width: 0;
}

.calendar-weekdays-header {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  text-align: center;
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--text-dim);
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-subtle);
}

.calendar-days-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  grid-auto-rows: minmax(85px, 1fr);
  gap: 6px;
  margin-top: 8px;
  flex: 1;
}

.cal-day-cell {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 6px 8px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  transition: all var(--transition-fast);
  min-height: 80px;
  position: relative;
  overflow: hidden;
}

.cal-day-cell:hover {
  border-color: rgba(16, 185, 129, 0.4);
  background: rgba(16, 185, 129, 0.04);
  transform: translateY(-1px);
}

.cal-day-cell.other-month {
  opacity: 0.3;
  background: transparent;
}

.cal-day-cell.today {
  border-color: var(--primary);
  background: rgba(16, 185, 129, 0.06);
  box-shadow: inset 0 0 12px rgba(16, 185, 129, 0.1);
}

.cal-day-cell.selected {
  border: 2px solid var(--accent);
  background: rgba(6, 182, 212, 0.12);
  box-shadow: 0 0 12px rgba(6, 182, 212, 0.2);
}

.cal-day-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.cal-day-number {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-muted);
}

.cal-day-cell.today .cal-day-number {
  display: inline-flex;
  width: 22px;
  height: 22px;
  align-items: center;
  justify-content: center;
  background: var(--primary);
  color: #042f20;
  border-radius: 50%;
  font-weight: 800;
  font-size: 0.75rem;
}

.cal-day-events-container {
  display: flex;
  flex-direction: column;
  gap: 3px;
  overflow: hidden;
  flex: 1;
}

.cal-event-pill {
  font-size: 0.65rem;
  padding: 2px 6px;
  border-radius: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 600;
  line-height: 1.3;
}

.cal-event-pill.prio-normal {
  background: rgba(16, 185, 129, 0.2);
  color: #a7f3d0;
  border-left: 2px solid var(--primary);
}

.cal-event-pill.prio-media {
  background: rgba(6, 182, 212, 0.2);
  color: #a5f3fc;
  border-left: 2px solid var(--accent);
}

.cal-event-pill.prio-alta {
  background: rgba(239, 68, 68, 0.25);
  color: #fca5a5;
  border-left: 2px solid var(--danger);
}

.cal-more-badge {
  font-size: 0.62rem;
  color: var(--text-dim);
  font-weight: 700;
  margin-top: 1px;
}

/* Coluna Lateral de Detalhes / Formulário */
.calendar-details-column {
  width: 380px;
  border-left: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  background: rgba(10, 15, 26, 0.75);
  overflow-y: auto;
  padding: 20px;
}

.cal-side-panel {
  display: flex;
  flex-direction: column;
  flex: 1;
  gap: 16px;
}

.side-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-subtle);
}

.panel-subtitle {
  font-size: 0.68rem;
  font-weight: 800;
  color: var(--primary);
  letter-spacing: 0.06em;
}

.side-panel-header h4 {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--text-main);
  margin-top: 2px;
}

.cal-day-events-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
  flex: 1;
}

.cal-empty-state {
  text-align: center;
  padding: 40px 10px;
  color: var(--text-dim);
}
.cal-empty-state i {
  font-size: 2.2rem;
  opacity: 0.3;
  margin-bottom: 10px;
  display: block;
}
.cal-empty-state p {
  font-size: 0.85rem;
  margin-bottom: 14px;
}

.cal-day-event-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: all var(--transition-fast);
  position: relative;
}

.cal-day-event-card:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.15);
}

.cal-day-event-card.prio-alta {
  border-left: 3px solid var(--danger);
}
.cal-day-event-card.prio-media {
  border-left: 3px solid var(--accent);
}
.cal-day-event-card.prio-normal {
  border-left: 3px solid var(--primary);
}

.card-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.card-event-title {
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--text-main);
  word-break: break-word;
}

.card-badge-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.card-time-badge {
  font-size: 0.72rem;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.card-folder-badge {
  font-size: 0.68rem;
  padding: 2px 6px;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.card-prio-badge {
  font-size: 0.65rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 4px;
  text-transform: uppercase;
}
.card-prio-badge.alta {
  background: rgba(239, 68, 68, 0.2);
  color: #fca5a5;
}
.card-prio-badge.media {
  background: rgba(6, 182, 212, 0.2);
  color: #a5f3fc;
}
.card-prio-badge.normal {
  background: rgba(16, 185, 129, 0.2);
  color: #a7f3d0;
}

.card-desc {
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.4;
  white-space: pre-wrap;
}

.card-actions-row {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 4px;
  border-top: 1px solid rgba(255, 255, 255, 0.04);
  padding-top: 6px;
}

/* Formulário do Calendário */
.cal-form-styled {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.form-row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.cal-form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 10px;
}

/* Card de Ação de Agenda dentro do Chat */
.ia-agenda-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.12), rgba(6, 182, 212, 0.08));
  border: 1px solid rgba(16, 185, 129, 0.35);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  margin: 10px 0;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.ia-agenda-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: rgba(16, 185, 129, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary);
  font-size: 1.1rem;
  flex-shrink: 0;
}

.ia-agenda-details {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.ia-agenda-tag {
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  color: var(--primary);
}

.ia-agenda-title {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text-main);
}

.ia-agenda-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 8px;
}

@media (max-width: 850px) {
  .calendar-layout-body {
    flex-direction: column;
    overflow-y: auto;
  }
  .calendar-details-column {
    width: 100%;
    border-left: none;
    border-top: 1px solid var(--border-subtle);
  }
  .calendar-grid-column {
    overflow-y: visible;
  }
  .calendar-days-grid {
    grid-auto-rows: minmax(65px, 1fr);
  }
}

/* Animações */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeInScale {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}

@keyframes pulse {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
  70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

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

/* Responsividade Mobile-First */
@media (max-width: 900px) {
  /* Em telas pequenas a aba mostra só "Pastas" para caber em uma linha */
  .tab-suffix {
    display: none;
  }
  .sidebar {
    position: absolute;
    left: -360px;
    top: 64px;
    bottom: 0;
    z-index: 90;
    transition: left 0.3s ease;
  }
  .sidebar.open {
    left: 0;
  }
  .app-body {
    flex-direction: column;
  }
  .app-body .sidebar {
    position: fixed;
    left: 0;
    top: 64px;
    bottom: 0;
    width: 280px;
    z-index: 90;
    border-right: 1px solid var(--border-subtle);
    border-bottom: 1px solid var(--border-subtle);
    transform: translateX(-100%);
    transition: transform 0.3s ease;
  }
  .app-body .sidebar.open {
    transform: translateX(0);
  }
  .app-body .chat-section {
    margin-left: 0;
    width: 100%;
  }
  .app-body .chat-section.mobile-full {
    margin-left: 0;
    width: 100%;
  }
  /* Botão hambúrguer do menu no celular */
  #btn-sidebar-toggle {
    display: flex !important;
  }
}

@media (max-width: 600px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 64px;
    bottom: 0;
    width: 100%;
    z-index: 90;
    border-bottom: 1px solid var(--border-subtle);
    transform: translateX(0);
  }
  .app-body .chat-section {
    margin-left: 0;
    width: 100%;
  }
  
  .chat-messages {
    padding: 16px;
  }
  
  .welcome-hero {
    padding: 20px 12px;
  }
  
  .hero-icon {
    width: 48px;
    height: 48px;
    font-size: 1.5rem;
    margin: 0 auto 16px;
  }
  
  .welcome-hero h2 {
    font-size: 1.2rem;
    margin-bottom: 8px;
  }
  
  .welcome-hero p {
    font-size: 0.75rem;
    line-height: 1.4;
    margin-bottom: 16px;
  }
  
  .quick-prompts {
    gap: 6px;
  }
  
  .prompt-chip {
    padding: 8px 12px;
    font-size: 0.7rem;
  }
  
  .message-row {
    max-width: 100%;
    flex-direction: column;
    gap: 12px;
  }
  
  .message-content-wrapper {
    width: 100%;
  }
  
  .message-body {
    font-size: 0.85rem;
    line-height: 1.5;
  }
  
  .message-body pre {
    font-size: 0.75rem;
    padding: 10px;
  }
  
  .message-body code {
    font-size: 0.75rem;
    padding: 1px 4px;
  }
}

@media (max-width: 480px) {
  .chat-messages {
    padding: 12px;
  }
  
  .chat-input-wrapper {
    padding: 12px;
  }
  
  .input-container {
    border-radius: var(--radius-md);
    padding: 6px 8px;
  }
  
  .input-container textarea {
    font-size: 0.85rem;
    min-height: 32px;
    max-height: 140px;
  }
  
  .input-actions {
    gap: 4px;
  }
  
  .btn-send {
    width: 32px;
    height: 32px;
  }
  
  .input-hints {
    font-size: 0.65rem;
    flex-direction: column;
    gap: 4px;
    align-items: flex-start;
  }
  
  .status-ready {
    margin-bottom: 4px;
  }
  
  .sidebar-tab {
    padding: 6px 6px;
    font-size: 0.7rem;
  }
  
  .folder-name {
    font-size: 0.7rem;
  }
  
  .file-name-text {
    font-size: 0.65rem;
  }
  
  .file-size-tag {
    font-size: 0.55rem;
  }
  
  .chat-title-group h3 {
    font-size: 0.8rem;
  }
}
