/* LOTA Trading Dashboard — Professional Dark Theme */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:       #08090a;
  --bg2:      #0f1114;
  --bg3:      #151820;
  --bg4:      #1c2030;
  --border:   #1e2235;
  --border2:  #2a3050;
  --green:    #00e676;
  --green-bg: rgba(0,230,118,0.08);
  --red:      #ff5252;
  --red-bg:   rgba(255,82,82,0.08);
  --blue:     #448aff;
  --blue-bg:  rgba(68,138,255,0.08);
  --yellow:   #ffd740;
  --yellow-bg:rgba(255,215,64,0.08);
  --purple:   #b388ff;
  --orange:   #ffab40;
  --cyan:     #00e5ff;
  --text:     #e8eaed;
  --text2:    #9aa0b0;
  --text3:    #5a6070;
  --text4:    #3a4050;
  --accent:   #00e676;
  --radius:   8px;
  --radius-lg:12px;
  --shadow:   0 2px 12px rgba(0,0,0,0.4);
  --sidebar-w:240px;
  --header-h: 56px;
}

html, body { height: 100%; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 13px;
  color: var(--text);
  background: var(--bg);
  display: flex;
  overflow: hidden;
}

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

/* ── SIDEBAR ───────────────────────────────────────────── */
#sidebar {
  width: var(--sidebar-w);
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow-y: auto;
  z-index: 10;
}

.sidebar-brand {
  padding: 20px 18px 16px;
  border-bottom: 1px solid var(--border);
}
.sidebar-brand h1 {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--accent);
  text-transform: uppercase;
}
.sidebar-brand p {
  font-size: 10px;
  color: var(--text3);
  margin-top: 4px;
  letter-spacing: 0.5px;
}

.nav-group { padding: 12px 0 4px; }
.nav-group-title {
  padding: 0 18px 6px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--text3);
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 18px;
  cursor: pointer;
  color: var(--text2);
  font-size: 12.5px;
  font-weight: 500;
  transition: all 0.15s;
  border-left: 3px solid transparent;
}
.nav-item:hover { background: var(--bg3); color: var(--text); }
.nav-item.active {
  background: rgba(0,230,118,0.05);
  color: var(--accent);
  border-left-color: var(--accent);
}
.nav-icon { font-size: 14px; width: 20px; text-align: center; }
.nav-dot {
  width: 7px; height: 7px; border-radius: 50%; margin-left: auto;
  flex-shrink: 0;
}
.nav-dot.running { background: var(--green); box-shadow: 0 0 6px var(--green); }
.nav-dot.stopped { background: var(--red); }
.nav-dot.unknown { background: var(--text3); }
.nav-dot.disabled { background: var(--text4); }

/* ── MAIN ──────────────────────────────────────────────── */
#main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

#header {
  height: var(--header-h);
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  flex-shrink: 0;
}
#header-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}
#header-sub {
  font-size: 11px;
  color: var(--text3);
}
#header-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 11px;
  color: var(--text3);
}
#header-right .stat {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}
#header-right .stat-label { font-size: 9px; text-transform: uppercase; letter-spacing: 1px; }
#header-right .stat-value { font-size: 14px; font-weight: 700; margin-top: 1px; }

#content {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

/* ── CARDS ──────────────────────────────────────────────── */
.card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
}
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.card-title {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text2);
}

/* ── STAT GRID ─────────────────────────────────────────── */
.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
}
.stat-card .label {
  font-size: 10px;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 6px;
}
.stat-card .value {
  font-size: 24px;
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.stat-card .sub {
  font-size: 11px;
  color: var(--text3);
  margin-top: 2px;
}
.stat-card .value.green { color: var(--green); }
.stat-card .value.red   { color: var(--red); }
.stat-card .value.blue  { color: var(--blue); }
.stat-card .value.yellow { color: var(--yellow); }

/* ── BOT GRID ──────────────────────────────────────────── */
.bot-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
  margin-top: 16px;
}
.bot-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
  overflow: hidden;
}
.bot-card:hover {
  border-color: var(--border2);
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}
.bot-card .top {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}
.bot-card .icon { font-size: 20px; }
.bot-card .name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.bot-card .exchange {
  font-size: 10px;
  color: var(--text3);
  margin-top: 1px;
}
.bot-card .dot {
  width: 8px; height: 8px; border-radius: 50%; margin-left: auto;
}
.bot-card .dot.running { background: var(--green); box-shadow: 0 0 6px var(--green); }
.bot-card .dot.stopped { background: var(--red); }
.bot-card .dot.unknown { background: var(--text3); }
.bot-card .metrics {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
}
.bot-card .metric {
  background: var(--bg);
  border-radius: 6px;
  padding: 8px;
  text-align: center;
}
.bot-card .metric .ml { font-size: 9px; color: var(--text3); text-transform: uppercase; letter-spacing: 0.5px; }
.bot-card .metric .mv { font-size: 14px; font-weight: 700; margin-top: 2px; font-variant-numeric: tabular-nums; }
.bot-card .live-tag {
  position: absolute;
  top: 10px; right: 10px;
  font-size: 9px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 1px;
}
.bot-card .live-tag.live { background: var(--green-bg); color: var(--green); border: 1px solid rgba(0,230,118,0.2); }
.bot-card .live-tag.paper { background: var(--bg3); color: var(--text3); }

/* ── TABLES ────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; }
th {
  padding: 10px 14px;
  text-align: left;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text3);
  background: var(--bg3);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
td {
  padding: 10px 14px;
  font-size: 12px;
  color: var(--text2);
  border-bottom: 1px solid var(--border);
  font-variant-numeric: tabular-nums;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(255,255,255,0.015); }
.td-green { color: var(--green); font-weight: 600; }
.td-red   { color: var(--red); font-weight: 600; }
.td-mono  { font-family: 'JetBrains Mono', 'Fira Code', monospace; font-size: 11px; }

/* ── BADGES ────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
  white-space: nowrap;
}
.badge-long  { color: var(--green); background: var(--green-bg); }
.badge-short { color: var(--red); background: var(--red-bg); }
.badge-lev   { color: var(--yellow); background: var(--yellow-bg); }
.badge-live  { color: var(--green); background: var(--green-bg); }
.badge-paper { color: var(--text3); background: var(--bg3); }
.badge-win   { color: var(--green); background: var(--green-bg); }
.badge-loss  { color: var(--red); background: var(--red-bg); }
.badge-be    { color: var(--blue); background: var(--blue-bg); }
.badge-trail { color: var(--cyan); background: rgba(0,229,255,0.08); }
.badge-timeout { color: var(--orange); background: rgba(255,171,64,0.08); }

/* ── TAB BAR ───────────────────────────────────────────── */
.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.tab-btn {
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text2);
  padding: 8px 16px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  transition: all 0.15s;
}
.tab-btn:hover { border-color: var(--border2); color: var(--text); }
.tab-btn.active {
  background: rgba(0,230,118,0.08);
  border-color: rgba(0,230,118,0.3);
  color: var(--accent);
}

/* ── POSITION CARDS ────────────────────────────────────── */
.pos-card {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 10px;
  border-left: 3px solid var(--border2);
}
.pos-card.profit { border-left-color: var(--green); }
.pos-card.loss   { border-left-color: var(--red); }
.pos-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}
.pos-symbol {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}
.pos-pnl {
  font-size: 20px;
  font-weight: 700;
  text-align: right;
}
.pos-pnl.green { color: var(--green); }
.pos-pnl.red   { color: var(--red); }
.pos-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 6px;
}
.pos-field {
  background: var(--bg);
  border-radius: 5px;
  padding: 7px;
  text-align: center;
}
.pos-field .pfl { font-size: 9px; color: var(--text3); text-transform: uppercase; letter-spacing: 0.8px; }
.pos-field .pfv { font-size: 12px; font-weight: 600; color: var(--text2); margin-top: 2px; font-variant-numeric: tabular-nums; }

/* ── DAILY PNL CHART ───────────────────────────────────── */
.daily-chart {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  height: 80px;
  padding: 8px 0;
}
.daily-bar {
  flex: 1;
  min-width: 8px;
  border-radius: 3px 3px 0 0;
  position: relative;
  transition: opacity 0.2s;
}
.daily-bar:hover { opacity: 0.8; }
.daily-label {
  position: absolute;
  bottom: -16px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 8px;
  color: var(--text4);
  white-space: nowrap;
}
.daily-val {
  position: absolute;
  top: -14px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 9px;
  white-space: nowrap;
}

/* ── LOADING / EMPTY ───────────────────────────────────── */
.loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px;
  color: var(--text3);
}
.spin {
  width: 28px; height: 28px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 12px;
}
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 0%,100%{ opacity: 1; } 50%{ opacity: 0.5; } }

.empty {
  text-align: center;
  padding: 40px;
  color: var(--text3);
  font-size: 13px;
}

/* ── RESPONSIVE ────────────────────────────────────────── */
@media (max-width: 768px) {
  :root { --sidebar-w: 0px; }
  #sidebar {
    position: fixed;
    left: -260px;
    top: 0; bottom: 0;
    width: 260px;
    transition: left 0.3s;
    box-shadow: 4px 0 20px rgba(0,0,0,0.5);
  }
  #sidebar.open { left: 0; }
  .stats-row { grid-template-columns: repeat(2, 1fr); }
  .bot-grid { grid-template-columns: 1fr; }
  #content { padding: 16px; }
  .hamburger { display: block !important; }
}

.hamburger {
  display: none;
  background: none;
  border: none;
  color: var(--text);
  font-size: 22px;
  cursor: pointer;
  padding: 4px;
}

/* ── POLISH / GLOW ─────────────────────────────────────── */
.sidebar-brand h1 {
  background: linear-gradient(135deg, var(--green), var(--cyan));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

#sidebar { background: linear-gradient(180deg, var(--bg2) 0%, #0a0c10 100%); }
#header  { background: linear-gradient(90deg, var(--bg2) 0%, #0d1018 100%); }

.stat-card {
  background: linear-gradient(145deg, var(--bg3), var(--bg2));
  transition: transform 0.15s, box-shadow 0.15s;
}
.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(0,0,0,0.3);
}

.bot-card {
  background: linear-gradient(145deg, var(--bg2), var(--bg3));
}
.bot-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--border2), transparent);
  opacity: 0;
  transition: opacity 0.2s;
}
.bot-card:hover::before { opacity: 1; }

.pos-card {
  background: linear-gradient(145deg, var(--bg3), var(--bg2));
  transition: transform 0.15s;
}
.pos-card:hover { transform: translateX(2px); }

/* Spotlight card glow */
.spotlight {
  position: relative;
  overflow: hidden;
}
.spotlight::after {
  content: '';
  position: absolute;
  top: -50%; left: -50%;
  width: 200%; height: 200%;
  background: radial-gradient(circle at 30% 30%, rgba(0,230,118,0.03) 0%, transparent 60%);
  pointer-events: none;
}
.spotlight.negative::after {
  background: radial-gradient(circle at 30% 30%, rgba(255,82,82,0.03) 0%, transparent 60%);
}

/* Pulse animation for live dots */
.nav-dot.running {
  animation: dot-pulse 2s ease-in-out infinite;
}
@keyframes dot-pulse {
  0%, 100% { box-shadow: 0 0 4px var(--green); }
  50% { box-shadow: 0 0 10px var(--green), 0 0 20px rgba(0,230,118,0.3); }
}

/* Table hover glow */
tr:hover td { background: rgba(0,230,118,0.02); }

/* Better badge styling */
.badge { letter-spacing: 0.3px; }

/* Header divider line accent */
#header::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  opacity: 0.15;
}
#header { position: relative; }
