/* TradeCow - shadcn/ui dark theme design system */

/* ══════════════════════════════════════════════
   1. CSS Variables
   ══════════════════════════════════════════════ */

:root {
  --background: 224 71% 4%;
  --foreground: 213 31% 91%;
  --card: 222 47% 6%;
  --card-foreground: 213 31% 91%;
  --primary: 210 40% 98%;
  --primary-foreground: 224 71% 4%;
  --secondary: 217 33% 17%;
  --secondary-foreground: 210 40% 98%;
  --muted: 217 33% 17%;
  --muted-foreground: 215 20% 65%;
  --accent: 217 91% 60%;
  --accent-foreground: 210 40% 98%;
  --destructive: 0 84% 60%;
  --destructive-foreground: 210 40% 98%;
  --border: 217 33% 17%;
  --input: 217 33% 17%;
  --ring: 213 27% 84%;
  --radius: 0.5rem;
  --success: 142 71% 45%;
  --warning: 38 92% 50%;
  --long: 142 71% 45%;
  --short: 0 84% 60%;
  --live: 199 89% 48%;
}

/* ══════════════════════════════════════════════
   2. Reset & Base
   ══════════════════════════════════════════════ */

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

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  background: hsl(var(--background));
  color: hsl(var(--foreground));
  min-height: 100vh;
}

a { color: hsl(var(--accent)); text-decoration: none; }
a:hover { text-decoration: underline; }

[x-cloak] { display: none !important; }

/* ══════════════════════════════════════════════
   3. Typography
   ══════════════════════════════════════════════ */

.font-mono { font-family: 'JetBrains Mono', 'SF Mono', Consolas, monospace; }
.text-xs { font-size: 0.75rem; }
.text-sm { font-size: 0.875rem; }
.text-lg { font-size: 1.125rem; }
.text-xl { font-size: 1.25rem; }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }

/* ══════════════════════════════════════════════
   4. Card
   ══════════════════════════════════════════════ */

.card {
  background: hsl(var(--card));
  color: hsl(var(--card-foreground));
  border: 1px solid hsl(var(--border));
  border-radius: calc(var(--radius) + 2px);
  padding: 1rem;
  box-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
}
.card-title { font-size: 0.875rem; font-weight: 600; margin-bottom: 0.75rem; }
.card-sm { padding: 0.75rem; }

/* ══════════════════════════════════════════════
   5. Buttons
   ══════════════════════════════════════════════ */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  border-radius: var(--radius); font-weight: 500; font-size: 0.875rem;
  height: 2.5rem; padding: 0.5rem 1rem; border: 1px solid transparent;
  cursor: pointer; transition: all 150ms; font-family: inherit;
  white-space: nowrap; user-select: none;
}
.btn:active:not(:disabled) { transform: scale(0.98); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-default { background: hsl(var(--primary)); color: hsl(var(--primary-foreground)); }
.btn-default:hover:not(:disabled) { opacity: 0.9; }

.btn-outline { background: transparent; border-color: hsl(var(--border)); color: hsl(var(--foreground)); }
.btn-outline:hover:not(:disabled) { background: hsl(var(--muted)); }

.btn-ghost { background: transparent; color: hsl(var(--foreground)); }
.btn-ghost:hover:not(:disabled) { background: hsl(var(--muted)); }

.btn-destructive { background: hsl(var(--destructive)); color: hsl(var(--destructive-foreground)); }
.btn-success { background: hsl(var(--success)); color: hsl(var(--primary-foreground)); }
.btn-accent { background: hsl(var(--accent)); color: hsl(var(--accent-foreground)); }

.btn-sm { height: 2rem; padding: 0.25rem 0.75rem; font-size: 0.8125rem; }
.btn-lg { height: 2.75rem; padding: 0.625rem 1.25rem; font-size: 0.9375rem; }
.btn-icon { width: 2.5rem; padding: 0; }
.btn-icon.btn-sm { width: 2rem; }
.btn-block { width: 100%; }

/* ══════════════════════════════════════════════
   6. Badge
   ══════════════════════════════════════════════ */

.badge {
  display: inline-flex; align-items: center; gap: 0.25rem;
  padding: 0.125rem 0.5rem; border-radius: calc(var(--radius) - 2px);
  font-size: 0.75rem; font-weight: 500; border: 1px solid transparent;
  white-space: nowrap; line-height: 1.5;
}
.badge-default { background: hsl(var(--primary)); color: hsl(var(--primary-foreground)); }
.badge-secondary { background: hsl(var(--secondary)); color: hsl(var(--secondary-foreground)); }
.badge-outline { background: transparent; border-color: hsl(var(--border)); color: hsl(var(--foreground)); }
.badge-success { background: hsl(var(--success) / 0.15); color: hsl(var(--success)); border-color: hsl(var(--success) / 0.3); }
.badge-destructive { background: hsl(var(--destructive) / 0.15); color: hsl(var(--destructive)); border-color: hsl(var(--destructive) / 0.3); }
.badge-warning { background: hsl(var(--warning) / 0.15); color: hsl(var(--warning)); border-color: hsl(var(--warning) / 0.3); }
.badge-live { background: hsl(var(--live) / 0.15); color: hsl(var(--live)); border-color: hsl(var(--live) / 0.3); }

/* ══════════════════════════════════════════════
   7. Input / Textarea
   ══════════════════════════════════════════════ */

.input, .textarea {
  width: 100%; background: hsl(var(--background));
  border: 1px solid hsl(var(--input)); border-radius: calc(var(--radius) - 2px);
  padding: 0.5rem 0.75rem; font-size: 0.875rem; font-family: inherit;
  color: hsl(var(--foreground)); transition: border-color 150ms, box-shadow 150ms;
  outline: none;
}
.input::placeholder, .textarea::placeholder { color: hsl(var(--muted-foreground)); }
.input:focus, .textarea:focus { border-color: hsl(var(--ring)); box-shadow: 0 0 0 3px hsl(var(--ring) / 0.1); }
.textarea { resize: vertical; min-height: 2.5rem; }
.label { font-size: 0.875rem; font-weight: 500; margin-bottom: 0.375rem; display: block; }
.input-group { margin-bottom: 1rem; }

/* ══════════════════════════════════════════════
   8. Table
   ══════════════════════════════════════════════ */

.table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
.table thead { border-bottom: 1px solid hsl(var(--border)); }
.table th {
  text-align: left; padding: 0.625rem 0.75rem; font-weight: 500; font-size: 0.75rem;
  color: hsl(var(--muted-foreground)); text-transform: uppercase; letter-spacing: 0.05em;
}
.table td { padding: 0.625rem 0.75rem; color: hsl(var(--foreground)); }
.table tbody tr { border-bottom: 1px solid hsl(var(--border)); transition: background 150ms; }
.table tbody tr:hover { background: hsl(var(--muted) / 0.5); }
.table tbody tr:last-child { border-bottom: none; }

/* ══════════════════════════════════════════════
   9. Tabs
   ══════════════════════════════════════════════ */

.tab-list {
  display: flex; gap: 0; border-bottom: 1px solid hsl(var(--border));
  margin-bottom: 0.75rem; flex-shrink: 0;
}
.tab-trigger {
  background: none; border: none; border-bottom: 2px solid transparent;
  color: hsl(var(--muted-foreground)); font-family: inherit;
  font-size: 0.875rem; font-weight: 500; padding: 0.5rem 1rem;
  cursor: pointer; transition: color 150ms, border-color 150ms;
  white-space: nowrap;
}
.tab-trigger:hover { color: hsl(var(--foreground)); }
.tab-trigger.active { color: hsl(var(--foreground)); border-bottom-color: hsl(var(--foreground)); }

/* ══════════════════════════════════════════════
   10. Separator
   ══════════════════════════════════════════════ */

.separator { height: 1px; background: hsl(var(--border)); width: 100%; }
.separator-v { width: 1px; background: hsl(var(--border)); align-self: stretch; }

/* ══════════════════════════════════════════════
   11. Layout
   ══════════════════════════════════════════════ */

.header {
  position: sticky; top: 0; z-index: 100;
  display: flex; align-items: center; height: 3.5rem;
  padding: 0 1rem; background: hsl(var(--background));
  border-bottom: 1px solid hsl(var(--border)); gap: 1rem;
}
.header-logo { font-size: 1rem; font-weight: 600; color: hsl(var(--foreground)); letter-spacing: -0.01em; flex-shrink: 0; }

.main-layout { display: flex; height: calc(100vh - 3.5rem); }
.panel-left { flex: 1; overflow-y: auto; padding: 1rem; min-width: 0; }
.panel-right { width: 400px; flex-shrink: 0; border-left: 1px solid hsl(var(--border)); display: flex; flex-direction: column; }

/* ══════════════════════════════════════════════
   12. KPI Strip
   ══════════════════════════════════════════════ */

.kpi-strip { display: flex; align-items: center; gap: 1.5rem; flex-wrap: wrap; padding: 0.5rem 0; }
.kpi-item { display: flex; flex-direction: column; align-items: center; min-width: 60px; }
.kpi-value { font-family: 'JetBrains Mono', monospace; font-size: 1rem; font-weight: 600; line-height: 1.2; }
.kpi-label { font-size: 0.6875rem; color: hsl(var(--muted-foreground)); text-transform: uppercase; letter-spacing: 0.05em; margin-top: 0.125rem; }

/* ══════════════════════════════════════════════
   13. Trading Components
   ══════════════════════════════════════════════ */

/* Panel title */
.panel-title { font-size: 0.8125rem; font-weight: 600; color: hsl(var(--foreground)); margin-bottom: 0.5rem; }

/* Tactic groups */
.tactic-group { border: 1px solid hsl(var(--border)); border-radius: var(--radius); overflow: hidden; margin-bottom: 0.75rem; }
.tactic-header { background: hsl(var(--secondary)); padding: 0.375rem 0.75rem; display: flex; align-items: center; gap: 0.5rem; border-bottom: 1px solid hsl(var(--border)); }
.tactic-name { font-size: 0.75rem; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; }
.tactic-count { font-family: 'JetBrains Mono', monospace; font-size: 0.75rem; color: hsl(var(--muted-foreground)); }

/* Direction rows */
.direction-row { display: flex; align-items: center; gap: 0.5rem; padding: 0.375rem 0.75rem; border-bottom: 1px solid hsl(var(--border)); min-height: 2rem; transition: background 150ms; }
.direction-row:last-child { border-bottom: none; }
.direction-row:hover { background: hsl(var(--muted) / 0.3); }
.direction-row.accepted { background: hsl(var(--success) / 0.05); }
.direction-row.executed { background: hsl(var(--live) / 0.05); }
.direction-row.rejected { background: hsl(var(--destructive) / 0.05); opacity: 0.5; }
.direction-sym { font-family: 'JetBrains Mono', monospace; font-size: 0.8125rem; font-weight: 600; min-width: 3rem; color: hsl(var(--foreground)); }
.direction-badge { font-size: 0.6875rem; font-weight: 600; }
.direction-rationale { font-size: 0.8125rem; color: hsl(var(--muted-foreground)); flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Position / Order rows for the table approach */
.table .font-mono { font-family: 'JetBrains Mono', monospace; }

/* ══════════════════════════════════════════════
   14. Chat Components
   ══════════════════════════════════════════════ */

.chat-panel { display: flex; flex-direction: column; height: 100%; }
.chat-messages { flex: 1; overflow-y: auto; padding: 1rem; display: flex; flex-direction: column; gap: 0.75rem; }

.msg-user { display: flex; justify-content: flex-end; }
.msg-user-bubble {
  background: hsl(var(--secondary)); padding: 0.625rem 0.875rem;
  border-radius: var(--radius) var(--radius) 0 var(--radius);
  max-width: 80%; font-size: 0.875rem; line-height: 1.5; color: hsl(var(--foreground));
}

.msg-ai { max-width: 95%; }
.msg-ai-label { font-size: 0.75rem; font-weight: 500; color: hsl(var(--muted-foreground)); margin-bottom: 0.25rem; }

/* Chat markdown */
.chat-md { color: hsl(var(--foreground)); font-size: 0.875rem; line-height: 1.6; }
.chat-md h1, .chat-md h2, .chat-md h3, .chat-md h4 { color: hsl(var(--foreground)); font-weight: 600; margin: 0.5rem 0 0.25rem; }
.chat-md h3 { font-size: 0.9375rem; }
.chat-md p { margin: 0.25rem 0; }
.chat-md ul, .chat-md ol { margin: 0.25rem 0; padding-left: 1.25rem; }
.chat-md li { margin: 0.125rem 0; }
.chat-md strong { color: hsl(var(--foreground)); font-weight: 600; }
.chat-md code { background: hsl(var(--secondary)); color: hsl(var(--accent)); padding: 0.0625rem 0.25rem; border-radius: 0.25rem; font-size: 0.8125rem; font-family: 'JetBrains Mono', monospace; }
.chat-md pre { background: hsl(var(--secondary)); border: 1px solid hsl(var(--border)); border-radius: var(--radius); padding: 0.75rem; overflow-x: auto; margin: 0.5rem 0; }
.chat-md pre code { background: transparent; padding: 0; color: hsl(var(--foreground)); }
.chat-md table { border-collapse: collapse; width: 100%; margin: 0.5rem 0; font-size: 0.8125rem; }
.chat-md th { border: 1px solid hsl(var(--border)); padding: 0.375rem 0.5rem; font-weight: 600; background: hsl(var(--secondary)); text-align: left; }
.chat-md td { border: 1px solid hsl(var(--border)); padding: 0.375rem 0.5rem; }
.chat-md blockquote { border-left: 3px solid hsl(var(--border)); padding-left: 0.75rem; color: hsl(var(--muted-foreground)); margin: 0.5rem 0; }
.chat-md a { color: hsl(var(--accent)); }

/* Chat session tabs */
.chat-tab-bar { display: flex; align-items: center; overflow-x: auto; gap: 0; scrollbar-width: none; }
.chat-tab-bar::-webkit-scrollbar { display: none; }
.chat-tab {
  display: flex; align-items: center; gap: 0.25rem; padding: 0.375rem 0.625rem;
  cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap;
  flex-shrink: 0; font-size: 0.8125rem; color: hsl(var(--muted-foreground));
  background: none; border-top: none; border-left: none; border-right: none;
  font-family: inherit; transition: color 150ms;
}
.chat-tab:hover { color: hsl(var(--foreground)); }
.chat-tab.active { border-bottom-color: hsl(var(--foreground)); color: hsl(var(--foreground)); font-weight: 500; }

/* Chat input */
.chat-input-area { display: flex; gap: 0.5rem; padding: 0.75rem; border-top: 1px solid hsl(var(--border)); align-items: flex-end; flex-shrink: 0; }
.chat-input { flex: 1; resize: none; min-height: 2.5rem; max-height: 7.5rem; }
.chat-send-btn {
  background: hsl(var(--primary)); color: hsl(var(--primary-foreground));
  border: none; border-radius: var(--radius); width: 2.5rem; height: 2.5rem;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; flex-shrink: 0; font-size: 1rem; transition: opacity 150ms;
}
.chat-send-btn:hover { opacity: 0.9; }

/* Chat welcome */
.chat-welcome { text-align: center; padding: 3rem 1.5rem; }
.chat-welcome-title { font-size: 1.125rem; font-weight: 600; color: hsl(var(--foreground)); }
.chat-welcome-sub { font-size: 0.875rem; color: hsl(var(--muted-foreground)); margin-top: 0.5rem; }

/* ══════════════════════════════════════════════
   15. Auth Pages
   ══════════════════════════════════════════════ */

.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1.5rem; }
.auth-card { background: hsl(var(--card)); border: 1px solid hsl(var(--border)); border-radius: calc(var(--radius) + 2px); padding: 2.5rem; width: 400px; max-width: 90vw; box-shadow: 0 1px 3px rgb(0 0 0 / 0.1); }
.auth-title { font-size: 1.5rem; font-weight: 700; text-align: center; margin-bottom: 0.25rem; color: hsl(var(--foreground)); }
.auth-subtitle { color: hsl(var(--muted-foreground)); font-size: 0.875rem; text-align: center; margin-bottom: 2rem; }
.auth-error { color: hsl(var(--destructive)); font-size: 0.875rem; min-height: 1.25rem; margin-bottom: 0.5rem; text-align: center; }
.auth-success { color: hsl(var(--success)); font-size: 0.875rem; text-align: center; }
.auth-links { display: flex; justify-content: space-between; margin-top: 1rem; font-size: 0.875rem; }

/* ══════════════════════════════════════════════
   16. Landing Page
   ══════════════════════════════════════════════ */

.landing-hero { text-align: center; padding: 5rem 1.5rem 3.75rem; }
.landing-tagline { color: hsl(var(--muted-foreground)); font-size: 1.125rem; margin-bottom: 2rem; }
.landing-ctas { display: flex; gap: 0.75rem; justify-content: center; }
.feature-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 1rem; padding: 0 1.5rem 3.75rem; max-width: 960px; margin: 0 auto; }

/* ══════════════════════════════════════════════
   17. No-broker Banner
   ══════════════════════════════════════════════ */

.no-broker-banner {
  background: hsl(var(--warning) / 0.08); border: 1px solid hsl(var(--warning) / 0.2);
  border-radius: var(--radius); padding: 0.75rem 1.25rem; margin: 0.5rem 0 0;
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 0.5rem;
}

/* ══════════════════════════════════════════════
   18. Utility Classes
   ══════════════════════════════════════════════ */

.text-success { color: hsl(var(--success)); }
.text-destructive { color: hsl(var(--destructive)); }
.text-warning { color: hsl(var(--warning)); }
.text-live { color: hsl(var(--live)); }
.text-muted { color: hsl(var(--muted-foreground)); }
.text-accent { color: hsl(var(--accent)); }
.text-center { text-align: center; }
.text-right { text-align: right; }
.mt-1 { margin-top: 0.25rem; } .mt-2 { margin-top: 0.5rem; } .mt-3 { margin-top: 0.75rem; } .mt-4 { margin-top: 1rem; }
.mb-1 { margin-bottom: 0.25rem; } .mb-2 { margin-bottom: 0.5rem; } .mb-3 { margin-bottom: 0.75rem; } .mb-4 { margin-bottom: 1rem; }
.gap-1 { gap: 0.25rem; } .gap-2 { gap: 0.5rem; } .gap-3 { gap: 0.75rem; } .gap-4 { gap: 1rem; }
.flex { display: flex; } .flex-col { flex-direction: column; } .flex-1 { flex: 1; min-width: 0; }
.items-center { align-items: center; } .justify-between { justify-content: space-between; } .justify-end { justify-content: flex-end; }
.w-full { width: 100%; } .hidden { display: none !important; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }

/* ══════════════════════════════════════════════
   19. Scrollbars
   ══════════════════════════════════════════════ */

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: hsl(var(--border)); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: hsl(var(--muted-foreground) / 0.3); }

/* ══════════════════════════════════════════════
   20. Mobile
   ══════════════════════════════════════════════ */

@media (max-width: 768px) {
  .header-logo { font-size: 0.875rem; }
  .header .badge { display: none; }
  .main-layout { flex-direction: column; height: auto; }
  .panel-left { min-height: 60vh; padding: 0.75rem; }
  .panel-right { width: 100%; border-left: none; border-top: 1px solid hsl(var(--border)); min-height: 400px; }
  .kpi-strip { gap: 0.75rem; }
  .desktop-only { display: none !important; }
  .mobile-only { display: flex !important; }
  .auth-card { padding: 1.5rem; }
  .landing-hero { padding: 2.5rem 1rem 2rem; }
  .feature-grid { grid-template-columns: 1fr 1fr; padding: 0 1rem 2.5rem; }
  .chat-pill { display: flex !important; }
}
@media (min-width: 769px) { .mobile-only { display: none !important; } }

/* Mobile chat pill */
.chat-pill {
  position: fixed; bottom: 1.25rem; right: 1.25rem; z-index: 9998;
  background: hsl(var(--accent)); color: hsl(var(--accent-foreground));
  border: none; border-radius: 1.75rem; padding: 0.75rem 1.5rem;
  font-weight: 600; font-size: 0.875rem; cursor: pointer;
  box-shadow: 0 4px 20px hsl(var(--accent) / 0.3);
  display: none; align-items: center; gap: 0.5rem;
}
.chat-pill:hover { opacity: 0.9; }

/* iOS safe area */
@supports (-webkit-touch-callout: none) {
  .auth-wrap { min-height: -webkit-fill-available; }
  body { min-height: -webkit-fill-available; }
}
