/* ================================================================
   POLYMARKET VOLUME TRACKER — CSS
   Dark trading-terminal aesthetic · S-tier edition
   ================================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

/* ---------- CSS Variables ---------- */
:root {
  --bg-0:     #0a0b0e;
  --bg-1:     #0f1117;
  --bg-2:     #161920;
  --bg-3:     #1e2128;
  --bg-4:     #252830;

  --border:   #2a2d38;
  --border-hi: #3a3d4a;

  --text-0:   #e8eaf0;
  --text-1:   #9da3b4;
  --text-2:   #636878;

  --accent:   #6c8ef5;
  --accent-2: #4f6ed4;

  --green:    #26d97f;
  --green-bg: rgba(38, 217, 127, 0.08);
  --red:      #ff4d6d;
  --red-bg:   rgba(255, 77, 109, 0.08);

  --yellow:   #f5c842;

  --radius:   8px;
  --radius-lg: 12px;
  --font:     'Inter', system-ui, sans-serif;
  --mono:     'JetBrains Mono', monospace;

  --shadow:   0 4px 24px rgba(0,0,0,0.6);
  --glow:     0 0 20px rgba(108,142,245,0.15);

  /* Ultrawide max-width constraint */
  --content-max: 1680px;
}

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

html, body {
  height: 100%;
  background: var(--bg-0);
  color: var(--text-0);
  font-family: var(--font);
  font-size: 13px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ---------- Layout ---------- */
#app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Content wrapper to constrain very-wide layouts */
.content-wrap {
  max-width: var(--content-max);
  width: 100%;
  margin: 0 auto;
  padding: 0 24px;
}

header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 24px;
  background: var(--bg-1);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

header .header-inner {
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: var(--content-max);
  width: 100%;
  margin: 0 auto;
}

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 15px;
  color: var(--text-0);
  letter-spacing: -0.3px;
}

.logo-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 10px var(--accent);
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.6; transform: scale(0.85); }
}

/* ---------- URL Input Bar ---------- */
#input-section {
  padding: 20px 0 0;
}

.input-row {
  display: flex;
  gap: 10px;
  align-items: center;
}

.url-input-wrapper {
  flex: 1;
  min-width: 0;
  position: relative;
}

.url-input-wrapper svg {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-2);
  pointer-events: none;
}

#url-input {
  width: 100%;
  padding: 10px 14px 10px 38px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-0);
  font-family: var(--mono);
  font-size: 12px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

#url-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(108,142,245,0.12);
}

#url-input::placeholder { color: var(--text-2); }

.btn-primary {
  padding: 10px 20px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border: none;
  border-radius: var(--radius);
  color: #fff;
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.15s;
  white-space: nowrap;
}

.btn-primary:hover { opacity: 0.88; transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }

/* ---------- Error / Status ---------- */
#status-bar {
  margin: 12px 0 0;
  padding: 8px 14px;
  border-radius: var(--radius);
  font-size: 12px;
  display: none;
}

#status-bar.error {
  display: block;
  background: var(--red-bg);
  border: 1px solid rgba(255,77,109,0.3);
  color: var(--red);
}

#status-bar.info {
  display: block;
  background: rgba(108,142,245,0.08);
  border: 1px solid rgba(108,142,245,0.25);
  color: var(--accent);
}

/* ---------- Event Info Banner ---------- */
#event-banner {
  margin: 16px 0 0;
  padding: 14px 18px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  display: none;
  background: linear-gradient(135deg, var(--bg-2) 0%, rgba(30,33,40,0.95) 100%);
  border-left: 3px solid var(--accent);
}

.event-meta {
  display: flex;
  align-items: center;
  gap: 14px;
}

/* Event image thumbnail box */
.event-image-box {
  width: 52px !important;
  height: 52px !important;
  min-width: 52px;
  max-width: 52px;
  max-height: 52px;
  background: #ffffff;
  border-radius: 10px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.35);
  flex-shrink: 0;
}

.event-image-box img {
  width: 52px;
  height: 52px;
  max-width: 52px;
  max-height: 52px;
  object-fit: contain;
  display: block;
}

/* Discipline / sport label above title */
.event-discipline {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-2);
}

.event-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-0);
  line-height: 1.3;
}

.event-subtitle {
  font-size: 11px;
  color: var(--text-2);
  margin-top: 3px;
}

/* ---------- Market Tabs ---------- */
#market-tabs-section {
  padding: 16px 0 0;
  display: none;
}

.market-header-row {
  display: flex;
  align-items: center;
  margin-bottom: 12px;
}

.tabs-header-group {
  display: flex;
  align-items: center;
  gap: 16px;
}

.tabs-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-2);
}

/* The Volume Readout Bubble */
#active-market-vol {
  display: none;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-1);
  background: var(--bg-2);
  padding: 4px 10px;
  border-radius: 12px;
  letter-spacing: 0.5px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.05);
  border: 1px solid var(--border);
  align-items: center;
  gap: 4px;
}
#active-market-vol span {
  color: var(--text-0);
}

.tabs-row {
  display: flex;
  gap: 6px;
  flex-wrap: nowrap;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: thin;
}
.tabs-row::-webkit-scrollbar { height: 4px; }

.tab-btn {
  white-space: nowrap;
  flex-shrink: 0;
  padding: 6px 14px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--bg-2);
  color: var(--text-1);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.tab-btn:hover {
  border-color: var(--border-hi);
  color: var(--text-0);
}

.tab-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}

/* ---------- Outcome Tabs ---------- */
#outcome-tabs-section {
  padding: 12px 0 0;
  display: none;
}

.outcome-tabs-row {
  display: flex;
  gap: 6px;
  flex-wrap: nowrap;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: thin;
}
.outcome-tabs-row::-webkit-scrollbar { height: 4px; }

.outcome-btn {
  white-space: nowrap;
  padding: 6px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-1);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  letter-spacing: 0.2px;
}

.outcome-btn:hover {
  border-color: var(--border-hi);
  color: var(--text-0);
  background: var(--bg-3);
}

/* Selected outcome: bright white pill with glow */
.outcome-btn.active {
  background: rgba(232, 234, 240, 0.12);
  border-color: rgba(232, 234, 240, 0.5);
  color: #ffffff;
  font-weight: 700;
  box-shadow: 0 0 12px rgba(232, 234, 240, 0.1), inset 0 0 0 1px rgba(255,255,255,0.08);
  text-shadow: 0 0 8px rgba(255,255,255,0.4);
}

/* Volume pill badge inside outcome button */
.outcome-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.outcome-vol-pill {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  background: rgba(108, 142, 245, 0.08);
  border: 1px solid rgba(108, 142, 245, 0.18);
  border-radius: 4px;
  padding: 1px 6px;
  line-height: 1.6;
  transition: all 0.2s;
}
.outcome-vol-label {
  font-family: var(--mono);
  font-size: 8px;
  font-weight: 600;
  letter-spacing: 0.6px;
  color: var(--text-2);
  text-transform: uppercase;
}
.outcome-vol-val {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 500;
  color: var(--accent);
}
.outcome-btn.active .outcome-vol-pill {
  background: rgba(108, 142, 245, 0.14);
  border-color: rgba(108, 142, 245, 0.35);
}
.outcome-btn.active .outcome-vol-label { color: var(--text-1); }
.outcome-btn.active .outcome-vol-val   { color: #a0b8ff; }

/* ---------- Filter Bar ---------- */
#filter-bar {
  display: none;
  padding: 10px 0 0;
}

#filter-bar .content-wrap {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.filter-label {
  font-size: 11px;
  color: var(--text-2);
  white-space: nowrap;
}

.filter-input, .filter-select {
  padding: 4px 9px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--text-0);
  font-family: var(--font);
  font-size: 11px;
  outline: none;
  transition: border-color 0.2s;
}

.filter-input:focus, .filter-select:focus {
  border-color: var(--accent);
}

.filter-input { width: 90px; }
.filter-select { width: 90px; }
.filter-select option { background: var(--bg-2); }

#apply-filter-btn {
  padding: 4px 12px;
  border-radius: 5px;
  font-size: 11px;
}

/* Hide number input arrows/spinners */
.filter-input[type=number]::-webkit-inner-spin-button, 
.filter-input[type=number]::-webkit-outer-spin-button { 
  -webkit-appearance: none; 
  margin: 0; 
}
.filter-input[type=number] {
  -moz-appearance: textfield;
  appearance: textfield;
}

/* Rounding select */
#round-select {
  padding: 5px 10px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-0);
  font-size: 12px;
  outline: none;
}

/* Timeframe buttons */
.tf-buttons {
  display: flex;
  gap: 4px;
}

.tf-btn {
  padding: 4px 9px;
  border-radius: 5px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-2);
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

.tf-btn:hover { color: var(--text-0); border-color: var(--border-hi); }
.tf-btn.active {
  background: var(--bg-3);
  border-color: var(--border-hi);
  color: var(--accent);
  font-weight: 700;
}

.divider-v {
  width: 1px;
  height: 20px;
  background: var(--border);
}

/* Format toggle button */
.format-toggle {
  padding: 4px 12px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--bg-2);
  color: var(--text-1);
  font-family: var(--font);
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}
.format-toggle:hover { border-color: var(--border-hi); color: var(--text-0); }
.format-toggle.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}

/* Inline select inside chart headers */
.chart-inline-select {
  padding: 3px 8px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--text-0);
  font-family: var(--mono);
  font-size: 11px;
  outline: none;
  cursor: pointer;
  transition: border-color 0.2s;
}
.chart-inline-select:focus { border-color: var(--accent); }

/* ---------- Charts Section ---------- */
#charts-section {
  padding: 16px 0;
  display: none;
}

#charts-section.visible {
  display: block;
}

#charts-section .content-wrap {
  display: flex;
  gap: 16px;
}

.chart-card {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  flex: 1;
  min-width: 0;
  /* subtle gradient top border */
  box-shadow:
    0 1px 0 0 rgba(108,142,245,0.15) inset,
    0 4px 24px rgba(0,0,0,0.4);
}

.chart-card:hover {
  border-color: var(--border-hi);
  transition: border-color 0.3s;
}

.chart-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(to bottom, rgba(255,255,255,0.02), transparent);
}

.chart-title {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-1);
}

.chart-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.chart-body {
  padding: 0;
  position: relative;
}

#vbp-chart   { height: 360px; }
#candle-chart { height: 360px; }

/* ---------- Loading Spinner ---------- */
.spinner-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10,11,14,0.7);
  z-index: 10;
  backdrop-filter: blur(2px);
}

.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Trading Log ---------- */
#log-section {
  padding: 0 0 32px;
  display: none;
}

#log-section .content-wrap {
  padding-bottom: 0;
}

.log-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-2);
}

#trade-count {
  font-size: 11px;
  color: var(--text-2);
  font-family: var(--mono);
}

.log-table-wrapper {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-1);
}

/* Fixed table layout prevents column shifting */
.log-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  table-layout: fixed;
}

/* Define fixed column widths so they never shift between modes */
.log-table th:nth-child(1),
.log-table td:nth-child(1) { width: 80px; }   /* Side */
.log-table th:nth-child(2),
.log-table td:nth-child(2) { width: 140px; }  /* Outcome */
.log-table th:nth-child(3),
.log-table td:nth-child(3) { width: 160px; }  /* Market */
.log-table th:nth-child(4),
.log-table td:nth-child(4) { width: 130px; }  /* Timestamp */
.log-table th:nth-child(5),
.log-table td:nth-child(5) { width: 110px; }  /* Wallet */
.log-table th:nth-child(6),
.log-table td:nth-child(6) { width: 180px; }  /* Size @ Price / Stake @ Odds */
.log-table th:nth-child(7),
.log-table td:nth-child(7) { width: 110px; }  /* Cost / Win */

.log-table thead th {
  padding: 9px 14px;
  text-align: left;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-2);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  position: sticky;
  top: 0;
  background: var(--bg-1);
  z-index: 1;
}

.log-table tbody tr {
  transition: background 0.12s;
}

.log-table tbody tr:hover {
  background: var(--bg-3);
}

.log-table tbody td {
  padding: 7px 14px;
  border-bottom: 1px solid rgba(42,45,56,0.5);
  vertical-align: middle;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.log-table tbody tr:last-child td {
  border-bottom: none;
}

/* Side badges */
.side-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.side-badge.buy  { background: var(--green-bg); color: var(--green); border: 1px solid rgba(38,217,127,0.25); }
.side-badge.sell { background: var(--red-bg);   color: var(--red);   border: 1px solid rgba(255,77,109,0.25); }

/* Mono values */
.mono { font-family: var(--mono); }

/* Links */
a.link {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid rgba(108,142,245,0.3);
  transition: color 0.15s, border-color 0.15s;
}

a.link:hover {
  color: #fff;
  border-color: rgba(108,142,245,0.7);
}

/* Truncate wallet */
.wallet-addr {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-1);
}

/* outcome cell */
.outcome-cell {
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- Empty state ---------- */
.empty-state {
  padding: 40px;
  text-align: center;
  color: var(--text-2);
  font-size: 13px;
}

/* ---------- Scrollbar Styling ---------- */
::-webkit-scrollbar        { width: 6px; height: 6px; }
::-webkit-scrollbar-track  { background: var(--bg-1); }
::-webkit-scrollbar-thumb  { background: var(--border-hi); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #4a4e5e; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  #charts-section .content-wrap { flex-direction: column; }
  .log-table { table-layout: auto; }
  .log-table th:nth-child(3),
  .log-table td:nth-child(3) { display: none; }  /* hide Market col on mobile */
}

/* ---------- Tooltip override for Plotly ---------- */
.plotly-notifier { display: none; }
