/* Polymarket Portal — custom CSS (HL-inspired) */
/* Tailwind handles most; this is surgical overrides + animations */

/* ===== Scrollbars ===== */
* { scrollbar-width: thin; scrollbar-color: #2a2a32 #0a0a0a; }
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-track { background: #0a0a0a; }
*::-webkit-scrollbar-thumb { background: #2a2a32; border-radius: 4px; }
*::-webkit-scrollbar-thumb:hover { background: #3a3a44; }

/* ===== Typography baseline ===== */
body { font-feature-settings: "ss01","cv01","tnum"; }

/* ===== Focus ===== */
button:focus-visible, a:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid #00ff88;
  outline-offset: 2px;
  border-radius: 2px;
}

/* ===== Cards ===== */
.card {
  background: #111113;
  border: 1px solid #27272e;
  border-radius: 6px;
  overflow: hidden;
}
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 12px;
  border-bottom: 1px solid #1e1e24;
  background: #0e0e11;
}
.card-head--tabs { padding: 0 8px; gap: 0; }
.card-title { font-size: 12px; font-weight: 600; color: #e4e4e7; letter-spacing: 0.03em; text-transform: uppercase; }

/* ===== Header stat pills ===== */
.stat { display: flex; flex-direction: column; line-height: 1.1; }
.stat-label { font-size: 9px; color: #7a7a85; text-transform: uppercase; letter-spacing: 0.08em; }
.stat-val { font-size: 13px; color: #e4e4e7; }

/* ===== Tables ===== */
.poly-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.poly-table thead th {
  text-align: right;
  padding: 6px 8px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #7a7a85;
  font-weight: 500;
  background: #0e0e11;
  border-bottom: 1px solid #1e1e24;
  white-space: nowrap;
}
.poly-table thead th.text-left { text-align: left; }
.poly-table tbody td {
  padding: 4px 8px;
  border-bottom: 1px solid #16161a;
  white-space: nowrap;
  vertical-align: middle;
  text-align: right;
}
.poly-table tbody td.text-left { text-align: left; }
.poly-table tbody td.text-center { text-align: center; }
.poly-table--compact tbody td { padding: 3px 8px; font-size: 11px; }

.row-main { cursor: pointer; transition: background-color 60ms ease; }
.row-main:hover { background: #16161a; }
.row-main--open { background: #1a1a20; }
.row-expand { background: #0d0d10; }
.row-expand td { border-bottom: 1px solid #1e1e24; }

/* ===== Pills ===== */
.pill {
  display: inline-block;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 3px;
  letter-spacing: 0.04em;
}
.pill--yes  { background: rgba(0,255,136,0.12); color: #00ff88; border: 1px solid rgba(0,255,136,0.25); }
.pill--no   { background: rgba(255,77,77,0.12); color: #ff4d4d; border: 1px solid rgba(255,77,77,0.25); }
.pill--tiny { font-size: 9px; padding: 0 4px; }

.pill--status { background: #1e1e24; color: #a1a1aa; border: 1px solid #27272e; }
.pill--candidate { background: rgba(255,176,32,0.12); color: #ffb020; border-color: rgba(255,176,32,0.3); }
.pill--confirmed { background: rgba(0,255,136,0.12); color: #00ff88; border-color: rgba(0,255,136,0.3); }
.pill--blocked   { background: rgba(255,77,77,0.12); color: #ff4d4d; border-color: rgba(255,77,77,0.3); }
.pill--placed    { background: rgba(88,166,255,0.12); color: #58a6ff; border-color: rgba(88,166,255,0.3); }
.pill--skipped   { background: #1e1e24; color: #7a7a85; border-color: #27272e; }

.pill--fill { background: rgba(0,255,136,0.12); color: #00ff88; border: 1px solid rgba(0,255,136,0.25); }
.pill--exit { background: rgba(88,166,255,0.12); color: #58a6ff; border: 1px solid rgba(88,166,255,0.25); }
.pill--alert{ background: rgba(255,176,32,0.12); color: #ffb020; border: 1px solid rgba(255,176,32,0.25); }
.pill--error{ background: rgba(255,77,77,0.12); color: #ff4d4d; border: 1px solid rgba(255,77,77,0.25); }
.pill--info { background: #1e1e24; color: #a1a1aa; border: 1px solid #27272e; }

/* ===== Buttons ===== */
.btn-x {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 3px;
  border: 1px solid #27272e;
  background: #16161a;
  color: #e4e4e7;
  cursor: pointer;
  transition: background-color 60ms, border-color 60ms;
  margin-left: 4px;
}
.btn-x:hover:not(:disabled) { background: #1e1e24; border-color: #33333c; }
.btn-x:disabled { opacity: 0.3; cursor: not-allowed; }
.btn-x--danger { color: #ff4d4d; border-color: rgba(255,77,77,0.3); }
.btn-x--danger:hover { background: rgba(255,77,77,0.08); }

/* ===== Status dot ===== */
.status-dot {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  background: #3a3a44; flex-shrink: 0;
}
.status-dot--on { background: #00ff88; box-shadow: 0 0 6px rgba(0,255,136,0.6); animation: pulse-green 2s ease-in-out infinite; }
.status-dot--off{ background: #ff4d4d; box-shadow: 0 0 6px rgba(255,77,77,0.6); }
.status-dot--warn{ background: #ffb020; box-shadow: 0 0 6px rgba(255,176,32,0.6); }

@keyframes pulse-green {
  0%, 100% { box-shadow: 0 0 6px rgba(0,255,136,0.6); }
  50%      { box-shadow: 0 0 12px rgba(0,255,136,0.9); }
}

/* ===== SSE pill ===== */
.sse-pill {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: 'JetBrains Mono', monospace; font-size: 10px; font-weight: 600;
  padding: 2px 8px; border-radius: 3px; cursor: pointer;
  background: #16161a; border: 1px solid #27272e; color: #e4e4e7;
}
.sse-pill--on  { border-color: rgba(0,255,136,0.3); color: #00ff88; }
.sse-pill--off { border-color: rgba(255,77,77,0.3); color: #ff4d4d; }
.sse-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; animation: pulse-dot 1.2s ease-in-out infinite; }
@keyframes pulse-dot { 0%,100%{opacity:1} 50%{opacity:0.3} }

/* ===== PnL bar (direction/magnitude indicator) ===== */
.pnl-bar { height: 2px; border-radius: 1px; background: #27272e; position: relative; }

/* ===== TP/SL progress bar ===== */
.tpsl-bar {
  position: relative;
  height: 6px;
  background: linear-gradient(to right, rgba(255,77,77,0.25) 0 33%, #1e1e24 33% 66%, rgba(0,255,136,0.25) 66% 100%);
  border-radius: 3px;
  overflow: hidden;
}
.tpsl-bar::before {
  content: '';
  position: absolute; top: -2px; bottom: -2px;
  width: 2px;
  background: #e4e4e7;
  left: var(--pos, 50%);
  box-shadow: 0 0 4px rgba(255,255,255,0.5);
}

/* ===== Empty state ===== */
.empty {
  text-align: center;
  padding: 24px 16px;
  color: #7a7a85;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
}

/* ===== Tabs ===== */
.tab-btn {
  padding: 8px 14px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: #7a7a85;
  border-bottom: 2px solid transparent;
  background: transparent;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  transition: color 100ms, border-color 100ms;
}
.tab-btn:hover { color: #e4e4e7; }
.tab-btn--active { color: #00ff88; border-bottom-color: #00ff88; }

/* ===== KPI tiles ===== */
.kpi { background: #0e0e11; border: 1px solid #1e1e24; border-radius: 4px; padding: 8px 10px; }
.kpi-label { font-size: 9px; color: #7a7a85; text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 2px; }
.kpi-val { font-size: 16px; color: #e4e4e7; font-weight: 600; }
.kpi--big { padding: 16px; }

/* ===== Sparkline ===== */
.sparkline { width: 100%; height: 40px; display: block; }
.sparkline path { fill: none; stroke-width: 1.5; stroke-linejoin: round; stroke-linecap: round; }

/* ===== Category bars ===== */
.catbar { position: relative; min-width: 160px; flex: 1 1 180px; background: #0e0e11; border: 1px solid #1e1e24; border-radius: 4px; padding: 6px 8px; overflow: hidden; }
.catbar-label { font-size: 10px; color: #a1a1aa; text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 2px; position: relative; z-index: 1; }
.catbar-val   { font-size: 14px; position: relative; z-index: 1; text-align: right; }
.catbar-fill  { position: absolute; left: 0; top: 0; bottom: 0; opacity: 0.15; z-index: 0; }
.catbar-fill.text-yes { background: #00ff88; }
.catbar-fill.text-warn { background: #ffb020; }
.catbar-fill.text-down { background: #ef5350; }

/* ===== Event log & filters ===== */
.filter-pill { font-family: 'JetBrains Mono', monospace; font-size: 10px; padding: 3px 8px; border-radius: 3px; background: #16161a; border: 1px solid #27272e; color: #a1a1aa; cursor: pointer; text-transform: uppercase; letter-spacing: 0.05em; }
.filter-pill:hover { border-color: #33333c; color: #e4e4e7; }
.filter-pill--active { background: rgba(0,255,136,0.12); border-color: rgba(0,255,136,0.3); color: #00ff88; }

.event-line { font-family: 'JetBrains Mono', monospace; font-size: 11px; padding: 3px 6px; border-left: 2px solid transparent; }
.event-info  { border-left-color: #27272e; }
.event-warn  { border-left-color: #ffb020; }
.event-error { border-left-color: #ff4d4d; }
.event-success{ border-left-color: #00ff88; }

.log-tail { background: #0a0a0a; border: 1px solid #1e1e24; border-radius: 4px; padding: 6px; max-height: 240px; overflow-y: auto; }
.log-line { font-family: 'JetBrains Mono', monospace; font-size: 10.5px; padding: 1px 0; line-height: 1.4; }
.log-info  { color: #a1a1aa; }
.log-warn  { color: #ffb020; }
.log-error { color: #ff4d4d; }
.log-success { color: #00ff88; }

/* ===== Outcome pills ===== */
.outcome-won  { background: rgba(0,255,136,0.12); color: #00ff88; border-color: rgba(0,255,136,0.3); }
.outcome-lost { background: rgba(255,77,77,0.12); color: #ff4d4d; border-color: rgba(255,77,77,0.3); }
.outcome-expired { background: #1e1e24; color: #a1a1aa; border-color: #27272e; }

/* ===== Screen reader only ===== */
.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0);
  white-space: nowrap; border: 0;
}

/* ===== Line clamp for mobile ===== */
.line-clamp-2 {
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ===== Trade card renderer sections ===== */
.tc-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.tc-block { background: #0e0e11; border: 1px solid #1e1e24; border-radius: 4px; padding: 10px; }
.tc-block h4 { font-size: 10px; color: #7a7a85; text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 6px; }
.tc-block p, .tc-block li { font-size: 11.5px; line-height: 1.5; color: #d4d4d8; }
.tc-block ul { list-style: disc; padding-left: 16px; }
.tc-cost-row { display: flex; justify-content: space-between; font-family: 'JetBrains Mono', monospace; font-size: 11px; padding: 2px 0; border-bottom: 1px dashed #1e1e24; }
.tc-cost-row:last-child { border-bottom: none; font-weight: 600; color: #e4e4e7; border-top: 1px solid #27272e; padding-top: 4px; margin-top: 2px; }

/* Responsive tweaks */
@media (max-width: 640px) {
  .card-head { padding: 6px 10px; }
  .stat { min-width: auto; }
  .btn-x { padding: 3px 8px; font-size: 11px; }
}
