/* CapitalWave - Dark Financial Terminal Aesthetic */

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

:root {
  --bg-primary: #0a0a0f;
  --bg-card: #12121a;
  --bg-card-hover: #16162a;
  --border: #1a1a2e;
  --border-light: #252540;
  --profit: #00d4aa;
  --profit-dim: rgba(0, 212, 170, 0.15);
  --loss: #ff4757;
  --loss-dim: rgba(255, 71, 87, 0.15);
  --gold: #ffd700;
  --gold-dim: rgba(255, 215, 0, 0.15);
  --blue: #4a9eff;
  --blue-dim: rgba(74, 158, 255, 0.15);
  --text-primary: #e0e0e0;
  --text-secondary: #8888aa;
  --text-muted: #555570;
  --bull: #00d4aa;
  --bear: #ff4757;
  --font-display: 'Space Grotesk', sans-serif;
  --font-body: 'Inter', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --radius: 12px;
  --radius-sm: 8px;
}

/* Light theme */
[data-theme="light"] {
  --bg-primary: #f5f7fa;
  --bg-card: #ffffff;
  --bg-card-hover: #f8f9fb;
  --border: #e0e4e9;
  --border-light: #d0d5db;
  --profit: #00a881;
  --profit-dim: rgba(0, 168, 129, 0.12);
  --loss: #e63946;
  --loss-dim: rgba(230, 57, 70, 0.12);
  --gold: #d4a100;
  --gold-dim: rgba(212, 161, 0, 0.12);
  --blue: #1a73e8;
  --blue-dim: rgba(26, 115, 232, 0.12);
  --text-primary: #1a202c;
  --text-secondary: #4a5568;
  --text-muted: #a0aec0;
  --bull: #00a881;
  --bear: #e63946;
}

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

body {
  font-family: var(--font-body);
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
}

/* ===== HEADER ===== */
.header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 56px;
  background: rgba(10, 10, 15, 0.95);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  z-index: 100;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.nav-menu {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: 8px;
}

.nav-link {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  text-decoration: none;
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  transition: all 0.2s ease;
  border: 1px solid transparent;
}

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

.nav-link.active {
  color: var(--blue);
  background: var(--blue-dim);
  border-color: rgba(74, 158, 255, 0.3);
}

.logo {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.5px;
  background: linear-gradient(135deg, var(--gold), #ffaa00);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.regime-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.regime-pill.bull {
  background: var(--profit-dim);
  color: var(--profit);
  border: 1px solid rgba(0, 212, 170, 0.3);
}

.regime-pill.bear {
  background: var(--loss-dim);
  color: var(--loss);
  border: 1px solid rgba(255, 71, 87, 0.3);
}

.regime-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  animation: pulse 2s infinite;
}

.regime-pill.bull .regime-dot { background: var(--profit); }
.regime-pill.bear .regime-dot { background: var(--loss); }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.header-right {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 13px;
  color: var(--text-secondary);
}

.mode-badge {
  padding: 3px 10px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.5px;
}

.mode-badge.test {
  background: var(--gold-dim);
  color: var(--gold);
}

.mode-badge.live {
  background: var(--profit-dim);
  color: var(--profit);
}

#clock {
  font-family: var(--font-mono);
  font-size: 13px;
}

/* ===== MAIN CONTENT ===== */
.main {
  padding: 72px 24px 24px;
  max-width: 1400px;
  margin: 0 auto;
}

/* ===== AT-A-GLANCE CARDS ===== */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}

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

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

.stat-card .label {
  font-size: 12px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.stat-card .value {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 700;
  line-height: 1.1;
}

.stat-card .sub {
  font-size: 13px;
  margin-top: 4px;
}

.positive { color: var(--profit); }
.negative { color: var(--loss); }
.neutral { color: var(--text-secondary); }

/* ===== ROADMAP PROGRESS ===== */
.roadmap-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
}

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

.roadmap-header h3 {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 600;
}

.roadmap-bar {
  position: relative;
  height: 32px;
  background: var(--bg-primary);
  border-radius: 16px;
  overflow: visible;
  margin: 8px 0;
}

.roadmap-fill {
  height: 100%;
  border-radius: 16px;
  background: linear-gradient(90deg, var(--blue), var(--profit), var(--gold));
  transition: width 1s ease;
  min-width: 2px;
  position: relative;
}

.roadmap-marker {
  position: absolute;
  top: -8px;
  transform: translateX(-50%);
  text-align: center;
}

.roadmap-marker .dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: var(--bg-primary);
  margin: 0 auto;
}

.roadmap-marker .dot.reached {
  background: var(--gold);
  border-color: var(--gold);
}

.roadmap-marker .marker-label {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 4px;
  white-space: nowrap;
}

.roadmap-stats {
  display: flex;
  gap: 24px;
  margin-top: 12px;
  font-size: 13px;
  color: var(--text-secondary);
}

/* ===== SECTION HEADERS ===== */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.section-header h2 {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 600;
}

.section-header .badge {
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 4px;
  background: var(--blue-dim);
  color: var(--blue);
}

/* ===== POSITIONS GRID ===== */
.positions-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.position-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  transition: all 0.2s;
}

.position-card:hover {
  border-color: var(--border-light);
  background: var(--bg-card-hover);
}

.position-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 12px;
}

.position-symbol {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
}

.position-pnl {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 4px;
}

.position-prices {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  font-size: 12px;
  margin-bottom: 12px;
}

.position-prices .price-item {
  display: flex;
  justify-content: space-between;
}

.position-prices .price-label {
  color: var(--text-muted);
}

.position-prices .price-value {
  font-family: var(--font-mono);
}

.position-progress {
  height: 4px;
  background: var(--bg-primary);
  border-radius: 2px;
  margin-bottom: 8px;
  overflow: hidden;
}

.position-progress-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 0.5s;
}

.position-meta {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-muted);
}

.gtt-icon {
  display: inline-flex;
  align-items: center;
  gap: 2px;
}

.gtt-active { color: var(--profit); }
.gtt-missing { color: var(--loss); }

/* ===== SCANNER TABLE ===== */
.scanner-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 20px;
  overflow: hidden;
}

.tab-bar {
  display: flex;
  border-bottom: 1px solid var(--border);
}

.tab {
  padding: 10px 20px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.2s;
}

.tab.active {
  color: var(--text-primary);
  border-bottom-color: var(--gold);
}

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

.table-wrapper {
  overflow-x: auto;
  max-height: 400px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th {
  position: sticky;
  top: 0;
  background: var(--bg-card);
  padding: 10px 12px;
  text-align: left;
  font-weight: 500;
  color: var(--text-secondary);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border);
}

td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 12px;
}

tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

.filter-dots {
  display: flex;
  gap: 3px;
}

.filter-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.filter-dot.pass { background: var(--profit); }
.filter-dot.fail { background: var(--loss); opacity: 0.4; }

.btn {
  padding: 6px 14px;
  border: none;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  font-family: var(--font-body);
}

.btn-buy {
  background: var(--profit-dim);
  color: var(--profit);
  border: 1px solid rgba(0, 212, 170, 0.3);
}

.btn-buy:hover {
  background: rgba(0, 212, 170, 0.25);
}

.btn-sell {
  background: var(--loss-dim);
  color: var(--loss);
  border: 1px solid rgba(255, 71, 87, 0.3);
}

.btn-sell:hover {
  background: rgba(255, 71, 87, 0.25);
}

.btn-action {
  background: var(--blue-dim);
  color: var(--blue);
  border: 1px solid rgba(74, 158, 255, 0.3);
}

.btn-action:hover {
  background: rgba(74, 158, 255, 0.25);
}

/* ===== TWO-COL LAYOUT ===== */
.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 20px;
}

/* ===== ACTIONS TIMELINE ===== */
.timeline {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  max-height: 350px;
  overflow-y: auto;
}

.timeline-item {
  display: flex;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}

.timeline-item:last-child {
  border-bottom: none;
}

.timeline-time {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  min-width: 60px;
}

.timeline-action {
  font-weight: 500;
}

.timeline-detail {
  color: var(--text-secondary);
}

/* ===== COMPLIANCE CARDS ===== */
.compliance-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
}

.compliance-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
  text-align: center;
}

.compliance-card .metric-value {
  font-family: var(--font-display);
  font-size: 32px;
  font-weight: 700;
  margin: 8px 0;
}

.compliance-card .metric-label {
  font-size: 11px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ===== CHARTS ===== */
.chart-container {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.chart-container canvas {
  width: 100% !important;
  height: 250px !important;
}

/* ===== TRADE HISTORY ===== */
.trades-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 20px;
  overflow: hidden;
}

.filter-bar {
  display: flex;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  align-items: center;
}

.filter-bar input, .filter-bar select {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 13px;
  font-family: var(--font-body);
}

/* ===== LOADING ===== */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  color: var(--text-muted);
}

.spinner {
  width: 24px;
  height: 24px;
  border: 3px solid var(--border);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-right: 12px;
}

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

/* ===== RESPONSIVE ===== */
@media (max-width: 1024px) {
  .cards-grid { grid-template-columns: repeat(2, 1fr); }
  .two-col { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  /* Header adjustments */
  .header { padding: 0 16px; height: auto; min-height: 56px; flex-wrap: wrap; }
  .header-left { margin-bottom: 8px; }
  .header-right { 
    flex-wrap: wrap; 
    gap: 8px;
    font-size: 0.9rem;
  }
  
  /* Logo and title */
  .logo { font-size: 1.2rem; }
  .subtitle { display: none; } /* Hide subtitle on smaller screens */
  
  /* Navigation */
  .nav-menu {
    width: 100%;
    flex-wrap: wrap;
    justify-content: flex-start;
    gap: 8px;
    margin-top: 8px;
  }
  
  .nav-link {
    padding: 8px 16px;
    font-size: 0.85rem;
  }
  
  /* Main content */
  .main { padding: 120px 16px 16px; } /* More top padding for wrapped header */
  
  /* Cards */
  .cards-grid { 
    grid-template-columns: 1fr; 
    gap: 12px;
  }
  
  .card {
    padding: 16px;
  }
  
  /* Tables - make scrollable */
  .table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0 -16px;
    padding: 0 16px;
  }
  
  table {
    min-width: 600px; /* Force horizontal scroll for wide tables */
    font-size: 0.85rem;
  }
  
  th, td {
    padding: 8px 6px;
  }
  
  /* Buttons */
  .btn {
    min-height: 44px; /* Better touch target */
    padding: 10px 16px;
    font-size: 0.9rem;
  }
  
  .btn-sm {
    min-height: 38px;
    padding: 6px 12px;
    font-size: 0.85rem;
  }
  
  /* Modal */
  .modal-content {
    width: 95%;
    max-width: 400px;
    margin: 20px;
    padding: 20px;
  }
  
  .modal-body {
    max-height: 60vh;
  }
}

@media (max-width: 640px) {
  .cards-grid { grid-template-columns: 1fr; }
  .header { padding: 0 12px; }
  .main { padding: 140px 12px 12px; } /* Even more top padding */
  .positions-grid { grid-template-columns: 1fr; }
  
  /* Stack header items vertically */
  .header-left, .header-right {
    width: 100%;
    justify-content: space-between;
  }
  
  /* Logo smaller on mobile */
  .logo { font-size: 1.1rem; }
  
  /* Metrics - reduce font size */
  .metric-value { font-size: 1.5rem; }
  .metric-label { font-size: 0.75rem; }
  
  /* Card titles */
  .section-title { font-size: 0.9rem; }
  
  /* Tables - allow even more scroll */
  table {
    font-size: 0.8rem;
    min-width: 500px;
  }
  
  th, td {
    padding: 6px 4px;
    white-space: nowrap;
  }
  
  /* Hide less important columns on mobile */
  .hide-mobile {
    display: none !important;
  }
  
  /* Forms */
  input, select, textarea {
    font-size: 16px; /* Prevent zoom on iOS */
    min-height: 44px;
  }
  
  /* Toast notifications */
  .toast {
    left: 10px;
    right: 10px;
    width: auto;
    font-size: 0.85rem;
  }
  
  /* Regiment pill */
  .regime-pill {
    font-size: 0.7rem;
    padding: 4px 8px;
  }
}

@media (max-width: 480px) {
  /* Very small screens - ultra compact */
  .header { padding: 0 8px; }
  .main { padding: 150px 8px 8px; }
  
  .logo { font-size: 1rem; }
  .metric-value { font-size: 1.3rem; }
  
  /* Stack navigation fully */
  .nav-link {
    flex: 1 1 auto;
    text-align: center;
    padding: 8px 10px;
    font-size: 0.8rem;
  }
  
  /* Buttons full width on very small screens */
  .modal-actions .btn {
    flex: 1;
    min-width: 100px;
  }
  
  table {
    font-size: 0.75rem;
  }
}

/* Landscape orientation on mobile */
@media (max-height: 500px) and (orientation: landscape) {
  .main { padding-top: 100px; }
  .modal-body { max-height: 50vh; }
}

/* Scrollbar styling */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-primary); }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* Dark mode toggle */
.theme-toggle {
  position: relative;
  width: 48px;
  height: 24px;
  background: var(--border-light);
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.3s ease;
  border: 1px solid var(--border);
}

.theme-toggle:hover {
  background: var(--text-muted);
}

.theme-toggle-slider {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  background: var(--text-primary);
  border-radius: 50%;
  transition: transform 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
}

.theme-toggle-slider::before {
  content: '🌙';
}

[data-theme="light"] .theme-toggle-slider {
  transform: translateX(24px);
}

[data-theme="light"] .theme-toggle-slider::before {
  content: '☀️';
}

/* Smooth theme transition */
body, .header, .main, .card, .btn, .modal, input, select, textarea {
  transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}


/* ===== TOAST ANIMATIONS ===== */
@keyframes slideIn {
  from {
    transform: translateX(400px);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

/* ===== SCHEDULER HEALTH INDICATOR ===== */
.scheduler-health {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border: 1px solid;
  cursor: pointer;
  transition: all 0.2s ease;
}

.scheduler-health.healthy {
  color: var(--profit);
  background: var(--profit-dim);
  border-color: rgba(0, 212, 170, 0.3);
}

.scheduler-health.recovering {
  color: var(--gold);
  background: var(--gold-dim);
  border-color: rgba(255, 215, 0, 0.3);
  animation: pulse 2s infinite;
}

.scheduler-health.degraded {
  color: var(--loss);
  background: var(--loss-dim);
  border-color: rgba(255, 71, 87, 0.3);
  animation: pulse 1.5s infinite;
}

.scheduler-health .health-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}


@keyframes slideOut {
  from {
    transform: translateX(0);
    opacity: 1;
  }
  to {
    transform: translateX(400px);
    opacity: 0;
  }
}
