/* =========================================================
   Bot Dashboard — stylesheet (light / trading-desk theme)
   ========================================================= */

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

:root {
  --bg:           #ffffff;
  --surface:      #f6f8fa;
  --surface2:     #eef1f4;
  --border:       #d0d7de;
  --text:         #1f2328;
  --text-muted:   #656d76;
  --accent:       #0969da;
  --accent-hover: #0550ae;
  --green:        #1a7f37;
  --green-bg:     #dafbe1;
  --red:          #cf222e;
  --red-bg:       #ffebe9;
  --yellow:       #9a6700;
  --radius:       6px;
  --font:         'Segoe UI', system-ui, -apple-system, sans-serif;
  --font-mono:    'Cascadia Code', 'Fira Code', 'Consolas', monospace;
  --shadow:       0 1px 3px rgba(31,35,40,.12), 0 2px 6px rgba(31,35,40,.06);
}

html { font-size: 15px; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  line-height: 1.5;
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: underline; }

/* ---- Top bar ---- */
.topbar {
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding: 0 1.5rem;
  height: 52px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 0 var(--border);
}
.topbar-title {
  font-weight: 700;
  font-size: 1rem;
  color: var(--text);
  letter-spacing: -0.01em;
}
.topbar-right {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  font-size: 0.85rem;
}
.topbar-user  { color: var(--text-muted); }
.topbar-nav a { color: var(--text-muted); font-weight: 500; }
.topbar-nav a:hover { color: var(--accent); text-decoration: none; }
.logout-link  { color: var(--red) !important; }
.logout-link:hover { opacity: 0.8; }

/* ---- Container ---- */
.container {
  max-width: 1140px;
  margin: 0 auto;
  padding: 1.75rem 1.25rem 3rem;
}

/* ---- Section headers ---- */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}
h2 {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.ts {
  font-size: 0.78rem;
  color: var(--text-muted);
}

section { margin-bottom: 2.5rem; }

/* ---- Card wrapper ---- */
.card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

/* ---- Tables ---- */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}
thead th {
  background: var(--surface);
  text-align: left;
  padding: 0.55rem 1rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--border);
}
tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background 0.08s;
}
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--surface); }
tbody td { padding: 0.6rem 1rem; vertical-align: middle; }

.bot-name {
  font-weight: 600;
  font-size: 0.9rem;
  letter-spacing: 0.02em;
}

/* ---- Badges ---- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.2rem 0.6rem;
  border-radius: 99px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.badge::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  display: inline-block;
}
.badge-run  {
  background: var(--green-bg);
  color: var(--green);
}
.badge-run::before  { background: var(--green); }
.badge-stop {
  background: var(--red-bg);
  color: var(--red);
}
.badge-stop::before { background: var(--red); }

/* ---- Action buttons ---- */
.actions-cell { display: flex; align-items: center; gap: 0.4rem; }

.btn {
  display: inline-block;
  padding: 0.25rem 0.7rem;
  font-size: 0.8rem;
  font-weight: 500;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  transition: opacity 0.12s, background 0.12s;
  line-height: 1.4;
  text-decoration: none;
}
.btn:hover { opacity: 0.82; text-decoration: none; }
.btn:active { opacity: 0.65; }

.btn-primary  { background: var(--accent);  color: #fff; border-color: var(--accent); }
.btn-danger   { background: var(--red);     color: #fff; border-color: var(--red); }
.btn-ghost    { background: transparent;    color: var(--text-muted); border-color: var(--border); }
.btn-ghost:hover { background: var(--surface2); color: var(--text); }

/* Action message (brief inline feedback) */
.action-msg {
  font-size: 0.78rem;
  min-width: 60px;
}
.action-ok  { color: var(--green); }
.action-err { color: var(--red); }

/* ---- Log age / small text ---- */
.log-age { color: var(--text-muted); font-size: 0.83rem; font-variant-numeric: tabular-nums; }

/* ---- System health ---- */
.health-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
}
.health-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  box-shadow: var(--shadow);
}
.health-label {
  font-size: 0.74rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 0.25rem;
}
.health-value {
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  color: var(--text);
}
.health-value small {
  font-size: 0.76rem;
  font-weight: 400;
  color: var(--text-muted);
}
.health-bar {
  height: 4px;
  background: var(--surface2);
  border-radius: 99px;
  overflow: hidden;
}
.health-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 99px;
  transition: width 0.4s ease;
  max-width: 100%;
}

/* ---- Log viewer ---- */
.log-controls {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 0.5rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}
.log-controls label { display: flex; align-items: center; gap: 0.3rem; cursor: pointer; }

.log-box {
  background: #1e1e2e;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.8rem 1rem;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  line-height: 1.55;
  color: #cdd6f4;
  white-space: pre-wrap;
  word-break: break-all;
  height: 70vh;
  overflow-y: auto;
  overflow-x: hidden;
}
.log-box .line-err  { color: #f38ba8; }
.log-box .line-warn { color: #fab387; }
.log-box .line-info { color: #cdd6f4; }
.log-box .line-dbg  { color: #6c7086; }

/* ---- Trades table ---- */
.trades-table { font-size: 0.85rem; }
.trade-count  { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 0.75rem; }
.empty-msg    { color: var(--text-muted); font-style: italic; }
.mono   { font-family: var(--font-mono); font-size: 0.82rem; }
.small  { font-size: 0.8rem; color: var(--text-muted); }

.pos     { color: var(--green); font-weight: 700; }
.neg     { color: var(--red);   font-weight: 700; }
.neutral { color: var(--yellow); }
.side-long  { color: var(--green); font-weight: 600; }
.side-short { color: var(--red);   font-weight: 600; }

/* ---- Footer ---- */
.footer-links { margin-top: 1rem; font-size: 0.88rem; }

/* ---- Login page ---- */
.login-body {
  background: var(--surface);
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
}
.login-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 2.5rem 2rem;
  text-align: center;
  width: 360px;
  box-shadow: var(--shadow);
}
.login-card h1 { font-size: 1.35rem; font-weight: 700; margin-bottom: 0.3rem; }
.subtitle { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 2rem; }
.hint     { font-size: 0.78rem; color: var(--text-muted); margin-top: 1.2rem; }

.form-group { text-align: left; margin-bottom: 1rem; }
.form-group label {
  display: block;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 0.3rem;
}
.form-group input {
  width: 100%;
  padding: 0.55rem 0.75rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.95rem;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.form-group input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(9,105,218,.12);
}
.submit-btn {
  width: 100%;
  padding: 0.65rem;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  font-size: 0.95rem;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: opacity 0.15s;
  margin-top: 0.5rem;
}
.submit-btn:hover { opacity: 0.88; }
.login-error {
  background: var(--red-bg);
  border: 1px solid #ffa198;
  border-radius: var(--radius);
  color: var(--red);
  padding: 0.5rem 0.75rem;
  font-size: 0.85rem;
  margin-bottom: 1rem;
  text-align: left;
}

/* ---- Responsive ---- */
@media (max-width: 640px) {
  .topbar { padding: 0 0.75rem; }
  .topbar-nav { display: none; }
  .health-grid { grid-template-columns: 1fr 1fr; }
  .log-box { height: 60vh; font-size: 0.72rem; }
  .actions-cell { flex-wrap: wrap; }
}

/* ---- Bot performance panel ---- */
.perf-table { font-size: 0.86rem; }

.perf-badge {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  border-radius: 99px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.03em;
}
.perf-ready   { background: var(--green-bg); color: var(--green); }
.perf-testing { background: var(--red-bg);   color: var(--red); }

/* ---- Exit reason badges ---- */
.reason-badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  white-space: nowrap;
}
.reason-tp    { background: #ddf4ff; color: #0969da; }
.reason-sl    { background: var(--red-bg); color: var(--red); }
.reason-trail { background: #fff3cd; color: #9a6700; }
.reason-time  { background: var(--surface2); color: var(--text-muted); }
.reason-other { background: var(--surface2); color: var(--text-muted); }

/* ---- Monospace log viewer ---- */
.log-container {
  background: #ffffff;
  font-family: monospace;
  font-size: 13px;
  line-height: 1.45;
  padding: 10px 14px;
  height: 600px;
  overflow-y: auto;
  border: 1px solid #ddd;
  border-radius: 6px;
  white-space: pre-wrap;
  word-break: break-all;
}

/* ---- Command Tools button row ---- */
.cmd-buttons {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

/* ---- Command input row ---- */
.cmd-input-row {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}
.cmd-input {
  flex: 1;
  font-family: monospace;
  font-size: 13px;
  padding: 8px 10px;
  border: 1px solid #ddd;
  border-radius: 6px;
  outline: none;
}
.cmd-input:focus {
  border-color: #0969da;
  box-shadow: 0 0 0 3px rgba(9,105,218,0.1);
}
.cmd-output-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin: 0 0 6px;
}
