/* ============================================================
   ArbitrageBot — modern dark-fintech theme
   Loaded AFTER Bootstrap + inline styles, so it overrides them.
   ============================================================ */
:root {
  --bg-0:#0b1020;
  --bg-1:#0f172a;
  --bg-2:#151f38;
  --panel:#111a30;
  --panel-2:#0e1729;
  --border:#233150;
  --text:#e6ecf7;
  --muted:#93a2c0;
  --brand:#6366f1;
  --brand-2:#8b5cf6;
  --accent:#22d3ee;
  --green:#10b981;
  --red:#ef4444;
  --shadow:0 10px 30px rgba(0,0,0,.35);
  --radius:16px;
}

* { box-sizing:border-box; }

html,body { height:100%; }
/* Auto-scroll fix (browser-verified repro 2026-10-25): Bootstrap 5.1's
   media-query sets :root{scroll-behavior:smooth}, which made every anchor
   click AND hash-reload animate the whole page for ~1s+ - read by users as
   "the page scrolls itself". Kill it; instant jumps are stable. */
html { scroll-behavior:auto !important; }
/* Live numbers changed width on every poll tick (CLS 0.033, hero shifted
   44px): tabular figures keep every digit the same width so updates can't
   reflow the layout under the reader. */
body { font-variant-numeric: tabular-nums; }
body {
  margin:0;
  font-family:'Inter',system-ui,-apple-system,Segoe UI,Roboto,sans-serif !important;
  color:var(--text);
  background:
    radial-gradient(1200px 600px at 100% -10%, rgba(99,102,241,.18), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, rgba(34,211,238,.12), transparent 60%),
    linear-gradient(180deg,var(--bg-0),var(--bg-1)) !important;
  background-attachment:fixed;
  -webkit-font-smoothing:antialiased;
  letter-spacing:.1px;
}

h1,h2,h3,h4,h5,h6 { color:var(--text); font-weight:700; }
a { color:var(--accent); text-decoration:none; }
a:hover { color:#7dd3fc; }
.text-muted { color:var(--muted) !important; }
small.text-muted { color:var(--muted) !important; }

/* ---------- Sidebar ---------- */
.sidebar {
  background:linear-gradient(180deg,#0d1428 0%,#0a1122 100%) !important;
  border-right:1px solid var(--border);
  min-height:100vh;
}
.sidebar h4 { color:#fff; font-weight:800; letter-spacing:.3px; }
.sidebar h4 .bi { color:var(--brand); margin-right:6px; }
.sidebar .nav-link {
  color:#c7d2e8; padding:11px 14px; margin:3px 4px; border-radius:10px;
  display:flex; align-items:center; gap:10px; font-weight:500;
  transition:background .18s ease,color .18s ease,transform .18s ease;
}
.sidebar .nav-link .bi { font-size:1.05rem; width:20px; text-align:center; opacity:.85; }
.sidebar .nav-link:hover { background:rgba(99,102,241,.14); color:#fff; transform:translateX(2px); }
.sidebar .nav-link.active {
  background:linear-gradient(90deg,rgba(99,102,241,.35),rgba(139,92,246,.18));
  color:#fff; box-shadow:inset 0 0 0 1px rgba(139,92,246,.35);
}
.sidebar hr { border-color:rgba(255,255,255,.12); margin:12px 0; }

/* ---------- Cards ---------- */
.card {
  background:linear-gradient(180deg,var(--panel),var(--panel-2)) !important;
  border:1px solid var(--border) !important;
  border-radius:var(--radius) !important;
  box-shadow:var(--shadow);
  color:var(--text);
}
.card .card-body { color:var(--text); }
.card-header {
  background:transparent !important; border-bottom:1px solid var(--border) !important;
  font-weight:700; color:var(--text);
}
.stat-card {
  background:linear-gradient(180deg,var(--panel),var(--panel-2)) !important;
  border:1px solid var(--border) !important; border-radius:var(--radius);
  box-shadow:var(--shadow); padding:20px; transition:transform .2s ease,box-shadow .2s ease;
}
.stat-card:hover { transform:translateY(-4px); box-shadow:0 16px 40px rgba(0,0,0,.45); }
.stat-card .label { color:var(--muted); font-size:.8rem; text-transform:uppercase; letter-spacing:.6px; }
.stat-card .value { font-size:1.6rem; font-weight:800; }
.opportunity-card {
  border:1px solid var(--border) !important; border-left:4px solid var(--green) !important;
  background:linear-gradient(180deg,#0e2018,#0b1712) !important; border-radius:12px;
  color:#d1fae5; padding:16px; box-shadow:var(--shadow);
}

/* ---------- Buttons ---------- */
.btn { border-radius:10px; font-weight:600; padding:.55rem 1.05rem; transition:transform .12s ease,box-shadow .2s ease,filter .2s; }
.btn:active { transform:translateY(1px); }
.btn-lg { border-radius:12px; }
.btn-primary {
  background:linear-gradient(90deg,var(--brand),var(--brand-2)) !important;
  border:none !important; box-shadow:0 8px 20px rgba(99,102,241,.35);
}
.btn-primary:hover { filter:brightness(1.08); box-shadow:0 10px 26px rgba(99,102,241,.5); }
.btn-success { background:linear-gradient(90deg,#059669,var(--green)) !important; border:none !important; }
.btn-danger { background:linear-gradient(90deg,#dc2626,var(--red)) !important; border:none !important; }
.btn-secondary,.btn-outline-secondary {
  background:#1b2743 !important; color:#c7d2e8 !important; border:1px solid var(--border) !important;
}
.btn-outline-primary { color:var(--brand) !important; border:1px solid var(--brand) !important; }
.btn-outline-primary:hover { background:var(--brand) !important; color:#fff !important; }
.btn-close { filter:invert(1) grayscale(1) brightness(1.6); }

/* ---------- Forms ---------- */
.form-control,.form-select,input,textarea {
  background:#0c1526 !important; border:1px solid var(--border) !important;
  color:var(--text) !important; border-radius:10px; padding:.6rem .85rem;
}
.form-control:focus,.form-select:focus,input:focus,textarea:focus {
  background:#0c1526 !important; color:var(--text) !important;
  border-color:var(--brand) !important;
  box-shadow:0 0 0 .2rem rgba(99,102,241,.25) !important;
}
.form-label { color:var(--muted); font-weight:600; font-size:.85rem; }
::placeholder { color:#5f6f8f !important; }

/* ---------- Tables ---------- */
.table { color:var(--text) !important; }
.table thead th {
  background:#0c1526 !important; color:var(--muted) !important;
  text-transform:uppercase; font-size:.75rem; letter-spacing:.6px; border-bottom:1px solid var(--border) !important;
}
.table tbody tr { border-bottom:1px solid rgba(35,49,80,.6); }
.table tbody tr:hover { background:rgba(99,102,241,.06); }
.table-striped tbody tr:nth-of-type(odd) { background:rgba(255,255,255,.02); }
.table>:not(caption)>*>* { background:transparent !important; color:var(--text); }

/* ---------- Alerts / badges ---------- */
.alert { border:1px solid var(--border); border-radius:12px; color:var(--text); background:#12203a; }
.alert-success { background:rgba(16,185,129,.12); border-color:rgba(16,185,129,.4); color:#a7f3d0; }
.alert-danger { background:rgba(239,68,68,.12); border-color:rgba(239,68,68,.4); color:#fecaca; }
.alert-warning { background:rgba(245,158,11,.12); border-color:rgba(245,158,11,.4); color:#fde68a; }
.alert-info { background:rgba(34,211,238,.12); border-color:rgba(34,211,238,.4); color:#bae6fd; }
.badge { border-radius:8px; font-weight:600; padding:.4em .6em; }
.bg-success { background:var(--green) !important; }
.bg-danger { background:var(--red) !important; }
.text-success { color:#34d399 !important; }
.text-danger { color:#f87171 !important; }
.text-primary { color:#a5b4fc !important; }
.profit-positive { color:#34d399 !important; font-weight:700; }
.profit-negative { color:#f87171 !important; font-weight:700; }

/* ---------- Code / lists ---------- */
code { color:#7dd3fc; background:rgba(34,211,238,.08); padding:.1em .35em; border-radius:6px; }
.list-group-item { background:var(--panel) !important; color:var(--text) !important; border-color:var(--border) !important; }

/* ---------- Logged-out auth pages (login/setup): center as a hero card ---------- */
body:not(.authed) .container { max-width:640px; padding-top:6vh; }

/* ---------- Floating theme toggle ---------- */
.theme-toggle {
  position:fixed; right:18px; bottom:18px; z-index:1050;
  width:44px; height:44px; border-radius:50%; border:1px solid var(--border);
  background:linear-gradient(180deg,var(--brand),var(--brand-2)); color:#fff;
  box-shadow:var(--shadow); display:flex; align-items:center; justify-content:center; cursor:pointer;
}
.theme-toggle:hover { filter:brightness(1.1); }

/* ---------- Scrollbar ---------- */
::-webkit-scrollbar { width:10px; height:10px; }
::-webkit-scrollbar-thumb { background:#263352; border-radius:8px; }
::-webkit-scrollbar-track { background:transparent; }

/* ---------- Mobile ---------- */
@media (max-width: 767px) {
  .sidebar { min-height:auto; }
  .container-fluid > .row { flex-direction:column; }
}

/* ============================================================
   THEME PALETTES
   Switched via <html data-theme="...">. Because almost every rule
   above reads these custom properties, redefining them re-skins the
   entire app (sidebar, cards, inputs, tables, buttons) at once.
   The user's choice is stored in localStorage; the admin's default
   theme is the server-provided fallback (see theme.js + base.html).
   ============================================================ */
html[data-theme="midnight"]{ --bg-0:#0b1020; --bg-1:#0f172a; --bg-2:#151f38; --panel:#111a30; --panel-2:#0e1729; --border:#233150; --text:#e6ecf7; --muted:#93a2c0; --brand:#6366f1; --brand-2:#8b5cf6; --accent:#22d3ee; }

html[data-theme="obsidian"]{ --bg-0:#000000; --bg-1:#05070b; --bg-2:#0a0e14; --panel:#0a0e14; --panel-2:#070a10; --border:#1c2433; --text:#e6ecf7; --muted:#8391ad; --brand:#22d3ee; --brand-2:#0ea5b7; --accent:#67e8f9; }

html[data-theme="emerald"]{ --bg-0:#041410; --bg-1:#081915; --bg-2:#0d251f; --panel:#0c211b; --panel-2:#081b16; --border:#1c3a30; --text:#e7f6ef; --muted:#8fb4a6; --brand:#10b981; --brand-2:#34d399; --accent:#6ee7b7; }

html[data-theme="violet"]{ --bg-0:#0c0718; --bg-1:#120a24; --bg-2:#1a0f34; --panel:#150c28; --panel-2:#100921; --border:#2c1d4d; --text:#efeafe; --muted:#a893cc; --brand:#8b5cf6; --brand-2:#a855f7; --accent:#c4b5fd; }

html[data-theme="sunset"]{ --bg-0:#180a08; --bg-1:#1f0e0b; --bg-2:#2a1410; --panel:#221009; --panel-2:#1a0c08; --border:#46231b; --text:#fdeee7; --muted:#cf9f8a; --brand:#f59e0b; --brand-2:#ef4444; --accent:#fb923c; }

/* Daylight = true light mode. Vars flip text/bg, plus a few component
   rules use literal dark hex above, so override those too. */
html[data-theme="daylight"]{
  --bg-0:#eef2f9; --bg-1:#e6ebf5; --bg-2:#dfe6f2; --panel:#ffffff; --panel-2:#f6f8fc; --border:#d3dbea;
  --text:#0f1a2e; --muted:#5b6a86; --brand:#4f46e5; --brand-2:#7c3aed; --accent:#0891b2; --shadow:0 10px 30px rgba(20,30,60,.12);
}
html[data-theme="daylight"] body{
  background:radial-gradient(1200px 600px at 100% -10%, rgba(79,70,229,.10), transparent 60%),
             radial-gradient(900px 500px at -10% 110%, rgba(8,145,178,.10), transparent 60%),
             linear-gradient(180deg,var(--bg-0),var(--bg-1)) !important; color:var(--text);
}
html[data-theme="daylight"] .sidebar{ background:linear-gradient(180deg,#ffffff 0%,#eef2f9 100%) !important; border-right:1px solid var(--border); }
html[data-theme="daylight"] .sidebar h4{ color:#0f1a2e; }
html[data-theme="daylight"] .sidebar .nav-link{ color:#33415c; }
html[data-theme="daylight"] .sidebar .nav-link:hover{ background:rgba(79,70,229,.10); color:#0f1a2e; }
html[data-theme="daylight"] .sidebar .nav-link.active{ background:linear-gradient(90deg,rgba(79,70,229,.18),rgba(124,58,237,.10)); color:#0f1a2e; box-shadow:inset 0 0 0 1px rgba(124,58,237,.25); }
html[data-theme="daylight"] .sidebar hr{ border-color:rgba(15,26,46,.12); }
html[data-theme="daylight"] .form-control,html[data-theme="daylight"] .form-select,html[data-theme="daylight"] input,html[data-theme="daylight"] textarea{ background:#ffffff !important; color:var(--text) !important; }
html[data-theme="daylight"] .form-control:focus,html[data-theme="daylight"] .form-select:focus,html[data-theme="daylight"] input:focus,html[data-theme="daylight"] textarea:focus{ background:#ffffff !important; color:var(--text) !important; }
html[data-theme="daylight"] ::placeholder{ color:#9aa8c2 !important; }
html[data-theme="daylight"] .table thead th{ background:#f2f5fb !important; color:var(--muted) !important; }
html[data-theme="daylight"] .btn-secondary,html[data-theme="daylight"] .btn-outline-secondary{ background:#eef2f9 !important; color:#33415c !important; }
html[data-theme="daylight"] .btn-close{ filter:none; }
html[data-theme="daylight"] .alert{ background:#ffffff; }
html[data-theme="daylight"] .list-group-item{ background:var(--panel) !important; }
html[data-theme="daylight"] ::-webkit-scrollbar-thumb{ background:#c3ccdd; }

/* ---------- Theme picker (floating) ---------- */
.theme-picker{ position:fixed; right:18px; bottom:18px; z-index:1060; display:flex; flex-direction:column; align-items:flex-end; gap:8px; }
.theme-picker .tp-main{ width:46px; height:46px; border-radius:50%; border:1px solid var(--border); background:linear-gradient(180deg,var(--brand),var(--brand-2)); color:#fff; box-shadow:var(--shadow); display:flex; align-items:center; justify-content:center; cursor:pointer; font-size:1.15rem; }
.theme-picker .tp-main:hover{ filter:brightness(1.1); }
.theme-picker .tp-swatches{ display:none; flex-direction:column; gap:8px; padding:10px; background:var(--panel); border:1px solid var(--border); border-radius:14px; box-shadow:var(--shadow); }
.theme-picker.open .tp-swatches{ display:flex; }
.theme-picker .tp-sw{ width:40px; height:30px; border-radius:8px; border:1px solid var(--border); cursor:pointer; position:relative; padding:0; }
.theme-picker .tp-sw[aria-pressed="true"]{ outline:2px solid var(--accent); outline-offset:2px; }
.theme-picker .tp-sw span{ position:absolute; left:46px; top:50%; transform:translateY(-50%); white-space:nowrap; font-size:.72rem; color:var(--muted); background:var(--panel); padding:2px 6px; border-radius:6px; opacity:0; pointer-events:none; transition:opacity .15s; }
.theme-picker .tp-sw:hover span{ opacity:1; }
@media (prefers-reduced-motion:reduce){ .theme-picker .tp-sw{ transition:none; } }
