/* ==========================================================================
   Superinvestor 13F Radar & AI Reasoning Stylesheet
   Modern Financial Terminal + Paper & Ink High Aesthetic Theme
   ========================================================================== */

:root {
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: "SF Mono", Monaco, Menlo, Consolas, "Liberation Mono", monospace;

  /* Dark Theme (Default) */
  --bg-page: #0c0e12;
  --bg-surface: #141820;
  --bg-card: #181d27;
  --bg-card-hover: #1f2533;
  --bg-accent-subtle: rgba(255, 255, 255, 0.04);
  
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-medium: rgba(255, 255, 255, 0.14);
  --border-focus: #3b82f6;

  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  --green-text: #10b981;
  --green-bg: rgba(16, 185, 129, 0.12);
  --green-border: rgba(16, 185, 129, 0.25);

  --red-text: #f43f5e;
  --red-bg: rgba(244, 63, 94, 0.12);
  --red-border: rgba(244, 63, 94, 0.25);

  --blue-primary: #3b82f6;
  --blue-hover: #2563eb;
  --blue-bg: rgba(59, 130, 246, 0.12);

  --amber-primary: #f59e0b;
  --amber-bg: rgba(245, 158, 11, 0.12);

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

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 12px 30px rgba(0, 0, 0, 0.5);
}

[data-theme="light"] {
  --bg-page: #f8fafc;
  --bg-surface: #ffffff;
  --bg-card: #ffffff;
  --bg-card-hover: #f1f5f9;
  --bg-accent-subtle: rgba(0, 0, 0, 0.03);

  --border-subtle: rgba(0, 0, 0, 0.08);
  --border-medium: rgba(0, 0, 0, 0.15);

  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;

  --green-text: #059669;
  --green-bg: rgba(5, 150, 105, 0.1);
  --green-border: rgba(5, 150, 105, 0.2);

  --red-text: #e11d48;
  --red-bg: rgba(225, 29, 72, 0.1);
  --red-border: rgba(225, 29, 72, 0.2);

  --blue-primary: #2563eb;
  --blue-hover: #1d4ed8;
  --blue-bg: rgba(37, 99, 235, 0.1);

  --amber-primary: #d97706;
  --amber-bg: rgba(217, 119, 6, 0.1);

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 12px 30px rgba(0, 0, 0, 0.1);
}

/* Reset & Base */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-page);
  color: var(--text-primary);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

/* Container */
.container {
  max-width: 1360px;
  margin: 0 auto;
  padding: 0 20px;
}

/* Top Navigation Bar */
.navbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background-color: rgba(12, 14, 18, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-subtle);
  padding: 14px 0;
  transition: background-color 0.2s;
}

[data-theme="light"] .navbar {
  background-color: rgba(248, 250, 252, 0.9);
}

.nav-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: inherit;
}

.brand-icon {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, #3b82f6, #8b5cf6);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: white;
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.4);
}

.brand-title {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-badge {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  background: var(--blue-bg);
  color: var(--blue-primary);
  border: 1px solid rgba(59, 130, 246, 0.2);
  text-transform: uppercase;
}

.brand-subtitle {
  font-size: 0.78rem;
  color: var(--text-muted);
}

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

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.pulse-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.25);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.6); }
  70% { box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
  100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

.btn-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
}

.btn-icon:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
  border-color: var(--border-medium);
}

/* Hero & Stats Section */
.hero {
  padding: 36px 0 24px;
}

.hero-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 16px;
}

.hero-title {
  font-size: 1.85rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  margin-bottom: 6px;
}

.hero-desc {
  font-size: 0.92rem;
  color: var(--text-secondary);
  max-width: 680px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  transition: border-color 0.15s;
}

.stat-card:hover {
  border-color: var(--border-medium);
}

.stat-label {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 4px;
}

.stat-val {
  font-size: 1.45rem;
  font-weight: 700;
  font-family: var(--font-mono);
  letter-spacing: -0.02em;
}

.stat-sub {
  font-size: 0.78rem;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* Tabs & Filter Bar */
.control-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-subtle);
}

.nav-tabs {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-surface);
  padding: 4px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
}

.tab-btn {
  padding: 8px 16px;
  font-size: 0.85rem;
  font-weight: 600;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s;
}

.tab-btn:hover {
  color: var(--text-primary);
}

.tab-btn.active {
  background: var(--bg-card);
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
}

.search-box {
  position: relative;
  min-width: 280px;
}

.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

.search-input {
  width: 100%;
  padding: 9px 12px 9px 36px;
  font-size: 0.85rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  outline: none;
  transition: all 0.15s;
}

.search-input:focus {
  border-color: var(--blue-primary);
  box-shadow: 0 0 0 2px var(--blue-bg);
}

/* Investor Matrix Grid */
.investor-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 20px;
  margin-bottom: 48px;
}

.investor-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 22px;
  display: flex;
  flex-direction: column;
  transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
  cursor: pointer;
  position: relative;
}

.investor-card:hover {
  transform: translateY(-2px);
  border-color: var(--border-medium);
  box-shadow: var(--shadow-md);
}

.card-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 14px;
}

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

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

.manager-name {
  font-size: 1.05rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.firm-name {
  font-size: 0.78rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.quarter-tag {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--blue-primary);
  font-family: var(--font-mono);
}

.card-metrics {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  background: var(--bg-surface);
  border-radius: var(--radius-md);
  margin-bottom: 14px;
  font-size: 0.82rem;
}

.metric-item {
  display: flex;
  flex-direction: column;
}

.metric-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
}

.metric-value {
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--text-primary);
}

/* Action Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 7px;
  border-radius: var(--radius-sm);
  font-size: 0.72rem;
  font-weight: 700;
  font-family: var(--font-mono);
}

.badge-green {
  background: var(--green-bg);
  color: var(--green-text);
  border: 1px solid var(--green-border);
}

.badge-red {
  background: var(--red-bg);
  color: var(--red-text);
  border: 1px solid var(--red-border);
}

.badge-blue {
  background: var(--blue-bg);
  color: var(--blue-primary);
  border: 1px solid rgba(59, 130, 246, 0.25);
}

.badge-amber {
  background: var(--amber-bg);
  color: var(--amber-primary);
  border: 1px solid rgba(245, 158, 11, 0.25);
}

.holdings-bar-title {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
  display: flex;
  justify-content: space-between;
}

.holdings-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 16px;
}

.stock-chip {
  padding: 3px 8px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-family: var(--font-mono);
  display: flex;
  align-items: center;
  gap: 4px;
}

.stock-chip .chip-ticker {
  font-weight: 700;
  color: var(--text-primary);
}

.stock-chip .chip-weight {
  color: var(--text-muted);
}

.ai-preview-box {
  background: var(--bg-accent-subtle);
  border-left: 3px solid var(--blue-primary);
  padding: 10px 12px;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 0.8rem;
  color: var(--text-secondary);
  line-height: 1.45;
  margin-bottom: 16px;
  flex: 1;
}

.card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px solid var(--border-subtle);
  padding-top: 14px;
  font-size: 0.78rem;
}

.links-group {
  display: flex;
  gap: 6px;
}

.link-btn {
  padding: 3px 7px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.72rem;
  font-weight: 600;
  transition: all 0.15s;
}

.link-btn:hover {
  color: var(--text-primary);
  border-color: var(--border-medium);
  background: var(--bg-card-hover);
}

.btn-detail {
  padding: 6px 12px;
  background: var(--blue-primary);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: background 0.15s;
}

.btn-detail:hover {
  background: var(--blue-hover);
}

/* Activity Feed Tab */
.feed-container {
  max-width: 900px;
  margin: 0 auto 48px;
}

.feed-item {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 18px;
  transition: border-color 0.15s;
}

.feed-item:hover {
  border-color: var(--border-medium);
}

.feed-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 14px;
}

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

.feed-moves {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.feed-move-box {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 10px 14px;
}

.feed-ai-quote {
  background: var(--bg-surface);
  border-radius: var(--radius-md);
  padding: 14px 18px;
  font-size: 0.86rem;
  color: var(--text-secondary);
  line-height: 1.6;
  border-left: 3px solid #8b5cf6;
}

/* Stock Consensus Tab */
.stocks-consensus-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 18px;
  margin-bottom: 48px;
}

.stock-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 20px;
}

.stock-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.stock-ticker {
  font-size: 1.25rem;
  font-weight: 800;
  font-family: var(--font-mono);
}

.stock-holders-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 14px;
}

.holder-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.82rem;
  padding: 6px 10px;
  background: var(--bg-surface);
  border-radius: var(--radius-sm);
}

/* Modal Dialog */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s, visibility 0.2s;
}

.modal-backdrop.open {
  opacity: 1;
  visibility: visible;
}

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

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

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

.modal-close-btn {
  background: transparent;
  border: none;
  font-size: 24px;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  line-height: 1;
  transition: color 0.15s;
}

.modal-close-btn:hover {
  color: var(--text-primary);
}

.modal-nav {
  display: flex;
  gap: 12px;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 20px;
}

.modal-tab-btn {
  padding: 10px 16px;
  font-size: 0.88rem;
  font-weight: 600;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  cursor: pointer;
}

.modal-tab-btn.active {
  color: var(--blue-primary);
  border-bottom-color: var(--blue-primary);
}

/* Deep Dive Trade Breakdown Cards */
.trade-breakdown-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 18px;
  margin-bottom: 16px;
}

.trade-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.trade-factors-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}

.factor-box {
  background: var(--bg-card);
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
}

.factor-title {
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 5px;
}

.factor-text {
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.trade-verdict-box {
  padding: 8px 12px;
  background: var(--blue-bg);
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  color: var(--blue-primary);
  font-weight: 600;
}

/* Holdings Table */
.holdings-table-wrapper {
  overflow-x: auto;
}

.holdings-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

.holdings-table th,
.holdings-table td {
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border-subtle);
}

.holdings-table th {
  background: var(--bg-surface);
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.72rem;
  letter-spacing: 0.04em;
}

.holdings-table td {
  font-family: var(--font-mono);
}

.holdings-table tr:hover td {
  background: var(--bg-surface);
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .investor-grid {
    grid-template-columns: 1fr;
  }
  .hero-header {
    flex-direction: column;
    align-items: flex-start;
  }
  .control-bar {
    flex-direction: column;
    align-items: stretch;
  }
  .search-box {
    width: 100%;
  }
}
