/* ============================================================
   Paper Trading Portal - Main Stylesheet
   ============================================================ */

:root {
  --sidebar-w: 240px;
  --sidebar-collapsed-w: 68px;
  --navbar-h: 58px;

  /* Dark theme */
  --bg-primary:   #0d1117;
  --bg-secondary: #161b22;
  --bg-card:      #1c2128;
  --bg-card-2:    #21262d;
  --border-color: #30363d;
  --text-primary: #e6edf3;
  --text-muted:   #7d8590;
  --accent:       #238636;
  --accent-hover: #2ea043;
  --sidebar-bg:   #161b22;
  --navbar-bg:    rgba(22,27,34,0.95);

  --green:  #3fb950;
  --red:    #f85149;
  --yellow: #d29922;
  --blue:   #58a6ff;
  --purple: #bc8cff;
  --orange: #f0883e;

  --font-body: 'Inter', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
}

[data-bs-theme="light"] {
  --bg-primary:   #f6f8fa;
  --bg-secondary: #ffffff;
  --bg-card:      #ffffff;
  --bg-card-2:    #f6f8fa;
  --border-color: #d0d7de;
  --text-primary: #1f2328;
  --text-muted:   #57606a;
  --sidebar-bg:   #ffffff;
  --navbar-bg:    rgba(255,255,255,0.95);
}

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

body {
  font-family: var(--font-body);
  background: var(--bg-primary);
  color: var(--text-primary);
  overflow-x: hidden;
  font-size: 14px;
}

.font-mono { font-family: var(--font-mono) !important; }

/* ── Sidebar ─────────────────────────────────────────────────────────── */
.sidebar {
  position: fixed;
  left: 0; top: 0; bottom: 0;
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  transition: width 0.25s ease;
  z-index: 1040;
  overflow: hidden;
}

.sidebar.collapsed { width: var(--sidebar-collapsed-w); }
.sidebar.collapsed .brand-text,
.sidebar.collapsed .nav-item span,
.sidebar.collapsed .sidebar-footer { opacity: 0; pointer-events: none; }

.sidebar-brand {
  display: flex;
  align-items: center;
  height: var(--navbar-h);
  padding: 0 18px;
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}

.brand-text {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  transition: opacity 0.2s;
}

.sidebar-nav { flex: 1; padding: 8px 0; overflow-y: auto; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 18px;
  color: var(--text-muted);
  text-decoration: none;
  border-radius: 6px;
  margin: 2px 8px;
  font-size: 13.5px;
  font-weight: 500;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
}

.nav-item:hover  { background: var(--bg-card); color: var(--text-primary); }
.nav-item.active { background: rgba(35,134,54,0.15); color: var(--green); }
.nav-item i      { font-size: 16px; flex-shrink: 0; width: 20px; text-align: center; }

.sidebar-divider { border-color: var(--border-color); margin: 8px 16px; }

.sidebar-footer {
  padding: 12px 18px;
  border-top: 1px solid var(--border-color);
  transition: opacity 0.2s;
}

.capital-mini small { font-size: 11px; display: block; }

/* ── Top Navbar ─────────────────────────────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-w);
  transition: margin-left 0.25s ease;
  min-height: 100vh;
}

.main-content.expanded { margin-left: var(--sidebar-collapsed-w); }

.top-navbar {
  position: sticky;
  top: 0;
  height: var(--navbar-h);
  background: var(--navbar-bg);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  padding: 0 20px;
  z-index: 1030;
}

.btn-sidebar-toggle {
  background: none; border: none;
  color: var(--text-muted); cursor: pointer;
  padding: 4px 8px; border-radius: 6px;
  transition: background 0.15s, color 0.15s;
}
.btn-sidebar-toggle:hover { background: var(--bg-card); color: var(--text-primary); }

.btn-icon {
  background: none; border: none;
  color: var(--text-muted); cursor: pointer;
  padding: 6px; border-radius: 8px;
  transition: background 0.15s, color 0.15s;
  display: flex; align-items: center;
}
.btn-icon:hover { background: var(--bg-card); color: var(--text-primary); }

/* Market status */
.market-status {
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 500;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  padding: 4px 12px;
}

.status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: pulse-dot 2s infinite;
}

.status-dot.open   { background: var(--green); }
.status-dot.closed { background: var(--red); animation: none; }

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

/* Index chips */
.index-chip {
  font-size: 12px; color: var(--text-muted);
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 6px; padding: 3px 10px;
}
.index-chip strong { color: var(--text-primary); font-family: var(--font-mono); }

/* Live clock */
.live-clock {
  font-size: 13px; font-weight: 500;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

/* Avatar */
.avatar-sm {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: linear-gradient(135deg, #238636, #1a7f37);
  color: #fff; font-size: 13px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}

/* Notification badge */
.notif-badge {
  position: absolute; top: 0; right: 0;
  width: 18px; height: 18px;
  background: var(--red); color: #fff;
  border-radius: 50%; font-size: 10px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
}

.notif-dropdown { width: 340px; max-height: 420px; overflow-y: auto; }
.notif-header   { border-bottom: 1px solid var(--border-color); }

/* ── Page wrapper ────────────────────────────────────────────────────── */
.page-wrapper { padding: 24px; }

/* ── Cards ───────────────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
}

.card-header {
  background: transparent;
  border-bottom: 1px solid var(--border-color);
  padding: 14px 18px;
  font-size: 13px;
  font-weight: 600;
}

.card-body { padding: 18px; }

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 18px 20px;
  transition: border-color 0.2s, transform 0.15s;
}
.stat-card:hover { border-color: var(--accent); transform: translateY(-1px); }

.stat-label  { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .5px; font-weight: 500; }
.stat-value  { font-size: 22px; font-weight: 700; font-family: var(--font-mono); margin: 4px 0; }
.stat-change { font-size: 12px; }

/* ── Tables ──────────────────────────────────────────────────────────── */
.table-trading {
  width: 100%; border-collapse: separate; border-spacing: 0;
  font-size: 13px;
}
.table-trading th {
  color: var(--text-muted); font-weight: 500; font-size: 11px;
  text-transform: uppercase; letter-spacing: .4px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}
.table-trading td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border-color);
  vertical-align: middle;
}
.table-trading tbody tr:hover { background: var(--bg-card-2); }
.table-trading tbody tr:last-child td { border-bottom: none; }

/* ── Badges ──────────────────────────────────────────────────────────── */
.badge-buy    { background: rgba(63,185,80,.15);  color: var(--green); border: 1px solid rgba(63,185,80,.3); }
.badge-sell   { background: rgba(248,81,73,.15);  color: var(--red);   border: 1px solid rgba(248,81,73,.3); }
.badge-short  { background: rgba(248,81,73,.15);  color: var(--red);   border: 1px solid rgba(248,81,73,.3); }
.badge-hold   { background: rgba(210,153,34,.15); color: var(--yellow); border: 1px solid rgba(210,153,34,.3); }
.badge-open   { background: rgba(88,166,255,.15); color: var(--blue);  border: 1px solid rgba(88,166,255,.3); }
.badge-closed { background: rgba(125,133,144,.15); color: var(--text-muted); border: 1px solid var(--border-color); }

.badge-signal {
  padding: 3px 8px; font-size: 11px; font-weight: 600;
  border-radius: 4px; display: inline-block;
}

/* ── Signal strength bar ─────────────────────────────────────────────── */
.strength-bar {
  height: 4px; border-radius: 2px;
  background: var(--border-color); overflow: hidden;
}
.strength-fill { height: 100%; border-radius: 2px; transition: width .3s; }

/* ── P&L colors ──────────────────────────────────────────────────────── */
.text-profit  { color: var(--green) !important; }
.text-loss    { color: var(--red)   !important; }
.bg-profit    { background: rgba(63,185,80,.08) !important; }
.bg-loss      { background: rgba(248,81,73,.08) !important; }

/* ── Buttons ─────────────────────────────────────────────────────────── */
.btn-trading {
  font-size: 13px; font-weight: 500; border-radius: 8px; padding: 6px 16px;
  border: none; cursor: pointer; transition: all 0.15s;
}
.btn-buy   { background: rgba(63,185,80,.15);  color: var(--green); border: 1px solid rgba(63,185,80,.4); }
.btn-sell  { background: rgba(248,81,73,.15);  color: var(--red);   border: 1px solid rgba(248,81,73,.4); }
.btn-buy:hover  { background: var(--green); color: #fff; }
.btn-sell:hover { background: var(--red);   color: #fff; }

/* ── Scanner pulse animation ─────────────────────────────────────────── */
.scanner-pulse {
  position: relative;
}
.scanner-pulse::after {
  content: '';
  position: absolute;
  top: 50%; left: 50%;
  width: 100%; height: 100%;
  border-radius: inherit;
  background: rgba(35,134,54,.3);
  transform: translate(-50%,-50%) scale(0);
  animation: scan-pulse 2s infinite;
}
@keyframes scan-pulse {
  0%   { transform: translate(-50%,-50%) scale(1); opacity: .6; }
  100% { transform: translate(-50%,-50%) scale(2); opacity: 0; }
}

/* ── Animated counter ────────────────────────────────────────────────── */
.counter { transition: all .3s; }

/* ── Chart containers ────────────────────────────────────────────────── */
.chart-container { position: relative; }
#equityChart, #dailyPnlChart, #monthlyChart,
#winLossChart, #stratChart { min-height: 260px; }

/* ── Login page ──────────────────────────────────────────────────────── */
.login-bg {
  min-height: 100vh;
  background: radial-gradient(ellipse at 30% 40%, rgba(35,134,54,.12) 0%, transparent 60%),
              radial-gradient(ellipse at 70% 60%, rgba(88,166,255,.08) 0%, transparent 60%),
              var(--bg-primary);
  display: flex; align-items: center; justify-content: center;
}

.login-card {
  width: 100%; max-width: 420px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 40px 36px;
  box-shadow: 0 20px 60px rgba(0,0,0,.4);
}

/* ── Scrollbar ───────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ── Glassmorphism stat cards ─────────────────────────────────────────── */
.glass-card {
  background: linear-gradient(135deg, rgba(255,255,255,.03) 0%, rgba(255,255,255,.01) 100%);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255,255,255,.07);
}

/* ── Toast notifications ─────────────────────────────────────────────── */
#toastContainer {
  position: fixed; bottom: 24px; right: 24px;
  z-index: 9999; display: flex; flex-direction: column; gap: 8px;
}

.trade-toast {
  min-width: 280px; max-width: 360px;
  background: var(--bg-card-2);
  border: 1px solid var(--border-color);
  border-radius: 10px; padding: 14px 16px;
  animation: slideInRight .3s ease;
  box-shadow: 0 8px 24px rgba(0,0,0,.4);
}
@keyframes slideInRight {
  from { transform: translateX(100%); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

/* ── Responsive ──────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.mobile-open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .page-wrapper { padding: 16px; }
}

/* ── Form controls ───────────────────────────────────────────────────── */
.form-control, .form-select {
  background: var(--bg-card-2);
  border-color: var(--border-color);
  color: var(--text-primary);
  font-size: 13px;
}
.form-control:focus, .form-select:focus {
  background: var(--bg-card-2);
  border-color: var(--accent);
  color: var(--text-primary);
  box-shadow: 0 0 0 3px rgba(35,134,54,.15);
}
.form-label { font-size: 12px; font-weight: 500; color: var(--text-muted); margin-bottom: 5px; }
.input-group-text {
  background: var(--bg-card-2);
  border-color: var(--border-color);
  color: var(--text-muted);
}

/* ── Dropdown menus ──────────────────────────────────────────────────── */
.dropdown-menu {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  font-size: 13px;
  border-radius: 10px;
  box-shadow: 0 12px 40px rgba(0,0,0,.4);
}
.dropdown-item { color: var(--text-primary); padding: 8px 16px; border-radius: 6px; margin: 2px 4px; }
.dropdown-item:hover { background: var(--bg-card-2); color: var(--text-primary); }

/* ── Loading spinner overlay ─────────────────────────────────────────── */
.loading-overlay {
  position: absolute; inset: 0;
  background: rgba(0,0,0,.5);
  display: flex; align-items: center; justify-content: center;
  border-radius: inherit; z-index: 10;
}

/* ── VWAP / indicator colors ─────────────────────────────────────────── */
.ind-bullish { color: var(--green); }
.ind-bearish { color: var(--red); }
.ind-neutral { color: var(--text-muted); }

/* ── Mode badges ─────────────────────────────────────────────────────── */
.mode-conservative { background: rgba(88,166,255,.15);  color: var(--blue); }
.mode-moderate     { background: rgba(63,185,80,.15);   color: var(--green); }
.mode-aggressive   { background: rgba(248,81,73,.15);   color: var(--red); }
.mode-scalping     { background: rgba(240,136,62,.15);  color: var(--orange); }
