/* ===== Exchange — matches Bragging Rights dark theme ===== */

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

body {
  background: #101624;
  color: #e6e9f0;
  font-family: 'Segoe UI', Arial, sans-serif;
  margin: 0;
  min-height: 100vh;
}

/* ===== Header ===== */
.hero {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #162040;
  padding: 0.8rem 2rem;
  border-bottom: 2px solid #1e2a4a;
  position: sticky;
  top: 0;
  z-index: 100;
}
.hero-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
}
.logo {
  width: 40px;
  height: 40px;
}
.site-title {
  font-size: 1.5rem;
  font-weight: bold;
  color: #3fa7ff;
  letter-spacing: 1px;
}
.site-subtitle {
  font-size: 0.8rem;
  color: #b8c6e0;
  margin-left: 0.5rem;
}
.hero-nav {
  display: flex;
  align-items: center;
  gap: 0.3rem;
}
.hero-nav a, .hero-nav button {
  color: #e6e9f0;
  background: none;
  border: none;
  font-size: 1rem;
  padding: 0.4rem 0.8rem;
  cursor: pointer;
  text-decoration: none;
  border-radius: 4px;
  transition: color 0.2s, background 0.2s;
  white-space: nowrap;
}
.hero-nav a:hover, .hero-nav button:hover {
  color: #3fa7ff;
  background: #1e2a4a;
}
.hero-nav a.active {
  color: #3fa7ff;
}
.nav-user {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: #b8c6e0;
  font-size: 0.9rem;
}
.nav-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid #3fa7ff33;
}
.nav-cash {
  color: #4ade80;
  font-weight: bold;
  font-size: 0.85rem;
}
.nav-login-btn {
  background: #3fa7ff !important;
  color: #101624 !important;
  font-weight: bold !important;
  border-radius: 4px !important;
  padding: 0.35rem 1rem !important;
}
.nav-login-btn:hover {
  background: #1e8be6 !important;
}

/* ===== Price Ticker Bar ===== */
.ticker-bar {
  background: #0d1020;
  border-bottom: 1px solid #1e2a4a;
  padding: 0.4rem 0;
  overflow: hidden;
  position: relative;
}
.ticker-track {
  display: flex;
  animation: ticker-scroll 60s linear infinite;
  white-space: nowrap;
  width: max-content;
}
.ticker-track:hover {
  animation-play-state: paused;
}
@keyframes ticker-scroll {
  from { transform: translateX(0); }
  to   { transform: translateX(-50%); }
}
.ticker-item {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0 1.5rem;
  font-size: 0.82rem;
  border-right: 1px solid #1e2a4a;
}
.ticker-name {
  font-weight: bold;
  color: #e6e9f0;
}
.ticker-price {
  color: #3fa7ff;
}
.ticker-change.up   { color: #4ade80; }
.ticker-change.down { color: #f87171; }
.ticker-change.flat { color: #b8c6e0; }

/* ===== Page layout ===== */
.page-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 1.5rem 1.5rem 3rem;
}
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 1rem;
}
.page-title {
  font-size: 1.6rem;
  font-weight: bold;
  color: #3fa7ff;
  margin: 0;
}

/* ===== Filter bar ===== */
.filter-bar {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 1.5rem;
  background: #162040;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  border: 1px solid #1e2a4a;
}
.filter-bar input,
.filter-bar select {
  background: #18213a;
  border: 1px solid #1e2a4a;
  border-radius: 4px;
  color: #e6e9f0;
  padding: 0.4rem 0.8rem;
  font-size: 0.95rem;
}
.filter-bar input:focus,
.filter-bar select:focus {
  outline: none;
  border-color: #3fa7ff55;
}
.filter-bar input { flex: 1; min-width: 160px; }
.filter-bar select { min-width: 120px; }

/* ===== Player Card Grid ===== */
.players-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
}
.player-card {
  background: #18213a;
  border-radius: 10px;
  padding: 1rem;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
  border: 1px solid #1e2a4a;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  text-decoration: none;
  color: inherit;
}
.player-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 20px rgba(63,167,255,0.15);
  border-color: #3fa7ff44;
}
.player-card-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.player-headshot {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  object-fit: cover;
  background: #222c4a;
  flex-shrink: 0;
  border: 2px solid #1e2a4a;
}
.player-info { flex: 1; min-width: 0; }
.player-name {
  font-weight: bold;
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #e6e9f0;
}
.player-meta {
  font-size: 0.78rem;
  color: #b8c6e0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.player-price-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.player-price {
  font-size: 1.25rem;
  font-weight: bold;
  color: #3fa7ff;
}
.change-badge {
  font-size: 0.78rem;
  font-weight: bold;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
}
.change-badge.up   { background: #14532d; color: #4ade80; }
.change-badge.down { background: #450a0a; color: #f87171; }
.change-badge.flat { background: #1e2a4a; color: #b8c6e0; }
.player-shares-row {
  font-size: 0.75rem;
  color: #b8c6e0;
}
.shares-bar {
  height: 3px;
  background: #1e2a4a;
  border-radius: 2px;
  margin-top: 4px;
  overflow: hidden;
}
.shares-bar-fill {
  height: 100%;
  background: #3fa7ff;
  border-radius: 2px;
  transition: width 0.3s;
}

/* ===== Top Movers ===== */
.movers-section {
  margin-bottom: 2rem;
}
.movers-section h3 {
  color: #3fa7ff;
  margin: 0 0 0.75rem;
  font-size: 1.1rem;
}
.movers-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}
.movers-list {
  background: #18213a;
  border-radius: 8px;
  border: 1px solid #1e2a4a;
  overflow: hidden;
}
.movers-list h4 {
  margin: 0;
  padding: 0.6rem 1rem;
  font-size: 0.85rem;
  font-weight: bold;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  border-bottom: 1px solid #1e2a4a;
}
.movers-list.gainers h4 { color: #4ade80; background: #14532d22; }
.movers-list.losers  h4 { color: #f87171; background: #450a0a22; }
.mover-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 1rem;
  border-bottom: 1px solid #1e2a4a;
  cursor: pointer;
  transition: background 0.15s;
  text-decoration: none;
  color: inherit;
}
.mover-row:last-child { border-bottom: none; }
.mover-row:hover { background: #222c4a; }
.mover-headshot {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  background: #222c4a;
  flex-shrink: 0;
}
.mover-name { flex: 1; font-size: 0.9rem; font-weight: bold; }
.mover-team { font-size: 0.78rem; color: #b8c6e0; }
.mover-price { font-size: 0.9rem; color: #3fa7ff; margin-left: auto; }
.mover-change { font-size: 0.85rem; font-weight: bold; min-width: 55px; text-align: right; }
.mover-change.up   { color: #4ade80; }
.mover-change.down { color: #f87171; }

/* ===== Player Detail Page ===== */
.player-detail-header {
  display: flex;
  gap: 1.5rem;
  align-items: flex-start;
  background: #18213a;
  border-radius: 12px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  border: 1px solid #1e2a4a;
  flex-wrap: wrap;
}
.player-detail-headshot {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  object-fit: cover;
  background: #222c4a;
  border: 3px solid #1e2a4a;
  flex-shrink: 0;
}
.player-detail-info { flex: 1; min-width: 200px; }
.player-detail-name {
  font-size: 1.8rem;
  font-weight: bold;
  color: #e6e9f0;
  margin: 0 0 0.25rem;
}
.player-detail-meta {
  color: #b8c6e0;
  font-size: 0.95rem;
  margin-bottom: 0.75rem;
}
.player-detail-price-block {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}
.player-detail-price {
  font-size: 2.2rem;
  font-weight: bold;
  color: #3fa7ff;
}
.player-detail-change {
  font-size: 1rem;
  font-weight: bold;
}
.player-detail-change.up   { color: #4ade80; }
.player-detail-change.down { color: #f87171; }
.player-detail-change.flat { color: #b8c6e0; }
.player-stat-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.5rem;
}
.stat-pill {
  background: #222c4a;
  border-radius: 4px;
  padding: 0.25rem 0.6rem;
  font-size: 0.8rem;
  color: #b8c6e0;
}
.stat-pill strong { color: #e6e9f0; }

/* ===== Trade Panel ===== */
.trade-panel {
  background: #18213a;
  border-radius: 12px;
  padding: 1.5rem;
  border: 1px solid #1e2a4a;
  min-width: 280px;
}
.trade-panel h3 {
  color: #3fa7ff;
  margin: 0 0 1rem;
  font-size: 1.1rem;
}
.trade-tabs {
  display: flex;
  margin-bottom: 1rem;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid #1e2a4a;
}
.trade-tab {
  flex: 1;
  padding: 0.5rem;
  background: #18213a;
  color: #b8c6e0;
  border: none;
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: bold;
  transition: background 0.2s, color 0.2s;
}
.trade-tab.active.buy  { background: #14532d; color: #4ade80; }
.trade-tab.active.sell { background: #450a0a; color: #f87171; }
.trade-tab:hover:not(.active) { background: #222c4a; color: #e6e9f0; }
.trade-form { display: flex; flex-direction: column; gap: 0.75rem; }
.trade-form label {
  font-size: 0.88rem;
  color: #b8c6e0;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.trade-form input[type="number"] {
  background: #0d1020;
  border: 1px solid #1e2a4a;
  border-radius: 4px;
  color: #e6e9f0;
  padding: 0.5rem 0.75rem;
  font-size: 1rem;
  width: 100%;
}
.trade-form input[type="number"]:focus {
  outline: none;
  border-color: #3fa7ff55;
}
.trade-preview {
  background: #0d1020;
  border-radius: 6px;
  padding: 0.75rem;
  font-size: 0.88rem;
}
.trade-preview-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 0.25rem;
  color: #b8c6e0;
}
.trade-preview-row.total {
  border-top: 1px solid #1e2a4a;
  padding-top: 0.4rem;
  margin-top: 0.25rem;
  font-weight: bold;
  color: #e6e9f0;
}
.trade-btn {
  padding: 0.65rem;
  border: none;
  border-radius: 6px;
  font-size: 1rem;
  font-weight: bold;
  cursor: pointer;
  transition: opacity 0.2s;
}
.trade-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.trade-btn.buy  { background: #4ade80; color: #0d1020; }
.trade-btn.buy:hover:not(:disabled)  { background: #22c55e; }
.trade-btn.sell { background: #f87171; color: #0d1020; }
.trade-btn.sell:hover:not(:disabled) { background: #ef4444; }
.trade-status {
  font-size: 0.88rem;
  min-height: 1.2em;
  text-align: center;
}
.trade-status.success { color: #4ade80; }
.trade-status.error   { color: #f87171; }
.cash-display {
  display: flex;
  justify-content: space-between;
  font-size: 0.88rem;
  color: #b8c6e0;
  margin-bottom: 0.5rem;
}
.cash-display strong { color: #4ade80; }

/* ===== Chart ===== */
.chart-container {
  background: #18213a;
  border-radius: 12px;
  padding: 1.25rem;
  margin-bottom: 1.5rem;
  border: 1px solid #1e2a4a;
}
.chart-container h3 {
  color: #3fa7ff;
  margin: 0 0 1rem;
  font-size: 1rem;
}
.chart-svg-wrapper {
  width: 100%;
  overflow: hidden;
}
.chart-svg { width: 100%; }
.chart-empty {
  text-align: center;
  padding: 2rem;
  color: #b8c6e0;
  font-size: 0.9rem;
}

/* ===== Stats Table ===== */
.stats-table-container {
  background: #18213a;
  border-radius: 12px;
  padding: 1.25rem;
  margin-bottom: 1.5rem;
  border: 1px solid #1e2a4a;
  overflow-x: auto;
}
.stats-table-container h3 {
  color: #3fa7ff;
  margin: 0 0 1rem;
  font-size: 1rem;
}
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}
.data-table th {
  color: #3fa7ff;
  padding: 0.5rem 0.75rem;
  text-align: left;
  border-bottom: 1px solid #1e2a4a;
  font-weight: 600;
  white-space: nowrap;
}
.data-table td {
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid #1a2238;
  color: #e6e9f0;
  white-space: nowrap;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: #222c4a; }
.data-table .num { text-align: right; }
.fp-cell { font-weight: bold; color: #3fa7ff; }
.fp-cell.positive { color: #4ade80; }
.fp-cell.negative { color: #f87171; }

/* ===== Portfolio Page ===== */
.portfolio-summary {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.summary-card {
  background: #18213a;
  border-radius: 8px;
  padding: 1rem 1.25rem;
  border: 1px solid #1e2a4a;
}
.summary-card .label {
  font-size: 0.78rem;
  color: #b8c6e0;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 0.3rem;
}
.summary-card .value {
  font-size: 1.35rem;
  font-weight: bold;
  color: #e6e9f0;
}
.summary-card .value.green  { color: #4ade80; }
.summary-card .value.red    { color: #f87171; }
.summary-card .value.blue   { color: #3fa7ff; }

/* Portfolio tabs */
.port-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}
.port-tab {
  padding: 0.4rem 1rem;
  background: #18213a;
  border: 1px solid #1e2a4a;
  border-radius: 4px;
  color: #b8c6e0;
  cursor: pointer;
  font-size: 0.9rem;
  transition: all 0.2s;
}
.port-tab.active, .port-tab:hover {
  background: #3fa7ff;
  color: #101624;
  border-color: #3fa7ff;
  font-weight: bold;
}

/* Holdings table sell button */
.sell-btn-sm {
  padding: 0.2rem 0.6rem;
  background: #f87171;
  color: #0d1020;
  border: none;
  border-radius: 4px;
  font-size: 0.8rem;
  font-weight: bold;
  cursor: pointer;
  transition: background 0.2s;
}
.sell-btn-sm:hover { background: #ef4444; }

/* Donut chart */
.donut-container {
  display: flex;
  align-items: center;
  gap: 2rem;
  flex-wrap: wrap;
}
.donut-legend {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  font-size: 0.82rem;
}
.donut-legend-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.donut-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ===== Leaderboard ===== */
.leaderboard-table-wrapper {
  background: #18213a;
  border-radius: 12px;
  border: 1px solid #1e2a4a;
  overflow: hidden;
}
.leaderboard-row {
  display: grid;
  grid-template-columns: 48px 1fr 140px 120px 100px;
  align-items: center;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid #1a2238;
  gap: 0.5rem;
  transition: background 0.15s;
}
.leaderboard-row:last-child { border-bottom: none; }
.leaderboard-row:hover:not(.header) { background: #222c4a; }
.leaderboard-row.header {
  background: #0d1020;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #3fa7ff;
  font-weight: 600;
}
.leaderboard-row.current-user { background: #162040; border-left: 3px solid #3fa7ff; }
.lb-rank { font-weight: bold; color: #b8c6e0; font-size: 0.95rem; text-align: center; }
.lb-rank-1 { color: #fbbf24; }
.lb-rank-2 { color: #9ca3af; }
.lb-rank-3 { color: #b45309; }
.lb-user { display: flex; align-items: center; gap: 0.6rem; min-width: 0; }
.lb-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  background: #222c4a;
  flex-shrink: 0;
}
.lb-username { font-weight: bold; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lb-value { font-weight: bold; color: #3fa7ff; text-align: right; }
.lb-change { text-align: right; font-size: 0.88rem; }
.lb-change.up   { color: #4ade80; }
.lb-change.down { color: #f87171; }
.lb-change.flat { color: #b8c6e0; }
.lb-holdings { color: #b8c6e0; font-size: 0.85rem; text-align: right; }

/* ===== Trade Modal ===== */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: #101624cc;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
}
.modal-overlay.hidden { display: none; }
.modal {
  background: #18213a;
  border-radius: 12px;
  padding: 1.5rem 2rem;
  min-width: 320px;
  max-width: 95vw;
  position: relative;
  box-shadow: 0 8px 40px #0008;
  border: 1px solid #1e2a4a;
}
.modal h2 { color: #3fa7ff; margin-top: 0; font-size: 1.2rem; }
.close-modal {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: none;
  border: none;
  color: #b8c6e0;
  font-size: 1.4rem;
  cursor: pointer;
  line-height: 1;
  padding: 0;
}
.close-modal:hover { color: #e6e9f0; }

/* ===== Spinner ===== */
@keyframes spin { to { transform: rotate(360deg); } }
.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid #1e2a4a;
  border-top-color: #3fa7ff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin: 2rem auto;
}
.loading-msg { text-align: center; color: #b8c6e0; padding: 2rem; }

/* ===== Auth placeholder ===== */
.auth-required {
  text-align: center;
  padding: 4rem 2rem;
  color: #b8c6e0;
}
.auth-required h2 { color: #3fa7ff; margin-bottom: 0.5rem; }
.auth-required p { margin-bottom: 1.5rem; }
.btn-primary {
  background: #3fa7ff;
  color: #101624;
  border: none;
  border-radius: 6px;
  padding: 0.65rem 1.5rem;
  font-size: 1rem;
  font-weight: bold;
  cursor: pointer;
  transition: background 0.2s;
  text-decoration: none;
  display: inline-block;
}
.btn-primary:hover { background: #1e8be6; }

/* ===== Pagination ===== */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.5rem;
  margin-top: 1.5rem;
  flex-wrap: wrap;
}
.pagination button {
  background: #18213a;
  border: 1px solid #1e2a4a;
  color: #e6e9f0;
  border-radius: 4px;
  padding: 0.35rem 0.85rem;
  cursor: pointer;
  font-size: 0.9rem;
  transition: background 0.2s;
}
.pagination button:hover:not(:disabled) { background: #3fa7ff; color: #101624; }
.pagination button:disabled { opacity: 0.4; cursor: default; }
.pagination .page-info { color: #b8c6e0; font-size: 0.85rem; }

/* ===== Footer ===== */
.site-footer {
  text-align: center;
  padding: 1.5rem 2rem;
  margin-top: 3rem;
  border-top: 1px solid #1e2a4a;
  color: #b8c6e0;
  font-size: 0.9rem;
}
.site-footer a { color: #3fa7ff; text-decoration: none; }
.site-footer a:hover { color: #e6e9f0; }
.footer-sep { margin: 0 0.7rem; color: #1e2a4a; }

/* ===== Responsive ===== */
@media (max-width: 1100px) {
  .movers-grid { grid-template-columns: 1fr; }
  .leaderboard-row { grid-template-columns: 40px 1fr 120px 100px; }
  .leaderboard-row .lb-holdings { display: none; }
}
@media (max-width: 768px) {
  .hero { padding: 0.6rem 1rem; }
  .site-title { font-size: 1.2rem; }
  .hero-nav a:not(.nav-login-btn), .hero-nav .nav-user { display: none; }
  .page-container { padding: 1rem; }
  .players-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  .player-detail-header { flex-direction: column; align-items: center; text-align: center; }
  .leaderboard-row { grid-template-columns: 36px 1fr 100px; }
  .leaderboard-row .lb-change, .leaderboard-row .lb-holdings { display: none; }
  .portfolio-summary { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 480px) {
  .players-grid { grid-template-columns: 1fr 1fr; }
  .filter-bar { flex-direction: column; }
  .filter-bar input, .filter-bar select { width: 100%; }
}
