/* Modern Dark Theme - Investing AI */
:root {
  --bg-main: #090d16;
  --bg-card: #131b2e;
  --bg-card-sub: #1b2640;
  --border-color: rgba(255, 255, 255, 0.08);
  --border-glow: rgba(99, 102, 241, 0.25);
  --text-main: #f8fafc;
  --text-sub: #94a3b8;
  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --primary-glow: rgba(99, 102, 241, 0.35);
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --purple: #a855f7;
  --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

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

body {
  font-family: var(--font-family);
  background-color: var(--bg-main);
  color: var(--text-main);
  line-height: 1.5;
  height: 100vh;
  overflow: hidden;
}

/* Login Page Styling */
.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 50% 20%, #1e1b4b 0%, #090d16 70%);
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: rgba(19, 27, 46, 0.85);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border-glow);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6), 0 0 50px rgba(99, 102, 241, 0.15);
  border-radius: 16px;
  padding: 36px;
}

.login-header {
  text-align: center;
  margin-bottom: 24px;
}

.logo-circle {
  width: 54px;
  height: 54px;
  margin: 0 auto 16px;
  background: linear-gradient(135deg, var(--primary), var(--purple));
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 20px var(--primary-glow);
}

.login-header h2 {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.subtitle {
  color: var(--text-sub);
  font-size: 14px;
  margin-top: 4px;
}

.error-banner {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #fca5a5;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 20px;
  text-align: center;
}

.login-form .form-group {
  margin-bottom: 20px;
}

.login-form label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-sub);
  margin-bottom: 8px;
}

.login-form input {
  width: 100%;
  padding: 12px 16px;
  background: #0d1322;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  color: var(--text-main);
  font-size: 14px;
  transition: all 0.2s ease;
}

.login-form input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.btn-primary {
  width: 100%;
  padding: 12px;
  background: linear-gradient(135deg, var(--primary), #4f46e5);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.1s ease, box-shadow 0.2s ease;
}

.btn-primary:hover {
  box-shadow: 0 6px 20px var(--primary-glow);
  transform: translateY(-1px);
}

.login-footer {
  text-align: center;
  margin-top: 24px;
  font-size: 12px;
  color: #64748b;
}

/* App Layout */
.app-body {
  display: flex;
  flex-direction: column;
}

.layout-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  max-width: 1100px;
  margin: 0 auto;
  width: 100%;
  padding: 12px 20px;
}

/* Header */
.top-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0 16px;
  border-bottom: 1px solid var(--border-color);
}

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

.logo-icon {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, var(--primary), var(--purple));
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px var(--primary-glow);
}

.brand-title {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.brand-sub {
  font-size: 12px;
  color: var(--text-sub);
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.btn-secondary {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-secondary:hover {
  background: var(--bg-card-sub);
  border-color: var(--border-glow);
}

.btn-ghost {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  color: var(--text-sub);
  text-decoration: none;
  font-size: 13px;
  border-radius: 8px;
  transition: all 0.2s;
}

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

/* Main Content & Chat */
.main-content {
  display: flex;
  flex: 1;
  position: relative;
  overflow: hidden;
  margin-top: 10px;
}

.chat-section {
  display: flex;
  flex-direction: column;
  flex: 1;
  height: 100%;
  overflow: hidden;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 8px 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Custom Scrollbar */
.chat-messages::-webkit-scrollbar {
  width: 6px;
}
.chat-messages::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
}

.message {
  display: flex;
  gap: 14px;
  max-width: 900px;
  width: 100%;
}

.message.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.avatar {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
}

.message.assistant .avatar {
  background: rgba(99, 102, 241, 0.15);
  border-color: rgba(99, 102, 241, 0.3);
  color: var(--primary);
}

.message.user .avatar {
  background: rgba(168, 85, 247, 0.15);
  border-color: rgba(168, 85, 247, 0.3);
  color: var(--purple);
}

.msg-content {
  flex: 1;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  padding: 16px 20px;
  border-radius: 12px;
  font-size: 14.5px;
  line-height: 1.6;
}

.message.user .msg-content {
  background: #1e1b4b;
  border-color: rgba(99, 102, 241, 0.3);
  max-width: 75%;
}

.msg-content p {
  margin-bottom: 10px;
}
.msg-content p:last-child {
  margin-bottom: 0;
}
.msg-content ul, .msg-content ol {
  margin: 10px 0 10px 24px;
}
.msg-content li {
  margin-bottom: 4px;
}
.msg-content code {
  background: rgba(0, 0, 0, 0.3);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: monospace;
  font-size: 13px;
  color: #38bdf8;
}

/* Quick Prompts Pills */
.quick-prompts {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.pill {
  padding: 6px 12px;
  background: rgba(99, 102, 241, 0.1);
  border: 1px solid rgba(99, 102, 241, 0.25);
  color: #a5b4fc;
  border-radius: 20px;
  font-size: 12.5px;
  cursor: pointer;
  transition: all 0.2s;
}

.pill:hover {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

/* Generative UI Cards */
.card-valuation {
  background: linear-gradient(145deg, #131c31, #0f1626);
  border: 1px solid rgba(56, 189, 248, 0.3);
  border-radius: 12px;
  padding: 16px;
  margin: 12px 0;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

.card-val-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  padding-bottom: 8px;
  margin-bottom: 12px;
}

.card-val-ticker {
  font-size: 18px;
  font-weight: 700;
  color: #38bdf8;
}

.badge-verdict {
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}
.badge-buy { background: rgba(16, 185, 129, 0.2); color: #34d399; border: 1px solid #059669; }
.badge-hold { background: rgba(245, 158, 11, 0.2); color: #fbbf24; border: 1px solid #d97706; }
.badge-overvalued { background: rgba(239, 68, 68, 0.2); color: #f87171; border: 1px solid #dc2626; }

.val-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 10px;
}

.val-item {
  background: rgba(0, 0, 0, 0.2);
  padding: 8px 12px;
  border-radius: 8px;
}
.val-label {
  font-size: 11px;
  color: var(--text-sub);
}
.val-val {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-main);
}

.card-macro {
  background: linear-gradient(145deg, #1a1738, #111025);
  border: 1px solid rgba(168, 85, 247, 0.3);
  border-radius: 12px;
  padding: 16px;
  margin: 12px 0;
}
.macro-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.macro-title {
  font-size: 16px;
  font-weight: 700;
  color: #c084fc;
}

.card-note {
  border-left: 4px solid var(--primary);
  background: rgba(99, 102, 241, 0.08);
  padding: 12px 16px;
  border-radius: 0 8px 8px 0;
  margin: 12px 0;
}
.card-note.warning {
  border-left-color: var(--warning);
  background: rgba(245, 158, 11, 0.08);
}
.note-title {
  font-weight: 700;
  font-size: 13.5px;
  margin-bottom: 4px;
}

/* Chat Input Bar */
.chat-input-wrapper {
  padding: 12px 0;
  border-top: 1px solid var(--border-color);
}

.chat-form {
  display: flex;
  align-items: center;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 6px 10px 6px 16px;
  transition: all 0.2s;
}

.chat-form:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.chat-form textarea {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-main);
  font-size: 14.5px;
  resize: none;
  font-family: inherit;
  line-height: 1.4;
  max-height: 120px;
}

.btn-send {
  background: var(--primary);
  color: white;
  border: none;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}
.btn-send:hover {
  background: var(--primary-hover);
}
.btn-send:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Drawer */
.articles-drawer {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 320px;
  background: var(--bg-card);
  border-left: 1px solid var(--border-color);
  box-shadow: -10px 0 30px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  z-index: 50;
  transition: transform 0.2s ease;
}
.articles-drawer.hidden {
  display: none;
}
.drawer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
}
.btn-icon {
  background: none;
  border: none;
  color: var(--text-sub);
  font-size: 24px;
  cursor: pointer;
}
.articles-list {
  padding: 12px;
  overflow-y: auto;
  flex: 1;
}
.article-item {
  padding: 10px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13.5px;
  color: #cbd5e1;
  transition: all 0.15s;
}
.article-item:hover {
  background: rgba(99, 102, 241, 0.15);
  color: white;
}

/* Thought / Reasoning Stream */
.thought-container {
  margin-bottom: 14px;
}

.thought-box {
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid rgba(99, 102, 241, 0.25);
  border-radius: 10px;
  overflow: hidden;
  font-size: 13px;
}

.thought-summary {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  color: #94a3b8;
  cursor: pointer;
  user-select: none;
  background: rgba(99, 102, 241, 0.08);
  font-weight: 500;
  transition: all 0.2s;
}

.thought-summary:hover {
  color: #c7d2fe;
  background: rgba(99, 102, 241, 0.15);
}

.thought-spinner {
  width: 13px;
  height: 13px;
  border: 2px solid rgba(99, 102, 241, 0.3);
  border-top-color: #6366f1;
  border-radius: 50%;
  display: inline-block;
  animation: thought-spin 0.8s linear infinite;
}

@keyframes thought-spin {
  to { transform: rotate(360deg); }
}

.thought-text {
  padding: 12px 16px;
  color: #64748b;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 220px;
  overflow-y: auto;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}


