/* Dr. Eco Bravo — Chat Design System */
:root {
  --bg-primary: #0a0e17;
  --bg-secondary: #111827;
  --bg-card: rgba(17, 24, 39, 0.7);
  --bg-input: rgba(17, 24, 39, 0.9);
  --border-subtle: rgba(99, 122, 175, 0.15);
  --border-active: rgba(52, 211, 153, 0.3);
  --text-primary: #e2e8f0;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --accent-emerald: #34d399;
  --accent-emerald-dim: rgba(52, 211, 153, 0.12);
  --accent-blue: #38bdf8;
  --accent-cyan: #22d3ee;
  --accent-violet: #a78bfa;
  --accent-rose: #fb7185;
  --accent-amber: #fbbf24;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-base: 250ms cubic-bezier(0.4, 0, 0.2, 1);
  --sidebar-width: 280px;
}

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { font-size: 16px; -webkit-font-smoothing: antialiased; }
body {
  font-family: var(--font-sans);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  height: 100vh;
  overflow: hidden;
}

/* Background */
.bg-grid {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background-image: linear-gradient(rgba(99,122,175,0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(99,122,175,0.03) 1px, transparent 1px);
  background-size: 60px 60px;
}
.glow {
  position: fixed; border-radius: 50%; filter: blur(120px);
  pointer-events: none; z-index: 0; animation: floatGlow 12s ease-in-out infinite;
}
.glow-1 { width: 500px; height: 500px; background: radial-gradient(circle, rgba(52,211,153,0.07), transparent 70%); top: -10%; right: -5%; }
.glow-2 { width: 400px; height: 400px; background: radial-gradient(circle, rgba(139,92,246,0.05), transparent 70%); bottom: 10%; left: -8%; animation-delay: -4s; }
@keyframes floatGlow {
  0%,100% { transform: translate(0,0) scale(1); }
  33% { transform: translate(30px,-20px) scale(1.05); }
  66% { transform: translate(-20px,15px) scale(0.95); }
}

/* Layout */
.chat-app {
  position: relative; z-index: 1; display: flex; height: 100vh; overflow: hidden;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-width); min-width: var(--sidebar-width);
  background: rgba(10, 14, 23, 0.95); border-right: 1px solid var(--border-subtle);
  display: flex; flex-direction: column; padding: 16px 12px;
  backdrop-filter: blur(20px); transition: transform 0.3s ease;
}
.sidebar-header { margin-bottom: 16px; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand-icon {
  width: 40px; height: 40px; border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--accent-emerald), #059669);
  display: flex; align-items: center; justify-content: center;
  color: var(--bg-primary); box-shadow: 0 0 20px rgba(52,211,153,0.2);
}
.brand h1 { font-size: 1rem; font-weight: 700; letter-spacing: -0.02em; }
.brand-sub { font-size: 0.7rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }

.btn-new-chat {
  width: 100%; padding: 10px 16px; border-radius: var(--radius-md);
  border: 1px dashed rgba(52,211,153,0.3); background: var(--accent-emerald-dim);
  color: var(--accent-emerald); font-family: var(--font-sans); font-size: 0.85rem;
  font-weight: 600; cursor: pointer; display: flex; align-items: center;
  justify-content: center; gap: 8px; transition: all var(--transition-fast);
  margin-top: 8px;
}
.btn-new-chat:hover { background: rgba(52,211,153,0.2); border-color: var(--accent-emerald); }

.sidebar-divider { height: 1px; background: var(--border-subtle); margin: 12px 0 8px; }
.sidebar-label { font-size: 0.7rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.08em; padding: 0 8px; margin-bottom: 8px; }

.sidebar-history { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
.sidebar-history::-webkit-scrollbar { width: 4px; }
.sidebar-history::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); border-radius: 2px; }

.history-empty {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 32px 16px; color: var(--text-muted); font-size: 0.8rem; text-align: center;
}

.history-item {
  display: flex; align-items: center; gap: 8px; padding: 10px 12px;
  border-radius: var(--radius-sm); cursor: pointer; font-size: 0.82rem;
  color: var(--text-secondary); transition: all var(--transition-fast);
  position: relative; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.history-item:hover { background: rgba(255,255,255,0.05); color: var(--text-primary); }
.history-item.active { background: rgba(52,211,153,0.1); color: var(--accent-emerald); }
.history-item .history-delete {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  background: none; border: none; color: var(--accent-rose); cursor: pointer;
  opacity: 0; transition: opacity var(--transition-fast); padding: 4px;
}
.history-item:hover .history-delete { opacity: 1; }

.sidebar-footer { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--border-subtle); }
.btn-clear-all {
  width: 100%; padding: 8px 12px; border-radius: var(--radius-sm);
  border: none; background: transparent; color: var(--text-muted);
  font-family: var(--font-sans); font-size: 0.78rem; cursor: pointer;
  display: flex; align-items: center; gap: 8px; transition: all var(--transition-fast);
}
.btn-clear-all:hover { background: rgba(251,113,133,0.1); color: var(--accent-rose); }

.sidebar-overlay {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.6);
  z-index: 9; backdrop-filter: blur(4px);
}

/* Main Chat */
.chat-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.chat-header {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 20px; border-bottom: 1px solid var(--border-subtle);
  background: rgba(10,14,23,0.8); backdrop-filter: blur(16px);
  min-height: 56px;
}
.btn-menu {
  display: none; background: none; border: none; color: var(--text-secondary);
  cursor: pointer; padding: 6px; border-radius: var(--radius-sm);
}
.btn-menu:hover { background: rgba(255,255,255,0.05); }
.header-center { flex: 1; }
.header-center h2 { font-size: 1rem; font-weight: 600; }
.header-status { display: flex; align-items: center; gap: 6px; font-size: 0.72rem; color: var(--text-muted); }
.status-dot-sm {
  width: 6px; height: 6px; border-radius: 50%; background: var(--accent-emerald);
  animation: pulse 2s ease-in-out infinite;
}
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.4; } }

/* Messages Area */
.messages-area {
  flex: 1; overflow-y: auto; padding: 24px 0;
  scroll-behavior: smooth;
}
.messages-area::-webkit-scrollbar { width: 6px; }
.messages-area::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); border-radius: 3px; }

/* Welcome Screen */
.welcome-screen { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 60px 24px; min-height: 60vh; text-align: center; animation: fadeInUp 0.6s ease-out; }
.welcome-screen.hidden { display: none; }
.welcome-icon-wrapper { margin-bottom: 20px; }
.welcome-icon {
  width: 80px; height: 80px; border-radius: 50%;
  background: var(--accent-emerald-dim); border: 2px solid rgba(52,211,153,0.25);
  display: flex; align-items: center; justify-content: center;
  color: var(--accent-emerald); animation: scaleIn 0.5s ease-out 0.2s both;
}
.welcome-title { font-size: 1.6rem; font-weight: 700; margin-bottom: 8px; background: linear-gradient(135deg, var(--text-primary), var(--accent-emerald)); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }
.welcome-desc { color: var(--text-secondary); font-size: 0.92rem; max-width: 480px; margin-bottom: 32px; }

.suggestions { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; max-width: 520px; width: 100%; }
.suggestion-chip {
  display: flex; align-items: center; gap: 10px; padding: 14px 16px;
  border-radius: var(--radius-md); border: 1px solid var(--border-subtle);
  background: var(--bg-card); color: var(--text-secondary); font-family: var(--font-sans);
  font-size: 0.82rem; cursor: pointer; text-align: left; transition: all var(--transition-fast);
}
.suggestion-chip:hover { border-color: var(--accent-emerald); color: var(--text-primary); background: rgba(52,211,153,0.05); transform: translateY(-1px); }
.suggestion-chip svg { flex-shrink: 0; color: var(--accent-emerald); }

/* Messages */
.messages-list { display: flex; flex-direction: column; gap: 4px; }

.message-group { padding: 20px 24px; max-width: 800px; margin: 0 auto; width: 100%; animation: fadeInUp 0.3s ease-out; }
.message-group.user-group { }
.message-group.assistant-group { background: rgba(255,255,255,0.015); border-top: 1px solid rgba(255,255,255,0.03); border-bottom: 1px solid rgba(255,255,255,0.03); }

.message-row { display: flex; gap: 16px; align-items: flex-start; }
.message-avatar {
  width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.8rem; font-weight: 700; margin-top: 2px;
}
.message-avatar.user-avatar { background: linear-gradient(135deg, var(--accent-blue), var(--accent-violet)); color: #fff; }
.message-avatar.assistant-avatar { background: linear-gradient(135deg, var(--accent-emerald), #059669); color: var(--bg-primary); }

.message-content { flex: 1; min-width: 0; }
.message-sender { font-size: 0.78rem; font-weight: 600; margin-bottom: 4px; color: var(--text-secondary); }

.message-text { font-size: 0.9rem; line-height: 1.7; color: var(--text-primary); word-wrap: break-word; }
.message-text p { margin-bottom: 12px; }
.message-text p:last-child { margin-bottom: 0; }
.message-text h1,.message-text h2,.message-text h3,.message-text h4 { margin: 16px 0 8px; font-weight: 700; color: var(--text-primary); }
.message-text h1 { font-size: 1.3rem; }
.message-text h2 { font-size: 1.15rem; }
.message-text h3 { font-size: 1rem; }
.message-text ul,.message-text ol { margin: 8px 0 12px 20px; }
.message-text li { margin-bottom: 4px; }
.message-text strong { color: var(--accent-emerald); font-weight: 600; }
.message-text em { color: var(--text-secondary); }
.message-text blockquote { border-left: 3px solid var(--accent-emerald); padding: 8px 16px; margin: 12px 0; background: rgba(52,211,153,0.05); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; color: var(--text-secondary); }
.message-text code { font-family: var(--font-mono); font-size: 0.82rem; background: rgba(0,0,0,0.3); padding: 2px 6px; border-radius: 4px; color: var(--accent-cyan); }
.message-text pre { background: rgba(0,0,0,0.35); border: 1px solid rgba(255,255,255,0.06); border-radius: var(--radius-md); padding: 16px; margin: 12px 0; overflow-x: auto; }
.message-text pre code { background: none; padding: 0; color: var(--text-secondary); }
.message-text table { width: 100%; border-collapse: collapse; margin: 12px 0; font-size: 0.85rem; }
.message-text th,.message-text td { padding: 8px 12px; border: 1px solid var(--border-subtle); text-align: left; }
.message-text th { background: rgba(52,211,153,0.08); font-weight: 600; }
.message-text hr { border: none; border-top: 1px solid var(--border-subtle); margin: 16px 0; }

/* Message Actions */
.message-actions {
  display: flex; gap: 4px; margin-top: 8px; opacity: 0; transition: opacity var(--transition-fast);
}
.message-group:hover .message-actions { opacity: 1; }
.msg-action-btn {
  display: flex; align-items: center; gap: 5px; padding: 5px 10px;
  border-radius: var(--radius-sm); border: 1px solid transparent;
  background: none; color: var(--text-muted); font-family: var(--font-sans);
  font-size: 0.72rem; cursor: pointer; transition: all var(--transition-fast);
}
.msg-action-btn:hover { background: rgba(255,255,255,0.06); color: var(--text-primary); border-color: var(--border-subtle); }
.msg-action-btn.copied { color: var(--accent-emerald); border-color: rgba(52,211,153,0.3); }
.msg-action-btn.delete-btn:hover { color: var(--accent-rose); border-color: rgba(251,113,133,0.3); }

/* Typing Indicator */
.typing-indicator {
  display: none; padding: 16px 24px; max-width: 800px; margin: 0 auto; width: 100%;
}
.typing-indicator.visible { display: flex; gap: 16px; align-items: flex-start; animation: fadeInUp 0.3s ease-out; }
.typing-avatar {
  width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0;
  background: linear-gradient(135deg, var(--accent-emerald), #059669);
  display: flex; align-items: center; justify-content: center; color: var(--bg-primary);
}
.typing-bubble { padding: 12px 16px; border-radius: var(--radius-md); background: var(--bg-card); border: 1px solid var(--border-subtle); }
.typing-dots { display: flex; gap: 4px; }
.typing-dots span {
  width: 8px; height: 8px; border-radius: 50%; background: var(--text-muted);
  animation: typingBounce 1.4s infinite ease-in-out;
}
.typing-dots span:nth-child(2) { animation-delay: 0.16s; }
.typing-dots span:nth-child(3) { animation-delay: 0.32s; }
@keyframes typingBounce {
  0%,60%,100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-6px); opacity: 1; }
}

/* Input Area */
.input-area {
  padding: 16px 24px 12px; border-top: 1px solid var(--border-subtle);
  background: rgba(10,14,23,0.8); backdrop-filter: blur(16px);
}
.input-form { max-width: 800px; margin: 0 auto; }
.input-wrapper {
  display: flex; align-items: flex-end; gap: 8px; padding: 8px 8px 8px 16px;
  border-radius: var(--radius-lg); border: 1px solid var(--border-subtle);
  background: var(--bg-input); transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.input-wrapper:focus-within { border-color: var(--accent-emerald); box-shadow: 0 0 0 3px rgba(52,211,153,0.1); }

#chatInput {
  flex: 1; border: none; background: none; color: var(--text-primary);
  font-family: var(--font-sans); font-size: 0.9rem; resize: none;
  outline: none; max-height: 160px; line-height: 1.5; padding: 6px 0;
}
#chatInput::placeholder { color: var(--text-muted); }

.btn-send {
  width: 36px; height: 36px; border-radius: var(--radius-sm);
  border: none; background: var(--accent-emerald); color: var(--bg-primary);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; transition: all var(--transition-fast);
}
.btn-send:disabled { opacity: 0.3; cursor: not-allowed; }
.btn-send:not(:disabled):hover { background: #2dd4a0; transform: scale(1.05); }

.disclaimer {
  text-align: center; font-size: 0.7rem; color: var(--text-muted);
  margin-top: 8px; max-width: 800px; margin-left: auto; margin-right: auto;
}

/* Error message */
.message-error { color: var(--accent-rose); font-style: italic; }

/* Animations */
@keyframes fadeInUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes scaleIn { from { opacity: 0; transform: scale(0.5); } to { opacity: 1; transform: scale(1); } }

/* Responsive */
@media (max-width: 768px) {
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; z-index: 10; transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay.visible { display: block; }
  .btn-menu { display: flex; }
  .suggestions { grid-template-columns: 1fr; }
  .message-group { padding: 16px; }
  .input-area { padding: 12px 16px 8px; }
  .welcome-screen { padding: 40px 16px; }
}
@media (max-width: 480px) {
  .welcome-title { font-size: 1.3rem; }
  .welcome-desc { font-size: 0.85rem; }
  .message-text { font-size: 0.85rem; }
}
