/* NBA Matchup Calculator — dark theme (Notion/Cursor style) */
:root {
  --bg: #1e1e1e;
  --surface: #252526;
  --bg-card: #2d2d2d;
  --bg-elevated: #3c3c3c;
  --border: #3c3c3c;
  --border-light: #404040;
  --text: #e4e4e7;
  --text-secondary: #a1a1aa;
  --muted: #71717a;
  --primary: #58a6ff;
  --primary-muted: rgba(56, 139, 253, 0.12);
  --away: #7ee8a2;
  --away-muted: rgba(126, 232, 162, 0.18);
  --home: #93d4ff;
  --home-muted: rgba(147, 212, 255, 0.18);
  --playing-muted: rgba(134, 239, 172, 0.12);
  --questionable-muted: rgba(251, 191, 36, 0.12);
  --doubtful-muted: rgba(251, 191, 36, 0.12);
  --out-muted: rgba(248, 113, 113, 0.12);
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.3);
  --radius: 8px;
  --radius-sm: 6px;
  --radius-lg: 10px;
  --radius-pill: 999px;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.header {
  padding: 1.5rem 1.5rem 1.75rem;
  border-bottom: 1px solid var(--border);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.header h1 { margin: 0 0 0.25rem; font-size: 1.5rem; font-weight: 600; }
.tagline { margin: 0; color: var(--text-secondary); font-size: 0.9375rem; }
.back { color: var(--primary); text-decoration: none; font-size: 0.9375rem; margin-top: 0.5rem; }
.back:hover { text-decoration: underline; }

.main { flex: 1; display: flex; flex-direction: column; padding: 2rem 1.5rem; min-height: 0; }
.error { color: #f87171; }
.no-games { color: var(--text-secondary); }

/* 70/30 results + chat layout */
.results-layout {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  gap: 0;
}

.results-row {
  flex: 1;
  display: flex;
  align-items: flex-start;
  min-height: 0;
  overflow: hidden;
  gap: 0.5in;
}

.results-panel {
  flex: 0 0 calc(68% - 0.35in);
  min-width: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 0;
  display: flex;
  flex-direction: column;
}

/* Single content area: either matchup (game cards) or player card */
.results-panel__content {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
/* View swap is controlled by JS (inline style.display). These are fallbacks only. */
.results-panel__content--matchup #games-container { display: block; }
.results-panel__content--matchup .player-card { display: none; }
.results-panel__content--player #games-container { display: none; }
.results-panel__content--player .player-card {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
}

.chat-panel {
  flex: 0 0 auto;
  width: calc(35% - 0.15in);
  min-width: 240px;
  margin-left: -0.5in;
  margin-right: calc(0.5in);
  height: 175vh;
  max-height: 175vh;
  min-height: 450px;
  align-self: flex-start;
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
}

.chat-panel__header {
  flex-shrink: 0;
  z-index: 1;
  padding: 0.75rem 1rem;
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text);
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

/* Scrollable message area: fixed height so content never expands the panel */
.chat-panel__messages {
  height: calc(175vh - 6.5rem);
  max-height: calc(175vh - 6.5rem);
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  -webkit-overflow-scrolling: touch;
}

.chat-panel__input-wrap {
  flex-shrink: 0;
  z-index: 1;
  display: flex;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  background: var(--surface);
  border-top: 1px solid var(--border);
}

.chat-msg {
  flex-shrink: 0;
  max-width: 95%;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.8125rem;
  line-height: 1.45;
}

.chat-msg--bot {
  align-self: flex-start;
  background: var(--bg-elevated);
  border: 1px solid var(--border-light);
  color: var(--text);
}

.chat-msg--user {
  align-self: flex-end;
  background: var(--primary-muted);
  border: 1px solid var(--primary);
  color: var(--text);
}

.chat-msg__text {
  white-space: pre-wrap;
  word-break: break-word;
  /* Prevent long content from forcing parent to grow; scroll lives in .chat-panel__messages */
  min-width: 0;
  overflow-wrap: break-word;
}


.chat-panel__input {
  flex: 1;
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  font-family: inherit;
  color: var(--text);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.chat-panel__input::placeholder { color: var(--muted); }
.chat-panel__input:focus { outline: none; border-color: var(--primary); }

.chat-panel__send {
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  font-family: inherit;
  font-weight: 500;
  color: #fff;
  background: var(--primary);
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.chat-panel__send:hover { opacity: 0.9; }

/* Clickable player name in roster */
.player-name-btn {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  color: var(--primary);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.player-name-btn:hover { color: var(--primary-hover, #7c9eff); }

/* Player stats card — PrizePicks-style layout */
.player-card {
  padding: 2rem 2.25rem;
  background: linear-gradient(165deg, #1a1d24 0%, #15171c 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md), 0 0 0 1px rgba(255, 255, 255, 0.04) inset;
  font-family: "DM Sans", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
.player-card__back {
  margin-bottom: 1.25rem;
  padding: 0.5rem 0.9rem;
  font-size: 0.9375rem;
  font-weight: 600;
  font-family: inherit;
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s, background 0.2s, transform 0.15s;
}
.player-card__back:hover { color: var(--primary); border-color: var(--primary); background: var(--primary-muted); transform: translateX(-2px); }
.player-card__header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 1rem 1.5rem;
  margin-bottom: 1.5rem;
}
.player-card__headshot {
  width: 132px;
  height: 132px;
  object-fit: cover;
  border-radius: var(--radius);
  border: 1px solid var(--border-light);
  flex-shrink: 0;
}
.player-card__header-info { flex: 1; min-width: 0; }
.player-card__name {
  margin: 0 0 0.4rem 0;
  font-size: 2.125rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.2;
  color: #fff;
}
.player-card__meta {
  margin: 0;
  font-size: 1.2rem;
  color: var(--text-secondary);
  font-weight: 600;
  letter-spacing: 0.02em;
}
.player-card__season {
  border-collapse: collapse;
  font-size: 0.9375rem;
  background: rgba(255, 255, 255, 0.04);
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border-light);
}
.player-card__season th,
.player-card__season td {
  padding: 0.5rem 0.75rem;
  text-align: left;
  border-bottom: 1px solid var(--border-light);
}
.player-card__season tr:last-child th,
.player-card__season tr:last-child td { border-bottom: none; }
.player-card__season th { color: var(--text-secondary); font-weight: 600; }
.player-card__season td { font-weight: 700; color: var(--text); }
.player-card__chart-section {
  margin-top: 0;
  margin-left: auto;
  margin-right: auto;
  max-width: calc(100% - 1in);
  padding: 1.5rem;
  background: rgba(0, 0, 0, 0.25);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-light);
  box-sizing: border-box;
}
.player-card__chart-label {
  margin: 0 0 0.75rem 0;
  font-size: 0.9375rem;
  font-weight: 700;
  color: var(--text-secondary);
  letter-spacing: 0.02em;
}
.player-card__stat-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 1rem;
}
.player-card__stat-tab {
  padding: 0.45rem 0.85rem;
  font-size: 0.875rem;
  font-weight: 700;
  font-family: inherit;
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s, background 0.2s;
}
.player-card__stat-tab:hover { color: var(--text); background: rgba(255, 255, 255, 0.1); }
.player-card__stat-tab.active {
  color: #4ade80;
  border-color: rgba(74, 222, 128, 0.5);
  background: rgba(74, 222, 128, 0.12);
}
.player-card__chart {
  display: block;
  height: 200px;
  min-height: 200px;
  margin-bottom: 0.5rem;
  overflow: visible;
}
.player-card__chart-frame {
  display: flex;
  flex-direction: row;
  align-items: stretch;
  height: 160px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0 0.4rem 0 0.35rem;
  background: rgba(0, 0, 0, 0.2);
  box-sizing: border-box;
}
.player-card__y-axis {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  height: 160px;
  padding-right: 0.35rem;
  padding-bottom: 1.15rem;
  margin-right: 0.2rem;
  border-right: 1px solid var(--border-light);
  flex-shrink: 0;
  box-sizing: border-box;
}
.player-card__y-tick {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-secondary);
  line-height: 1;
}
.player-card__chart-empty {
  margin: 0;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  font-size: 0.9375rem;
}
.player-card__bars {
  display: flex !important;
  flex-direction: row !important;
  flex-wrap: nowrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 0.5rem;
  height: 160px;
  min-height: 160px;
  flex: 1;
  min-width: 0;
  box-sizing: border-box;
  position: relative;
}
.player-card__avg-ref {
  position: absolute;
  left: 0;
  right: 0;
  height: 14px;
  border-bottom: 2px dashed rgba(255, 255, 255, 0.5);
  pointer-events: none;
}
.player-card__avg-ref-label {
  position: absolute;
  right: 0;
  top: 50%;
  transform: translate(0, -50%);
  font-size: 0.7rem;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.85);
  background: rgba(0, 0, 0, 0.5);
  padding: 0.15rem 0.4rem;
  border-radius: 3px;
}
.player-card__bar-wrap {
  flex: 1 1 0;
  min-width: 28px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  height: 160px;
  min-height: 160px;
}
.player-card__bar-spacer {
  flex: 1 1 0%;
  min-height: 4px;
  width: 100%;
}
.player-card__bar-value {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 0.2rem;
  line-height: 1;
  flex-shrink: 0;
}
.player-card__bar {
  width: 100%;
  min-width: 20px;
  min-height: 6px;
  flex: 0 0 auto;
  background: #4ade80;
  background: linear-gradient(180deg, #4ade80 0%, rgba(74, 222, 128, 0.85) 100%);
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  transition: height 0.2s ease;
}
.player-card__bar-label {
  margin-top: 0.35rem;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-secondary);
  flex-shrink: 0;
}
.player-card__avg-line {
  margin: 0;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.matchup-strip {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
  padding: 0.5rem 0;
  flex-shrink: 0;
}
.matchup-btn {
  padding: 0.5rem 0.875rem;
  font-size: 0.875rem;
  font-family: inherit;
  color: var(--text-secondary);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.matchup-btn:hover {
  color: var(--text);
  background: var(--bg-card);
  border-color: var(--border-light);
}
.matchup-btn[aria-pressed="true"] {
  color: var(--text);
  background: var(--primary-muted);
  border-color: var(--primary);
}

.games { display: flex; flex-direction: column; gap: 1.75rem; }

.game-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2rem 2.25rem;
  margin-left: max(0, calc(0.5in - 1.5rem));
  margin-right: 0.5in;
  box-shadow: var(--shadow);
  transition: box-shadow 0.2s ease, border-color 0.2s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.game-card[hidden] {
  display: none !important;
}
.game-card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--border-light);
}

.game-card .matchup-header,
.game-card .win-pct-bar,
.game-card .win-pct-labels,
.game-card .pick,
.game-card .ratings { text-align: center; }

.matchup-header { font-size: 1.1rem; margin-bottom: 0.5rem; }
.matchup-header .team.away { color: var(--away); }
.matchup-header .team.home { color: var(--home); }
.matchup-header .at { color: var(--muted); margin: 0 0.35rem; }

.win-pct-bar {
  display: flex;
  width: 100%;
  max-width: 320px;
  height: 8px;
  border-radius: var(--radius-pill);
  overflow: hidden;
  background: var(--bg-elevated);
  margin-bottom: 0.35rem;
}
.win-pct-bar .bar.away { background: var(--away); }
.win-pct-bar .bar.home { background: var(--home); }

.win-pct-labels {
  display: flex;
  justify-content: center;
  gap: 1.5rem;
  font-size: 0.8125rem;
  color: var(--text-secondary);
  margin-bottom: 0.75rem;
}

.pick {
  padding: 0.6rem 1rem;
  background: var(--primary-muted);
  border-radius: var(--radius-sm);
  margin: 0 0 1.25rem;
  font-size: 0.9375rem;
}

.ratings {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1.5rem;
  justify-items: center;
  width: 100%;
  max-width: 400px;
}
.team-ratings {
  padding: 0.75rem 1rem;
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-light);
  text-align: center;
}
.team-ratings h4 { margin: 0 0 0.25rem; font-size: 0.9375rem; color: var(--text); }
.team-ratings p { margin: 0; font-size: 0.8125rem; color: var(--text-secondary); }

.rosters {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: flex-start;
  gap: 0.5in;
  width: 100%;
}
.roster {
  flex: 1 1 0;
  min-width: 0;
  max-width: 520px;
  overflow-x: auto;
}
.roster h4 { margin: 0 0 0.75rem; font-size: 0.875rem; font-weight: 600; color: var(--text); text-align: center; }
.roster table {
  width: 100%;
  min-width: max-content;
  border-collapse: collapse;
  font-size: 0.75rem;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border);
  margin: 0 auto;
  background: var(--bg-card);
}
.roster th, .roster td { padding: 0.4rem 0.6rem; text-align: center; border-bottom: 1px solid var(--border-light); }
.roster th {
  background: var(--bg-elevated);
  color: var(--text-secondary);
  font-weight: 500;
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.roster td:first-child, .roster th:first-child { text-align: center; padding-left: 0.65rem; }
.roster td:nth-child(n+4), .roster th:nth-child(n+4) { font-variant-numeric: tabular-nums; }
.roster tbody tr:hover { background: var(--bg-elevated); }
.roster tbody tr:last-child td { border-bottom: none; }
.roster tr.status-out { opacity: 0.6; }
.roster tr.status-out:hover { opacity: 0.85; }
.roster tr.status-questionable { opacity: 0.9; }

.badge {
  display: inline-block;
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-pill);
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}
.badge.playing { background: var(--playing-muted); color: #86efac; border: 1px solid rgba(134, 239, 172, 0.4); }
.badge.questionable { background: var(--questionable-muted); color: #fbbf24; border: 1px solid rgba(251, 191, 36, 0.4); }
.badge.out { background: var(--out-muted); color: #f87171; border: 1px solid rgba(248, 113, 113, 0.4); }
.badge.doubtful { background: var(--doubtful-muted); color: #fbbf24; border: 1px solid rgba(251, 191, 36, 0.4); }

.injury-label { margin: 0.875rem 0 0.35rem; font-size: 0.75rem; font-weight: 500; color: var(--text-secondary); text-align: left; }
.injury-list { margin: 0; padding-left: 1.25rem; font-size: 0.75rem; color: var(--text-secondary); line-height: 1.7; }

/* Team comparison (after rosters) */
.team-comparison {
  width: 100%;
  max-width: 520px;
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 2px solid var(--border);
}

.team-comparison__title {
  margin: 0 0 0.75rem;
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text);
  text-align: center;
}

.team-comparison__teams {
  display: grid;
  grid-template-columns: 3.5rem 1fr 3.5rem;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
  font-size: 0.875rem;
  font-weight: 600;
  align-items: center;
}

.team-comparison__teams .team.away { text-align: right; color: var(--away); }
.team-comparison__teams .team.home { text-align: left; color: var(--home); }

.team-comparison__table {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.team-comparison__row {
  display: grid;
  grid-template-columns: 3.5rem 1fr 3.5rem;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.8125rem;
  font-variant-numeric: tabular-nums;
}

.team-comparison__val {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text);
}

.team-comparison__val.away { text-align: right; }
.team-comparison__val.home { text-align: left; }

.team-comparison__cell {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.team-comparison__stat-name {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  font-weight: 500;
  color: var(--text-secondary);
  text-align: center;
}

.team-comparison__bar {
  display: flex;
  height: 8px;
  border-radius: var(--radius-pill);
  overflow: hidden;
  background: var(--bg-elevated);
}

.team-comparison__bar-segment.away { background: var(--away); min-width: 4px; }
.team-comparison__bar-segment.home { background: var(--home); min-width: 4px; }

.footer {
  padding: 1.25rem 1.5rem;
  border-top: 1px solid var(--border);
  text-align: center;
  color: var(--muted);
  font-size: 0.8125rem;
  background: var(--bg-elevated);
  margin-top: auto;
}

/* Home page */
.page-home .main {
  padding: 4rem 1.5rem 3rem;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.home-cta {
  width: 100%;
  max-width: 420px;
  padding: 2rem 1.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.home-cta__title {
  margin: 0 0 0.5rem;
  font-size: 1.35rem;
  font-weight: 600;
  color: var(--text);
}

.home-cta__desc {
  margin: 0 0 1.5rem;
  font-size: 0.9375rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.home-cta .date-form {
  margin: 0;
  padding: 0;
  background: transparent;
  border: none;
  box-shadow: none;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  align-items: stretch;
  text-align: left;
}

.home-cta .date-form label {
  font-size: 0.875rem;
}

.date-form {
  padding: 1.5rem;
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  align-items: center;
}
.date-form label { font-weight: 500; }
.date-form input[type="date"] {
  padding: 0.5rem 0.875rem;
  font-size: 0.9375rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
}
.date-form button {
  padding: 0.75rem 1.5rem;
  font-size: 0.9375rem;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.date-form button:hover { opacity: 0.9; }

@media (max-width: 900px) {
  .results-row { flex-direction: column; }
  .results-panel { width: 100%; flex: 1 1 auto; padding-right: 0; }
  .chat-panel { width: 100%; flex: 0 0 auto; height: 140vh; min-height: 450px; max-height: 140vh; display: flex; flex-direction: column; }
  .chat-panel__messages { height: calc(140vh - 6.5rem); max-height: calc(140vh - 6.5rem); }
  .matchup-strip {
    overflow-x: auto;
    flex-wrap: nowrap;
    justify-content: flex-start;
    padding-bottom: 0.25rem;
    -webkit-overflow-scrolling: touch;
  }
  .matchup-btn { flex-shrink: 0; }
  .rosters { flex-direction: column; align-items: center; }
  .roster { width: 100%; max-width: 520px; }
  .ratings { grid-template-columns: 1fr; }
  .game-card { padding: 2rem 1.5rem; margin-left: 0; margin-right: 0; }
}
