/* ============================================================
   Trading Bot Panel — Main Stylesheet
   Framework: Bootstrap 5.3 + custom
   ============================================================ */

:root {
  --sidebar-width: 240px;
  --topbar-height: 56px;
  --sidebar-bg: #1a2035;
  --sidebar-hover: #253050;
  --sidebar-active: #2d3a5e;
  --sidebar-text: #a0aec0;
  --sidebar-text-active: #fff;
  --sidebar-border: rgba(255,255,255,0.06);

  --card-radius: 12px;
  --card-shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 8px rgba(0,0,0,.06);
  --card-shadow-hover: 0 4px 16px rgba(0,0,0,.12);

  --color-scalp:  #3b82f6;
  --color-early:  #8b5cf6;
  --color-swing:  #10b981;

  --color-long-bg:   #dcfce7;
  --color-long-text: #166534;
  --color-long-border: #86efac;
  --color-short-bg:  #fee2e2;
  --color-short-text:#991b1b;
  --color-short-border:#fca5a5;

  --color-win:  #10b981;
  --color-loss: #ef4444;
  --color-neutral: #6b7280;
}

/* ── Reset / Base ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
body {
  margin: 0;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-size: 14px;
  background: #f1f5f9;
  color: #1e293b;
  overflow-x: hidden;
}

/* ── Sidebar ─────────────────────────────────────────────── */
.sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  z-index: 1000;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.1) transparent;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--sidebar-border);
  text-decoration: none;
}
.sidebar-brand-icon {
  width: 34px; height: 34px;
  background: linear-gradient(135deg, #3b82f6, #8b5cf6);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  font-size: 16px;
  flex-shrink: 0;
}
.sidebar-brand-text {
  font-weight: 700;
  font-size: 14px;
  color: #fff;
  line-height: 1.2;
}
.sidebar-brand-sub {
  font-size: 10px;
  color: var(--sidebar-text);
  font-weight: 400;
}

.sidebar-section {
  padding: 16px 20px 4px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: rgba(160,174,192,.5);
}

.sidebar-nav {
  list-style: none;
  margin: 0;
  padding: 4px 0;
}
.sidebar-nav li a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 20px;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  border-radius: 0;
  transition: background .15s, color .15s;
  position: relative;
}
.sidebar-nav li a:hover {
  background: var(--sidebar-hover);
  color: var(--sidebar-text-active);
}
.sidebar-nav li a.active {
  background: var(--sidebar-active);
  color: var(--sidebar-text-active);
}
.sidebar-nav li a.active::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--color-scalp);
  border-radius: 0 2px 2px 0;
}
.sidebar-nav li a .nav-icon {
  font-size: 16px;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}
.sidebar-nav li a .nav-badge {
  margin-left: auto;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 20px;
  line-height: 1.6;
}
.badge-scalp  { background: rgba(59,130,246,.25); color: #93c5fd; }
.badge-early  { background: rgba(139,92,246,.25);  color: #c4b5fd; }
.badge-swing  { background: rgba(16,185,129,.25);  color: #6ee7b7; }

/* Active line color per module */
.nav-scalp.active::before  { background: var(--color-scalp) !important; }
.nav-early.active::before  { background: var(--color-early) !important; }
.nav-swing.active::before  { background: var(--color-swing) !important; }

.sidebar-footer {
  margin-top: auto;
  padding: 12px 20px;
  border-top: 1px solid var(--sidebar-border);
  font-size: 11px;
  color: rgba(160,174,192,.5);
}
.sidebar-footer .version { font-weight: 600; }

/* ── Topbar ─────────────────────────────────────────────── */
.topbar {
  position: fixed;
  top: 0;
  left: var(--sidebar-width);
  right: 0;
  height: var(--topbar-height);
  background: #fff;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  align-items: center;
  padding: 0 24px;
  z-index: 900;
  gap: 16px;
}
.topbar-title {
  font-size: 16px;
  font-weight: 700;
  color: #0f172a;
  flex-shrink: 0;
}
.topbar-spacer { flex: 1; }

.topbar-pnl-group {
  display: flex;
  align-items: center;
  gap: 8px;
}
.topbar-pnl-item {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 8px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  font-size: 12px;
  font-weight: 600;
}
.topbar-pnl-item .label { color: #64748b; font-weight: 500; }
.topbar-pnl-item .value { font-weight: 700; }
.topbar-pnl-item .value.pos { color: var(--color-win); }
.topbar-pnl-item .value.neg { color: var(--color-loss); }
.topbar-pnl-item .value.zero { color: var(--color-neutral); }

.live-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--color-win);
  animation: pulse-dot 2s infinite;
  flex-shrink: 0;
}
.live-dot.stale { background: #f59e0b; animation: none; }
.live-dot.dead  { background: var(--color-loss); animation: none; }

@keyframes pulse-dot {
  0%,100% { opacity: 1; transform: scale(1); }
  50%      { opacity: .6; transform: scale(.8); }
}

.topbar-user {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; font-weight: 600;
  color: #374151;
}
.topbar-user .avatar {
  width: 30px; height: 30px;
  background: linear-gradient(135deg,#3b82f6,#8b5cf6);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 13px; font-weight: 700;
}

/* ── Main content area ─────────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-width);
  margin-top: var(--topbar-height);
  min-height: calc(100vh - var(--topbar-height));
  padding: 24px;
}

/* ── Cards ──────────────────────────────────────────────── */
.card {
  background: #fff;
  border-radius: var(--card-radius);
  box-shadow: var(--card-shadow);
  border: 1px solid #f1f5f9;
}
.card:hover { box-shadow: var(--card-shadow-hover); }
.card-header {
  padding: 14px 20px;
  border-bottom: 1px solid #f1f5f9;
  display: flex; align-items: center; gap: 10px;
  background: transparent;
  border-radius: var(--card-radius) var(--card-radius) 0 0;
}
.card-header h6 {
  margin: 0;
  font-size: 13px;
  font-weight: 700;
  color: #0f172a;
}
.card-header .card-actions { margin-left: auto; }
.card-body { padding: 16px 20px; }

/* Stat cards */
.stat-card {
  padding: 20px;
  border-radius: var(--card-radius);
  background: #fff;
  box-shadow: var(--card-shadow);
  border: 1px solid #f1f5f9;
  display: flex; flex-direction: column; gap: 4px;
}
.stat-card .stat-label {
  font-size: 12px;
  color: #64748b;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .05em;
}
.stat-card .stat-value {
  font-size: 24px;
  font-weight: 800;
  color: #0f172a;
  line-height: 1;
}
.stat-card .stat-sub {
  font-size: 11px;
  color: #94a3b8;
}
.stat-card .stat-icon {
  font-size: 28px;
  margin-bottom: 4px;
}
.stat-card.scalp-card  .stat-icon { color: var(--color-scalp); }
.stat-card.early-card  .stat-icon { color: var(--color-early); }
.stat-card.swing-card  .stat-icon { color: var(--color-swing); }

/* ── Tables ─────────────────────────────────────────────── */
.table-panel {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.table-panel thead th {
  background: #f8fafc;
  padding: 10px 12px;
  font-weight: 700;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: #64748b;
  border-bottom: 1px solid #e2e8f0;
  white-space: nowrap;
}
.table-panel tbody td {
  padding: 10px 12px;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: middle;
}
.table-panel tbody tr:hover td { background: #f8fafc; }
.table-panel tbody tr:last-child td { border-bottom: none; }

/* ── Badges / Pills ──────────────────────────────────────── */
.dir-badge {
  display: inline-flex; align-items: center;
  padding: 2px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .03em;
}
.dir-long  { background: var(--color-long-bg);  color: var(--color-long-text);  border: 1px solid var(--color-long-border); }
.dir-short { background: var(--color-short-bg); color: var(--color-short-text); border: 1px solid var(--color-short-border); }

.status-badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
}
.status-open     { background: #dbeafe; color: #1e40af; }
.status-closed   { background: #f0fdf4; color: #166534; }
.status-pending  { background: #fef3c7; color: #92400e; }
.status-waiting  { background: #ede9fe; color: #5b21b6; }
.status-expired  { background: #f1f5f9; color: #64748b; }
.status-blocked  { background: #fee2e2; color: #991b1b; }

.module-tag {
  display: inline-flex; align-items: center;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
}
.module-scalp { background: rgba(59,130,246,.12);  color: #2563eb; }
.module-early { background: rgba(139,92,246,.12);   color: #7c3aed; }
.module-swing { background: rgba(16,185,129,.12);   color: #059669; }

/* Score bar */
.score-bar {
  display: flex; align-items: center; gap: 8px;
}
.score-bar .bar-track {
  flex: 1; height: 5px; background: #e2e8f0; border-radius: 99px; overflow: hidden;
}
.score-bar .bar-fill {
  height: 100%; border-radius: 99px;
  transition: width .4s;
}
.score-bar .bar-fill.high  { background: var(--color-win); }
.score-bar .bar-fill.med   { background: #f59e0b; }
.score-bar .bar-fill.low   { background: var(--color-loss); }
.score-num { font-weight: 700; font-size: 13px; min-width: 28px; text-align: right; }

/* PnL coloring */
.pnl-pos { color: var(--color-win);  font-weight: 700; }
.pnl-neg { color: var(--color-loss); font-weight: 700; }
.pnl-zero { color: var(--color-neutral); font-weight: 600; }

/* Flash animation for live PnL */
@keyframes flash-green {
  0% { background: rgba(16,185,129,.25); }
  100% { background: transparent; }
}
@keyframes flash-red {
  0% { background: rgba(239,68,68,.25); }
  100% { background: transparent; }
}
.flash-green { animation: flash-green .6s ease-out; }
.flash-red   { animation: flash-red   .6s ease-out; }

/* ── Service status indicators ─────────────────────────── */
.service-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid #f1f5f9;
}
.service-row:last-child { border-bottom: none; }
.service-dot {
  width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0;
}
.service-dot.active   { background: var(--color-win); }
.service-dot.inactive { background: var(--color-loss); }
.service-dot.unknown  { background: #f59e0b; }
.service-name { font-weight: 600; font-size: 13px; flex: 1; }
.service-status { font-size: 11px; font-weight: 600; }
.service-status.active   { color: var(--color-win); }
.service-status.inactive { color: var(--color-loss); }

/* ── Coin state badges ──────────────────────────────────── */
.coin-state {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 6px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
}
.coin-state-HOT     { background: #fef3c7; color: #d97706; }
.coin-state-RUNNING { background: #dbeafe; color: #2563eb; }
.coin-state-COOLING { background: #f0fdf4; color: #16a34a; }
.coin-state-NORMAL  { background: #f1f5f9; color: #64748b; }
.coin-state-DEAD    { background: #fee2e2; color: #b91c1c; }

/* ── Chart containers ──────────────────────────────────── */
.chart-container { position: relative; }
.chart-container canvas { max-width: 100%; }

/* ── Page header ────────────────────────────────────────── */
.page-header {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 20px;
}
.page-header h4 {
  font-size: 20px;
  font-weight: 800;
  margin: 0;
  color: #0f172a;
}
.page-header .module-dot {
  width: 10px; height: 10px; border-radius: 50%;
  flex-shrink: 0;
}

/* ── Filters bar ────────────────────────────────────────── */
.filters-bar {
  display: flex; align-items: center; gap: 10px;
  flex-wrap: wrap;
  padding: 12px 0;
}
.filters-bar .form-control, .filters-bar .form-select {
  font-size: 13px;
  height: 34px;
  padding: 4px 10px;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
}
.filters-bar .btn {
  height: 34px;
  font-size: 13px;
  padding: 0 14px;
  border-radius: 8px;
}

/* ── Settings ────────────────────────────────────────────── */
.setting-row {
  display: flex; align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid #f1f5f9;
  gap: 12px;
}
.setting-row:last-child { border-bottom: none; }
.setting-key {
  font-family: 'Fira Code', 'JetBrains Mono', monospace;
  font-size: 12px;
  background: #f1f5f9;
  padding: 2px 8px;
  border-radius: 4px;
  color: #334155;
  flex-shrink: 0;
  min-width: 220px;
}
.setting-value {
  font-weight: 600;
  color: #0f172a;
  font-size: 13px;
}

/* ── Login page ─────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  background: linear-gradient(135deg, #1a2035 0%, #0f172a 100%);
  display: flex; align-items: center; justify-content: center;
}
.login-card {
  width: 100%; max-width: 380px;
  background: #fff;
  border-radius: 20px;
  padding: 40px 36px;
  box-shadow: 0 20px 60px rgba(0,0,0,.4);
}
.login-logo {
  width: 52px; height: 52px;
  background: linear-gradient(135deg, #3b82f6, #8b5cf6);
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 24px;
  margin: 0 auto 20px;
}
.login-card h4 {
  text-align: center;
  font-weight: 800;
  color: #0f172a;
  margin-bottom: 4px;
}
.login-card .sub {
  text-align: center;
  color: #94a3b8;
  font-size: 13px;
  margin-bottom: 28px;
}

/* ── Empty state ─────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: #94a3b8;
}
.empty-state i { font-size: 40px; margin-bottom: 12px; display: block; }
.empty-state p { margin: 0; font-size: 13px; }

/* ── Utility ─────────────────────────────────────────────── */
.text-mono { font-family: 'Fira Code', monospace; font-size: 12px; }
.text-win  { color: var(--color-win)  !important; }
.text-loss { color: var(--color-loss) !important; }
.fw-800 { font-weight: 800; }
.gap-1 { gap: 4px; }
.gap-2 { gap: 8px; }
.rounded-xl { border-radius: var(--card-radius) !important; }
.overflow-auto { overflow: auto; }

/* ── Responsive ─────────────────────────────────────────── */
@media (max-width: 991px) {
  .sidebar { transform: translateX(-100%); transition: transform .3s; }
  .sidebar.open { transform: translateX(0); }
  .topbar  { left: 0; }
  .main-content { margin-left: 0; }
}

/* ── Scrollbar ───────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ── Loading skeleton ─────────────────────────────────────── */
.skeleton {
  background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
  background-size: 200% 100%;
  animation: skeleton-loading 1.5s infinite;
  border-radius: 4px;
}
@keyframes skeleton-loading {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
