/* ===== CSS Variables: Dark Trading Theme ===== */
:root {
  --bg-primary: #0d0f14;
  --bg-secondary: #131722;
  --bg-card: #1a1e2e;
  --bg-hover: #222636;
  --border: #2a2d3d;
  --text-primary: #e2e8f0;
  --text-secondary: #8892a4;
  --text-muted: #4a5568;
  --accent: #6366f1;
  --accent-hover: #7c7ff7;
  --green: #22c55e;
  --green-dim: #16a34a;
  --red: #ef4444;
  --red-dim: #dc2626;
  --yellow: #f59e0b;
  --blue: #3b82f6;
  --purple: #a855f7;

  --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
  --sidebar-width: 220px;
}

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

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

#app {
  display: flex;
  min-height: 100vh;
}

/* ===== Sidebar ===== */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 20px 0;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 20px 24px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 12px;
}
.logo-icon { font-size: 22px; }
.logo-text { font-size: 18px; font-weight: 700; color: var(--accent); letter-spacing: 0.5px; }

.nav { flex: 1; padding: 0 8px; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius);
  color: var(--text-secondary);
  text-decoration: none;
  font-weight: 500;
  transition: all 0.15s;
  margin-bottom: 2px;
  position: relative;
}
.nav-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.nav-item.active { background: rgba(99, 102, 241, 0.15); color: var(--accent); }
.nav-icon { width: 20px; text-align: center; }

.badge {
  background: var(--red);
  color: white;
  font-size: 11px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 999px;
  margin-left: auto;
}

.bot-control {
  padding: 16px 12px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--border);
}
.user-icon { font-size: 14px; }
.user-name { font-size: 12px; font-weight: 600; color: var(--text-secondary); flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.btn-logout { background: none; border: 1px solid var(--border); color: var(--text-muted); border-radius: 6px; padding: 4px 8px; cursor: pointer; font-size: 13px; transition: all 0.15s; }
.btn-logout:hover { border-color: var(--red); color: var(--red); }
.bot-status {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: background 0.3s;
}
.bot-status.running { background: var(--green); box-shadow: 0 0 8px var(--green); }
.bot-status.paused { background: var(--yellow); }

/* ===== Main Content ===== */
.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  padding: 28px 32px;
  overflow-y: auto;
}

/* ===== Page Header ===== */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
}
.page-title { font-size: 22px; font-weight: 700; }
.page-subtitle { color: var(--text-secondary); font-size: 13px; margin-top: 2px; }

/* ===== Cards ===== */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow);
}

.card-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-bottom: 8px;
}

/* ===== KPI Grid ===== */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
}
.kpi-label { font-size: 12px; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.7px; }
.kpi-value {
  font-size: 26px;
  font-weight: 700;
  margin-top: 4px;
  color: var(--text-primary);
}
.kpi-value.positive { color: var(--green); }
.kpi-value.negative { color: var(--red); }
.kpi-change { font-size: 12px; color: var(--text-secondary); margin-top: 4px; }

/* ===== Grid Layouts ===== */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }

/* ===== Tables ===== */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead th {
  padding: 10px 14px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.7px;
  border-bottom: 1px solid var(--border);
}
tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}
tbody tr:hover { background: var(--bg-hover); }
tbody tr:last-child { border-bottom: none; }
td {
  padding: 12px 14px;
  font-size: 13px;
  color: var(--text-primary);
}
td.muted { color: var(--text-secondary); }
td.mono { font-family: monospace; font-size: 12px; }
.td-green { color: var(--green); font-weight: 600; }
.td-red { color: var(--red); font-weight: 600; }
.td-yellow { color: var(--yellow); }

/* ===== Buttons ===== */
.btn {
  padding: 8px 16px;
  border-radius: var(--radius);
  border: none;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.btn-primary { background: var(--accent); color: white; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-start { background: var(--green-dim); color: white; flex: 1; justify-content: center; font-size: 12px; }
.btn-start:hover { background: var(--green); }
.btn-stop { background: var(--red-dim); color: white; flex: 1; justify-content: center; font-size: 12px; }
.btn-stop:hover { background: var(--red); }
.btn-ghost { background: transparent; color: var(--text-secondary); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--bg-hover); color: var(--text-primary); }
.btn-danger { background: transparent; color: var(--red); border: 1px solid var(--red-dim); }
.btn-danger:hover { background: rgba(239, 68, 68, 0.1); }
.btn-sm { padding: 5px 10px; font-size: 12px; }

/* ===== Inputs ===== */
.input-group { margin-bottom: 14px; }
.input-label { font-size: 12px; font-weight: 600; color: var(--text-secondary); margin-bottom: 6px; display: block; }
input, select, textarea {
  width: 100%;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  padding: 9px 12px;
  font-size: 13px;
  font-family: var(--font);
  transition: border-color 0.15s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
}
input[type="password"] { letter-spacing: 2px; }

/* ===== Tags / Badges ===== */
.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
}
.tag-green { background: rgba(34, 197, 94, 0.15); color: var(--green); }
.tag-red { background: rgba(239, 68, 68, 0.15); color: var(--red); }
.tag-yellow { background: rgba(245, 158, 11, 0.15); color: var(--yellow); }
.tag-blue { background: rgba(59, 130, 246, 0.15); color: var(--blue); }
.tag-purple { background: rgba(168, 85, 247, 0.15); color: var(--purple); }
.tag-gray { background: rgba(74, 85, 104, 0.2); color: var(--text-secondary); }

/* ===== Chart Container ===== */
.chart-container {
  width: 100%;
  height: 280px;
  border-radius: var(--radius);
  overflow: hidden;
  margin-top: 12px;
}

/* ===== Alert Items ===== */
.alert-item {
  display: flex;
  gap: 12px;
  padding: 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  margin-bottom: 10px;
  background: var(--bg-card);
  transition: background 0.15s;
}
.alert-item:hover { background: var(--bg-hover); }
.alert-item.unread { border-left: 3px solid var(--accent); }
.alert-icon { font-size: 18px; }
.alert-body { flex: 1; }
.alert-title { font-weight: 600; margin-bottom: 2px; }
.alert-message { color: var(--text-secondary); font-size: 13px; }
.alert-time { font-size: 11px; color: var(--text-muted); margin-top: 4px; }

/* ===== Wallet Cards ===== */
.wallet-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
  background: var(--bg-card);
  margin-bottom: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.wallet-card.active { border-color: var(--accent); background: rgba(99, 102, 241, 0.05); }
.wallet-address { font-family: monospace; font-size: 13px; color: var(--text-secondary); }
.wallet-balance { font-size: 20px; font-weight: 700; color: var(--green); }
.wallet-actions { display: flex; gap: 8px; }

/* ===== Modal ===== */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  width: 440px;
  max-width: 95vw;
}
.modal-title { font-size: 18px; font-weight: 700; margin-bottom: 20px; }
.modal-actions { display: flex; gap: 10px; margin-top: 20px; justify-content: flex-end; }

/* ===== Misc ===== */
.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-muted);
}
.empty-state-icon { font-size: 40px; margin-bottom: 12px; }
.loading { color: var(--text-muted); font-size: 13px; padding: 20px; }

.section-gap { margin-bottom: 24px; }

.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.mt-16 { margin-top: 16px; }
.mb-16 { margin-bottom: 16px; }

/* Toast notifications */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  padding: 12px 18px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  animation: slideIn 0.2s ease;
  max-width: 340px;
}
.toast-success { background: rgba(34, 197, 94, 0.2); border: 1px solid var(--green); color: var(--green); }
.toast-error { background: rgba(239, 68, 68, 0.2); border: 1px solid var(--red); color: var(--red); }
.toast-info { background: rgba(99, 102, 241, 0.2); border: 1px solid var(--accent); color: var(--accent); }

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

/* Responsive */
@media (max-width: 900px) {
  .sidebar { width: 60px; }
  .logo-text, .nav-item span:last-child { display: none; }
  .main-content { margin-left: 60px; padding: 20px 16px; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .grid-2 { grid-template-columns: 1fr; }
}

/* ===== Tab Buttons ===== */
.tab-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.2s;
  font-family: var(--font);
}
.tab-btn:hover { color: var(--text-secondary); }
.tab-btn.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}
