/* ═══════════════════════════════════════════════════════════
   MadnessPredict v2 — Dark Theme Stylesheet
   Design DNA: Polymarket x DraftKings x Bloomberg Terminal
   ═══════════════════════════════════════════════════════════ */

/* ── CSS Variables ────────────────────────────────────────── */
:root {
  /* Backgrounds — layered dark surfaces */
  --bg-base: #0B0B11;
  --bg-surface: #12121C;
  --bg-elevated: #1A1A28;
  --bg-input: #0F0F18;

  /* Brand Accent */
  --accent-primary: #3B82F6;
  --accent-primary-glow: rgba(59, 130, 246, 0.15);

  /* Outcome Colors */
  --color-favorite: #22C55E;
  --color-underdog: #F59E0B;
  --color-value-bet: #EF4444;
  --color-neutral: #6B7280;

  /* Text Hierarchy */
  --text-primary: #F9FAFB;
  --text-secondary: #9CA3AF;
  --text-muted: #4B5563;
  --text-odds: #E5E7EB;

  /* Borders */
  --border-subtle: rgba(255, 255, 255, 0.06);
  --border-active: rgba(59, 130, 246, 0.3);

  /* Probability Bar */
  --bar-team-a: #3B82F6;
  --bar-team-b: #6B7280;

  /* Fonts */
  --font-display: 'DM Sans', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
}

/* ── Reset & Base ─────────────────────────────────────────── */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-display);
  background: var(--bg-base);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Typography Utilities ─────────────────────────────────── */
.text-hero     { font-size: 3.5rem; font-weight: 700; letter-spacing: -0.03em; line-height: 1.0; }
.text-title    { font-size: 1.5rem; font-weight: 600; letter-spacing: -0.02em; line-height: 1.2; }
.text-subtitle { font-size: 1rem;   font-weight: 500; letter-spacing: -0.01em; line-height: 1.4; }
.text-body     { font-size: 0.875rem; font-weight: 400; line-height: 1.5; }
.text-caption  { font-size: 0.75rem; font-weight: 500; letter-spacing: 0.05em; text-transform: uppercase; color: var(--text-secondary); }
.text-mono     { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

/* ── Header ───────────────────────────────────────────────── */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  background: var(--bg-base);
  border-bottom: 1px solid var(--border-subtle);
}

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

.header__title {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.header__meta {
  display: flex;
  align-items: center;
  gap: 16px;
}

.header__tournament {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.header__status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  color: var(--color-favorite);
  font-weight: 500;
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--color-favorite);
  box-shadow: 0 0 6px var(--color-favorite);
  animation: pulse-dot 2s infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* ── Main Content ─────────────────────────────────────────── */
.main {
  flex: 1;
  max-width: 720px;
  width: 100%;
  margin: 0 auto;
  padding: 32px 20px 24px;
}

/* ── Team Selector ────────────────────────────────────────── */
.selector {
  display: flex;
  align-items: flex-end;
  gap: 16px;
  margin-bottom: 16px;
}

.selector__team {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.selector__dropdown {
  width: 100%;
  padding: 12px 14px;
  font-family: var(--font-display);
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-primary);
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  outline: none;
  cursor: pointer;
  transition: border-color 0.2s;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%239CA3AF' stroke-width='1.5' fill='none'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
}

.selector__dropdown:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px var(--accent-primary-glow);
}

.selector__dropdown option {
  background: var(--bg-surface);
  color: var(--text-primary);
}

.selector__vs {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-muted);
  padding-bottom: 14px;
  flex-shrink: 0;
  letter-spacing: 0.1em;
}

/* ── Predict Button ───────────────────────────────────────── */
.btn-predict {
  width: 100%;
  padding: 14px 24px;
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 600;
  color: #fff;
  background: var(--accent-primary);
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.2s, opacity 0.2s, transform 0.1s;
  margin-bottom: 24px;
}

.btn-predict:hover:not(:disabled) {
  background: #2563EB;
  transform: translateY(-1px);
}

.btn-predict:active:not(:disabled) {
  transform: translateY(0);
}

.btn-predict:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.btn-predict--loading {
  animation: btn-pulse 1.5s infinite;
  pointer-events: none;
}

@keyframes btn-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

/* ── Results Section ──────────────────────────────────────── */
.results {
  animation: results-enter 300ms ease-out both;
}

@keyframes results-enter {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ── Result Card (Probability Hero) ───────────────────────── */
.result-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  padding: 24px;
  margin-bottom: 12px;
}

.prob-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.prob-header__team {
  display: flex;
  align-items: center;
  gap: 8px;
}

.prob-header__name {
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.seed-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 20px;
  padding: 0 6px;
  border-radius: 10px;
  font-size: 0.65rem;
  font-weight: 600;
  font-family: var(--font-mono);
}

.seed-badge--green  { background: rgba(34, 197, 94, 0.15);  color: var(--color-favorite); }
.seed-badge--blue   { background: rgba(59, 130, 246, 0.15); color: var(--accent-primary); }
.seed-badge--amber  { background: rgba(245, 158, 11, 0.15); color: var(--color-underdog); }
.seed-badge--gray   { background: rgba(107, 114, 128, 0.15); color: var(--color-neutral); }

/* Probability Numbers */
.prob-numbers {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 8px;
}

.prob-numbers__pct {
  font-size: 3.5rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1;
  color: var(--text-primary);
}

.prob-numbers__pct--dim {
  color: var(--text-secondary);
}

/* Probability Bar */
.probability-bar {
  height: 12px;
  border-radius: 6px;
  overflow: hidden;
  background: var(--bg-elevated);
  position: relative;
  margin-bottom: 12px;
}

.probability-bar__fill {
  height: 100%;
  border-radius: 6px;
  background: var(--bar-team-a);
  transition: width 600ms cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 0 12px var(--accent-primary-glow);
}

/* Probability Footer */
.prob-footer {
  text-align: center;
}

.prob-footer__text {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.prob-footer__text strong {
  color: var(--accent-primary);
  font-weight: 600;
}

.prob-footer__confidence {
  color: var(--text-muted);
  font-size: 0.8rem;
}

.prob-footer__confidence--high   { color: var(--color-favorite); }
.prob-footer__confidence--medium { color: var(--color-underdog); }
.prob-footer__confidence--low    { color: var(--text-muted); }

/* ── Seed Info ────────────────────────────────────────────── */
.seed-info {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  padding: 12px 16px;
  margin-bottom: 12px;
}

.seed-info__text {
  font-size: 0.8rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* ── Odds Comparison Card ─────────────────────────────────── */
.odds-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  padding: 16px;
  margin-bottom: 12px;
  animation: stagger-in 300ms ease-out both;
  animation-delay: 50ms;
}

.section-label {
  margin-bottom: 12px;
}

.odds-table {
  width: 100%;
}

.odds-table__header,
.odds-table__row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 0.8fr;
  gap: 4px;
  padding: 8px 0;
}

.odds-table__header {
  border-bottom: 1px solid var(--border-subtle);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.odds-table__row {
  border-bottom: 1px solid var(--border-subtle);
}

.odds-table__row:last-child {
  border-bottom: none;
}

.odds-table__row--model .odds-table__cell {
  color: var(--accent-primary);
  font-weight: 600;
}

.odds-table__row--model .odds-table__cell--source {
  color: var(--accent-primary);
}

.odds-table__row--implied {
  border-bottom: none;
  padding-top: 0;
}

.odds-table__row--implied .odds-table__cell {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.odds-table__cell {
  font-size: 0.85rem;
  color: var(--text-odds);
  display: flex;
  align-items: center;
}

.odds-table__cell--source {
  color: var(--text-secondary);
  font-size: 0.8rem;
  font-weight: 500;
}

.odds-table__cell--edge {
  justify-content: flex-end;
}

/* VALUE Badge */
.badge--value {
  background: rgba(239, 68, 68, 0.15);
  color: #EF4444;
  border: 1px solid rgba(239, 68, 68, 0.3);
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 600;
  font-family: var(--font-mono);
  letter-spacing: 0.02em;
  white-space: nowrap;
  transition: transform 0.15s;
}

@media (hover: hover) {
  .badge--value:hover {
    transform: scale(1.05);
  }
}

/* Odds Extra (Spread + Total) */
.odds-extra {
  display: flex;
  gap: 24px;
  padding-top: 12px;
  margin-top: 8px;
  border-top: 1px solid var(--border-subtle);
}

.odds-extra__item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.odds-extra__item .text-mono {
  font-size: 0.9rem;
  color: var(--text-odds);
}

.odds-unavailable {
  font-size: 0.8rem;
  color: var(--text-muted);
  padding: 8px 0;
}

/* ── Betting Edge Card ─────────────────────────────────────── */
.edge-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  padding: 16px;
  margin-bottom: 12px;
  animation: stagger-in 300ms ease-out both;
  animation-delay: 75ms;
}

.edge-items {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.edge-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border-subtle);
}

.edge-item:last-child {
  border-bottom: none;
}

.edge-item__icon {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.03em;
}

.edge-item__icon--spread {
  background: rgba(59, 130, 246, 0.12);
  color: var(--accent-primary);
  border: 1px solid rgba(59, 130, 246, 0.2);
}

.edge-item__icon--ou {
  background: rgba(245, 158, 11, 0.12);
  color: var(--color-underdog);
  border: 1px solid rgba(245, 158, 11, 0.2);
}

.edge-item__body {
  flex: 1;
  min-width: 0;
}

.edge-item__headline {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.edge-item__rec {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
}

.edge-item__tag {
  display: inline-flex;
  align-items: center;
  padding: 1px 7px;
  border-radius: 3px;
  font-size: 0.6rem;
  font-weight: 600;
  font-family: var(--font-mono);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.edge-item__tag--high {
  background: rgba(34, 197, 94, 0.15);
  color: var(--color-favorite);
  border: 1px solid rgba(34, 197, 94, 0.25);
}

.edge-item__tag--medium {
  background: rgba(245, 158, 11, 0.15);
  color: var(--color-underdog);
  border: 1px solid rgba(245, 158, 11, 0.25);
}

.edge-item__tag--low {
  background: rgba(107, 114, 128, 0.15);
  color: var(--color-neutral);
  border: 1px solid rgba(107, 114, 128, 0.25);
}

.edge-item__desc {
  font-size: 0.78rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

.edge-unavailable {
  font-size: 0.8rem;
  color: var(--text-muted);
  padding: 8px 0;
}

/* ── Key Factors Card ─────────────────────────────────────── */
.factors-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  padding: 16px;
  margin-bottom: 12px;
  animation: stagger-in 300ms ease-out both;
  animation-delay: 100ms;
}

.factors-list {
  list-style: none;
}

.factors-list__item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 0.85rem;
  line-height: 1.4;
}

.factors-list__item:last-child {
  border-bottom: none;
}

.factors-list__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 5px;
}

.factors-list__dot--a { background: var(--accent-primary); }
.factors-list__dot--b { background: var(--color-neutral); }

.factors-list__content {
  flex: 1;
}

.factors-list__feature {
  font-weight: 600;
  color: var(--text-primary);
}

.factors-list__desc {
  color: var(--text-secondary);
}

.factors-list__advantage {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--color-favorite);
  font-weight: 500;
}

/* ── Stagger Animation ────────────────────────────────────── */
@keyframes stagger-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ── Footer ───────────────────────────────────────────────── */
.footer {
  padding: 12px 24px;
  text-align: center;
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-base);
}

.footer__metrics {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-bottom: 2px;
}

.footer__metrics .text-mono {
  color: var(--text-secondary);
}

.footer__sep {
  margin: 0 6px;
  opacity: 0.4;
}

.footer__sources {
  font-size: 0.65rem;
  color: var(--text-muted);
  opacity: 0.6;
}

/* ── Hover Effects ────────────────────────────────────────── */
@media (hover: hover) {
  .prob-header__name:hover {
    text-decoration: underline;
    text-decoration-color: var(--border-active);
    text-underline-offset: 3px;
  }

  .odds-table__row:not(.odds-table__header):hover {
    background: var(--bg-elevated);
    border-radius: 2px;
  }
}

/* ── Mobile Responsive ────────────────────────────────────── */
@media (max-width: 768px) {
  .header {
    padding: 0 16px;
  }

  .header__tournament {
    display: none;
  }

  .main {
    padding: 20px 16px 16px;
  }

  .selector {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  .selector__vs {
    text-align: center;
    padding-bottom: 0;
    padding: 4px 0;
  }

  .prob-numbers__pct {
    font-size: 2.5rem;
  }

  .result-card {
    padding: 16px;
  }

  /* Stack odds table on mobile */
  .odds-table__header {
    display: none;
  }

  .odds-table__row {
    grid-template-columns: 1fr;
    gap: 4px;
    padding: 12px;
    background: var(--bg-elevated);
    border-radius: 4px;
    margin-bottom: 8px;
    border-bottom: none;
  }

  .odds-table__row .odds-table__cell--source {
    font-weight: 600;
    font-size: 0.85rem;
    margin-bottom: 4px;
  }

  .odds-table__cell--edge {
    justify-content: flex-start;
  }

  .footer__metrics {
    font-size: 0.65rem;
  }

  .footer__sep {
    display: none;
  }

  .footer__metrics {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
  }
}

/* ── Scrollbar (subtle) ───────────────────────────────────── */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: var(--bg-base);
}

::-webkit-scrollbar-thumb {
  background: var(--bg-elevated);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* ── Selection Color ──────────────────────────────────────── */
::selection {
  background: var(--accent-primary-glow);
  color: var(--text-primary);
}

/* ═══════════════════════════════════════════════════════════
   Paywall & Restore Pages
   ═══════════════════════════════════════════════════════════ */

.paywall {
  max-width: 480px;
  margin: 80px auto;
  padding: 0 20px;
  text-align: center;
}

.paywall__hero h1 {
  font-size: 2rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 8px;
  letter-spacing: -0.02em;
}

.paywall__subtitle {
  color: var(--text-secondary);
  font-size: 1rem;
  margin-bottom: 32px;
}

.paywall__card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 32px 24px;
  text-align: left;
}

.paywall__card--form {
  text-align: left;
}

.paywall__card-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 24px;
}

.paywall__card-header h2 {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
}

.paywall__price-amount {
  font-family: var(--font-mono);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--color-favorite);
}

.paywall__price-period {
  color: var(--text-muted);
  font-size: 0.8rem;
  margin-left: 4px;
}

.paywall__features {
  list-style: none;
  padding: 0;
  margin: 0 0 24px 0;
}

.paywall__features li {
  color: var(--text-secondary);
  padding: 8px 0;
  font-size: 0.9rem;
  border-bottom: 1px solid var(--border-subtle);
}

.paywall__features li::before {
  content: "\2713  ";
  color: var(--color-favorite);
  font-weight: 600;
}

.paywall__features li:last-child {
  border-bottom: none;
}

.paywall__proof {
  background: var(--bg-elevated);
  border-radius: 6px;
  padding: 16px;
  margin-bottom: 24px;
  text-align: center;
}

.paywall__proof-stat {
  font-family: var(--font-mono);
  font-size: 2rem;
  font-weight: 700;
  color: var(--accent-primary);
  display: block;
}

.paywall__proof-label {
  color: var(--text-secondary);
  font-size: 0.8rem;
}

.paywall__cta {
  width: 100%;
  padding: 16px;
  background: var(--accent-primary);
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 1.1rem;
  font-weight: 600;
  font-family: var(--font-display);
  cursor: pointer;
  transition: background 200ms, transform 100ms;
}

.paywall__cta:hover {
  background: #2563EB;
  transform: translateY(-1px);
}

.paywall__cta:active {
  transform: translateY(0);
}

.paywall__restore {
  margin-top: 24px;
}

.paywall__restore a {
  color: var(--accent-primary);
  text-decoration: none;
}

.paywall__restore a:hover {
  text-decoration: underline;
}

.paywall__footer-text {
  margin-top: 16px;
  color: var(--text-muted);
  font-size: 0.75rem;
}

/* Restore page specifics */
.paywall__restore-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.paywall__restore-subtitle {
  color: var(--text-secondary);
  margin-bottom: 32px;
}

.paywall__error {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: 6px;
  padding: 12px;
  margin-bottom: 20px;
  color: #EF4444;
  font-size: 0.9rem;
}

.paywall__label {
  color: var(--text-secondary);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  display: block;
  margin-bottom: 8px;
}

.paywall__input {
  width: 100%;
  padding: 12px;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  color: var(--text-primary);
  font-family: var(--font-display);
  font-size: 1rem;
  margin-bottom: 16px;
  box-sizing: border-box;
  outline: none;
  transition: border-color 0.2s;
}

.paywall__input:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px var(--accent-primary-glow);
}

.paywall__input::placeholder {
  color: var(--text-muted);
}

/* Header user indicator */
.header__user {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 400;
}
