/* ============================================================
   style.css — Central de Inteligência Direct
   Design system baseado no Stitch (dark, glassmorphism, Inter)
   ============================================================ */

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

/* ─── TOKENS ─────────────────────────────────────────────── */
:root {
  --bg-deep:      #090f1a;
  --bg-dark:      #0d1117;
  --bg-card:      rgba(255, 255, 255, 0.04);
  --bg-hover:     rgba(255, 255, 255, 0.07);
  --border:       rgba(255, 255, 255, 0.08);
  --border-glow:  rgba(6, 127, 249, 0.35);

  --accent:       #067ff9;
  --accent-light: #3a9dff;
  --accent-glow:  rgba(6, 127, 249, 0.2);
  --purple:       #7c3aed;

  --text:         #e6edf3;
  --text-muted:   #8b949e;
  --text-dim:     #484f58;

  --success:      #3fb950;
  --error:        #f85149;
  --warning:      #d29922;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;

  --glass-blur: blur(16px);
  --shadow-card: 0 4px 24px rgba(0,0,0,0.4);
  --shadow-glow: 0 0 20px rgba(6,127,249,0.15);

  --font: 'Inter', -apple-system, sans-serif;
  --transition: 0.2s ease;
}

/* ─── RESET ───────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { height: 100%; font-size: 16px; }
body {
  font-family: var(--font);
  background: var(--bg-deep);
  color: var(--text);
  height: 100%;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ─── ANIMATED BACKGROUND ─────────────────────────────────── */
.bg-gradient {
  position: fixed;
  inset: 0;
  z-index: 0;
  background:
    radial-gradient(ellipse 80% 60% at 10% 0%, rgba(6,127,249,0.12) 0%, transparent 70%),
    radial-gradient(ellipse 60% 50% at 90% 100%, rgba(124,58,237,0.1) 0%, transparent 70%),
    var(--bg-deep);
  pointer-events: none;
}

/* ─── VIEWS ────────────────────────────────────────────────── */
#view-login, #view-app {
  position: relative;
  z-index: 1;
  height: 100vh;
  width: 100vw;
}
.hidden { display: none !important; }

/* ═══════════════════════════════════════════════════════════
   LOGIN VIEW
═══════════════════════════════════════════════════════════ */
#view-login {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 24px;
}

.login-card {
  width: 100%;
  max-width: 420px;
  padding: 40px 36px;
  background: var(--bg-card);
  backdrop-filter: var(--glass-blur);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-card), inset 0 1px 0 rgba(255,255,255,0.05);
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.login-brand {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.login-brand .wordmark {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: var(--text);
}
.login-brand .neural {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  background: linear-gradient(90deg, var(--accent), var(--accent-light));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.login-brand .tagline {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 2px;
}

.login-divider {
  height: 1px;
  background: var(--border);
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.input-group {
  position: relative;
  display: flex;
  align-items: center;
}
.input-group .input-icon {
  position: absolute;
  left: 14px;
  color: var(--text-muted);
  font-size: 16px;
  pointer-events: none;
}
.input-group input {
  width: 100%;
  padding: 13px 44px 13px 42px;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.input-group input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.input-group input::placeholder { color: var(--text-muted); }
.toggle-password {
  position: absolute;
  right: 14px;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 16px;
  transition: color var(--transition);
}
.toggle-password:hover { color: var(--text); }

.btn-primary {
  width: 100%;
  padding: 14px;
  background: linear-gradient(135deg, var(--accent), #0562c4);
  border: none;
  border-radius: var(--radius-md);
  color: #fff;
  font-family: var(--font);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity var(--transition), box-shadow var(--transition), transform var(--transition);
  box-shadow: 0 4px 16px rgba(6,127,249,0.3);
  position: relative;
  overflow: hidden;
}
.btn-primary:hover {
  opacity: 0.92;
  box-shadow: 0 6px 22px rgba(6,127,249,0.45);
  transform: translateY(-1px);
}
.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn-primary .spinner {
  display: inline-block;
  width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: middle;
  margin-right: 8px;
}

.login-footer {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.login-footer .lock-note {
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 5px;
}

.error-msg {
  font-size: 13px;
  color: var(--error);
  text-align: center;
  min-height: 18px;
}

.site-footer {
  font-size: 12px;
  color: var(--text-dim);
  letter-spacing: 0.03em;
}

/* ═══════════════════════════════════════════════════════════
   APP VIEW — Layout principal
═══════════════════════════════════════════════════════════ */
#view-app {
  display: flex;
  gap: 0;
}

/* ─── SIDEBAR ────────────────────────────────────────────── */
.sidebar {
  width: 280px;
  flex-shrink: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: rgba(255,255,255,0.025);
  border-right: 1px solid var(--border);
  padding: 0;
  overflow: hidden;
}

.sidebar-header {
  padding: 22px 20px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}
.sidebar-brand .wordmark-sm {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 0.08em;
}
.sidebar-brand .neural-sm {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  background: linear-gradient(90deg, var(--accent), var(--accent-light));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  display: block;
  margin-top: 1px;
}

.sidebar-section {
  padding: 16px 20px 8px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.client-list {
  flex: 1;
  overflow-y: auto;
  padding: 4px 10px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.client-list::-webkit-scrollbar { width: 4px; }
.client-list::-webkit-scrollbar-track { background: transparent; }
.client-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.client-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background var(--transition), border-left var(--transition);
  border-left: 3px solid transparent;
  margin: 2px 0;
  gap: 10px;
}
.client-item:hover { background: var(--bg-hover); }
.client-item.active {
  background: linear-gradient(90deg, rgba(6,127,249,0.12), transparent);
  border-left-color: var(--accent);
  box-shadow: inset 0 0 20px rgba(6,127,249,0.05);
}

.client-info { flex: 1; min-width: 0; }
.client-name {
  font-size: 13.5px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text);
}
.client-item.active .client-name { color: var(--accent-light); }
.client-meta {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

.badge {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 7px;
  background: var(--bg-hover);
  border-radius: 99px;
  color: var(--text-muted);
  border: 1px solid var(--border);
  white-space: nowrap;
}
.client-item.active .badge {
  background: rgba(6,127,249,0.15);
  color: var(--accent-light);
  border-color: rgba(6,127,249,0.3);
}

.client-skeleton {
  height: 52px;
  background: var(--bg-hover);
  border-radius: var(--radius-md);
  margin: 4px 0;
  animation: shimmer 1.4s infinite;
}

/* Reports section */
.reports-section {
  padding: 12px 10px;
  border-top: 1px solid var(--border);
}
.sidebar-section-sm {
  padding: 8px 10px 6px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.report-chips {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.report-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-muted);
  background: none;
  border: none;
  width: 100%;
  text-align: left;
  transition: background var(--transition), color var(--transition);
}
.report-chip:hover { background: var(--bg-hover); color: var(--text); }
.report-chip:disabled { opacity: 0.4; cursor: not-allowed; }
.report-chip .chip-icon { font-size: 14px; }

.sidebar-user {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}
.user-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--purple));
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; color: #fff;
  flex-shrink: 0;
}
.user-info { flex: 1; min-width: 0; }
.user-name { font-size: 12.5px; font-weight: 600; color: var(--text); }
.user-role { font-size: 11px; color: var(--text-muted); }
.btn-logout {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 14px;
  padding: 6px;
  border-radius: var(--radius-sm);
  transition: background var(--transition), color var(--transition);
}
.btn-logout:hover { background: var(--bg-hover); color: var(--error); }

/* ─── MAIN CONTENT ────────────────────────────────────────── */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  min-width: 0;
}

.chat-header {
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 14px;
  background: rgba(255,255,255,0.02);
  backdrop-filter: blur(8px);
}
.chat-client-name {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}
.chat-client-meta { font-size: 13px; color: var(--text-muted); }
.status-pill {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 600;
  background: rgba(63,185,80,0.1);
  border: 1px solid rgba(63,185,80,0.25);
  color: var(--success);
  margin-left: auto;
}
.status-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--success);
  animation: pulse 2s infinite;
}

/* ─── CHAT AREA ────────────────────────────────────────────── */
.chat-area {
  flex: 1;
  overflow-y: auto;
  padding: 28px 32px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.chat-area::-webkit-scrollbar { width: 4px; }
.chat-area::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* Empty state */
.empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--text-muted);
  text-align: center;
  padding: 40px;
}
.empty-state .empty-icon { font-size: 48px; opacity: 0.5; }
.empty-state h3 { font-size: 18px; font-weight: 600; color: var(--text); }
.empty-state p { font-size: 14px; max-width: 340px; line-height: 1.6; }

/* No client selected */
.no-client-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  color: var(--text-muted);
  text-align: center;
}
.no-client-state .big-icon { font-size: 64px; opacity: 0.3; }

/* Chat messages */
.msg {
  display: flex;
  gap: 12px;
  max-width: 780px;
  animation: fadeInUp 0.25s ease;
}
.msg.user { flex-direction: row-reverse; margin-left: auto; }
.msg.ai { margin-right: auto; }

.msg-avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
}
.msg.ai .msg-avatar {
  background: linear-gradient(135deg, var(--accent), var(--purple));
}
.msg.user .msg-avatar {
  background: rgba(255,255,255,0.1);
  border: 1px solid var(--border);
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
}

.msg-content { display: flex; flex-direction: column; gap: 6px; min-width: 0; }

.msg-bubble {
  padding: 14px 18px;
  border-radius: var(--radius-lg);
  font-size: 14.5px;
  line-height: 1.65;
}
.msg.ai .msg-bubble {
  background: var(--bg-card);
  backdrop-filter: var(--glass-blur);
  border: 1px solid var(--border);
  border-radius: 4px var(--radius-lg) var(--radius-lg) var(--radius-lg);
  color: var(--text);
}
.msg.user .msg-bubble {
  background: linear-gradient(135deg, var(--accent), #0562c4);
  border-radius: var(--radius-lg) var(--radius-lg) 4px var(--radius-lg);
  color: #fff;
}

/* Report bubble */
.msg-bubble.report {
  background: rgba(6,127,249,0.06);
  border-color: rgba(6,127,249,0.2);
}
.msg-bubble.report h2 { font-size: 15px; font-weight: 700; color: var(--accent-light); margin-bottom: 12px; }
.msg-bubble.report h3 { font-size: 13.5px; font-weight: 600; margin: 12px 0 6px; color: var(--text); }
.msg-bubble.report p, .msg-bubble.report li { font-size: 13.5px; line-height: 1.7; }
.msg-bubble.report ul, .msg-bubble.report ol { padding-left: 18px; }
.msg-bubble.report strong { color: var(--accent-light); font-weight: 600; }

/* Sources */
.msg-sources {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}
.source-chip {
  font-size: 11px;
  padding: 3px 9px;
  border-radius: 99px;
  background: rgba(6,127,249,0.08);
  border: 1px solid rgba(6,127,249,0.2);
  color: var(--accent-light);
  cursor: help;
  transition: background var(--transition), transform var(--transition);
  position: relative;
}
.source-chip:hover {
  background: rgba(6,127,249,0.18);
  transform: translateY(-1px);
}

/* Inline citation references [1, 2, 3] */
.citation-group {
  font-size: 0.85em;
  color: var(--accent-light);
  font-weight: 600;
}
.citation-ref {
  cursor: help;
  color: var(--accent-light);
  font-weight: 700;
  text-decoration: underline dotted rgba(6,127,249,0.4);
  text-underline-offset: 2px;
  transition: color var(--transition), background var(--transition);
  border-radius: 3px;
  padding: 0 1px;
}
.citation-ref:hover {
  background: rgba(6,127,249,0.15);
  color: #fff;
}

/* Typing indicator */
.typing-indicator {
  display: flex;
  gap: 5px;
  padding: 14px 18px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 4px var(--radius-lg) var(--radius-lg) var(--radius-lg);
  width: fit-content;
}
.typing-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: typing 1.2s infinite;
}
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

/* ─── CHAT INPUT ───────────────────────────────────────────── */
.chat-input-area {
  padding: 16px 24px 20px;
  border-top: 1px solid var(--border);
  background: rgba(255,255,255,0.02);
}
.input-wrapper {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 12px 14px;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.input-wrapper:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.chat-input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  font-family: var(--font);
  font-size: 14.5px;
  color: var(--text);
  resize: none;
  max-height: 120px;
  line-height: 1.5;
  min-height: 22px;
}
.chat-input::placeholder { color: var(--text-muted); }
.btn-send {
  width: 36px; height: 36px;
  border-radius: var(--radius-sm);
  background: var(--accent);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 16px;
  transition: opacity var(--transition), transform var(--transition);
  flex-shrink: 0;
}
.btn-send:hover { opacity: 0.85; transform: scale(1.05); }
.btn-send:disabled { opacity: 0.35; cursor: not-allowed; transform: none; }

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

/* ─── MARKDOWN RENDERING ──────────────────────────────────── */
.msg-bubble strong { font-weight: 600; }
.msg-bubble em { font-style: italic; }
.msg-bubble code {
  font-family: 'Fira Code', monospace;
  font-size: 13px;
  background: rgba(255,255,255,0.07);
  padding: 2px 5px;
  border-radius: 4px;
}
.msg-bubble ul, .msg-bubble ol {
  padding-left: 20px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.msg-bubble ol { list-style-type: decimal; }
.msg-bubble p + p { margin-top: 8px; }
.msg-bubble h2 { font-size: 16px; font-weight: 700; color: var(--accent-light); margin: 16px 0 8px; }
.msg-bubble h3 { font-size: 14.5px; font-weight: 600; color: var(--text); margin: 14px 0 6px; }
.msg-bubble h4 { font-size: 13.5px; font-weight: 600; color: var(--text-muted); margin: 12px 0 4px; text-transform: uppercase; letter-spacing: 0.03em; }
.msg-bubble h2:first-child,
.msg-bubble h3:first-child,
.msg-bubble h4:first-child { margin-top: 0; }
.msg-bubble hr {
  border: none;
  height: 1px;
  background: var(--border);
  margin: 14px 0;
}

/* ─── ANIMATIONS ──────────────────────────────────────────── */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
@keyframes shimmer {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}
@keyframes typing {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30% { transform: translateY(-6px); opacity: 1; }
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* ─── SCROLLBAR ─────────────────────────────────────────────── */
* { scrollbar-width: thin; scrollbar-color: var(--border) transparent; }

/* ─── RESPONSIVE ────────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar { width: 220px; }
  .chat-area { padding: 20px 16px; }
  .chat-input-area { padding: 12px 16px 16px; }
}
