/* ─── CSS Variables & Design System ─────────────────────────────── */
:root {
  --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  /* HSL Tailored Dark Theme */
  --bg-primary: hsl(222, 24%, 9%);
  --bg-secondary: hsl(222, 20%, 13%);
  --bg-card: hsl(222, 18%, 16%);
  --bg-card-hover: hsl(222, 18%, 19%);
  --bg-input: hsl(222, 22%, 11%);
  --bg-accent-subtle: hsl(152, 60%, 12%);

  --border-subtle: hsl(222, 16%, 22%);
  --border-focus: hsl(210, 80%, 55%);
  --border-success: hsl(152, 60%, 35%);

  --text-primary: hsl(210, 40%, 98%);
  --text-secondary: hsl(215, 20%, 75%);
  --text-muted: hsl(215, 16%, 52%);

  --color-success: hsl(152, 68%, 45%);
  --color-success-bg: hsla(152, 68%, 45%, 0.12);
  --color-accent: hsl(210, 95%, 62%);
  --color-sportpesa: hsl(210, 95%, 62%);
  --color-sportpesa-bg: hsla(210, 95%, 62%, 0.12);
  --color-1xbet: hsl(28, 95%, 60%);
  --color-1xbet-bg: hsla(28, 95%, 60%, 0.12);
  --color-warning: hsl(38, 92%, 50%);

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
}

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

body {
  font-family: var(--font-sans);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ─── Header ──────────────────────────────────────────────────────── */
.site-header {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-subtle);
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: blur(8px);
}

.header-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.brand-badge {
  background: var(--color-success);
  color: hsl(222, 30%, 8%);
  font-size: 0.7rem;
  font-weight: 800;
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-sm);
  letter-spacing: 0.05em;
}

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

.brand-subtitle {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 500;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.live-status-pill {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  font-size: 0.8rem;
  color: var(--text-secondary);
  font-family: var(--font-mono);
}

.pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--color-success);
  box-shadow: 0 0 8px var(--color-success);
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
  padding: 0.45rem 0.9rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-primary:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-focus);
}

/* ─── Main Container ──────────────────────────────────────────────── */
.main-container {
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 1.5rem;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* ─── Stats Grid ──────────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
}

.stat-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  transition: transform 0.15s ease;
}

.stat-card:hover {
  transform: translateY(-2px);
}

.stat-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.stat-value {
  font-size: 1.75rem;
  font-weight: 800;
  font-family: var(--font-mono);
  letter-spacing: -0.03em;
  color: var(--text-primary);
}

.stat-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.text-success { color: var(--color-success); }
.text-accent { color: var(--color-accent); }

/* ─── Controls & Calculator Bar ───────────────────────────────────── */
.controls-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1.25rem;
}

.controls-row {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: flex-end;
}

.stake-control, .filter-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.stake-control {
  min-width: 180px;
}

.filter-group {
  flex: 1;
  min-width: 180px;
}

.control-label {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.input-prefix-wrapper {
  display: flex;
  align-items: center;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.input-prefix {
  padding: 0 0.6rem;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-muted);
  background: hsla(222, 16%, 18%, 0.6);
  border-right: 1px solid var(--border-subtle);
  line-height: 2.2rem;
}

.control-input, .control-select {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.9rem;
  padding: 0.5rem 0.75rem;
  outline: none;
  transition: border-color 0.15s ease;
}

.input-prefix-wrapper .control-input {
  border: none;
  font-family: var(--font-mono);
  font-weight: 700;
}

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

.toggle-group {
  display: flex;
  align-items: center;
  padding-bottom: 0.35rem;
}

.toggle-label {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  cursor: pointer;
  user-select: none;
}

.toggle-label input {
  display: none;
}

.toggle-switch {
  width: 36px;
  height: 20px;
  background: var(--border-subtle);
  border-radius: 999px;
  position: relative;
  transition: background 0.2s ease;
}

.toggle-switch::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  background: var(--text-primary);
  border-radius: 50%;
  transition: transform 0.2s ease;
}

.toggle-label input:checked + .toggle-switch {
  background: var(--color-success);
}

.toggle-label input:checked + .toggle-switch::after {
  transform: translateX(16px);
}

.toggle-text {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
}

/* ─── Results Section ─────────────────────────────────────────────── */
.results-section {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.results-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.results-header h2 {
  font-size: 1.1rem;
  font-weight: 700;
}

.results-count-badge {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--bg-secondary);
  padding: 0.2rem 0.6rem;
  border-radius: var(--radius-sm);
}

.cards-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* ─── Opportunity Card ────────────────────────────────────────────── */
.opp-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: border-color 0.15s ease, transform 0.15s ease;
}

.opp-card:hover {
  border-color: hsl(222, 16%, 32%);
  transform: translateY(-1px);
}

.opp-card.is-arb {
  border-left: 4px solid var(--color-success);
}

.card-header {
  background: var(--bg-secondary);
  padding: 0.75rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-subtle);
  flex-wrap: wrap;
  gap: 0.5rem;
}

.match-title-group {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.match-league {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
}

.match-teams {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
}

.match-time {
  font-size: 0.75rem;
  color: var(--text-secondary);
  font-family: var(--font-mono);
}

.market-badge-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.market-badge {
  font-size: 0.75rem;
  font-weight: 700;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  padding: 0.25rem 0.55rem;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
}

.arb-badge {
  font-size: 0.75rem;
  font-weight: 800;
  background: var(--color-success-bg);
  border: 1px solid var(--border-success);
  color: var(--color-success);
  padding: 0.25rem 0.6rem;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
}

.card-body {
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* ─── Outcomes Table / Grid ───────────────────────────────────────── */
.outcomes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 0.75rem;
}

.outcome-box {
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.outcome-box.winner-sportpesa {
  border-color: hsla(210, 95%, 62%, 0.4);
  background: linear-gradient(to bottom, var(--bg-input), var(--color-sportpesa-bg));
}

.outcome-box.winner-1xbet {
  border-color: hsla(28, 95%, 60%, 0.4);
  background: linear-gradient(to bottom, var(--bg-input), var(--color-1xbet-bg));
}

.outcome-role {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-secondary);
}

.outcome-odd-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}

.outcome-odd {
  font-size: 1.25rem;
  font-weight: 800;
  font-family: var(--font-mono);
  color: var(--text-primary);
}

.outcome-book-pill {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.15rem 0.4rem;
  border-radius: var(--radius-sm);
  text-transform: uppercase;
}

.pill-sportpesa {
  background: var(--color-sportpesa-bg);
  color: var(--color-sportpesa);
  border: 1px solid hsla(210, 95%, 62%, 0.3);
}

.pill-1xbet {
  background: var(--color-1xbet-bg);
  color: var(--color-1xbet);
  border: 1px solid hsla(28, 95%, 60%, 0.3);
}

.outcome-stake-calc {
  border-top: 1px dashed var(--border-subtle);
  padding-top: 0.4rem;
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  font-family: var(--font-mono);
  color: var(--text-muted);
}

.calc-stake-val {
  font-weight: 700;
  color: var(--text-primary);
}

/* ─── Card Footer / Links ─────────────────────────────────────────── */
.card-footer {
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-subtle);
  padding: 0.75rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.profit-summary {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.85rem;
}

.profit-amount {
  font-weight: 800;
  font-family: var(--font-mono);
  color: var(--color-success);
}

.direct-links {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.btn-bookmaker-link {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.7rem;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 700;
  text-decoration: none;
  transition: all 0.15s ease;
}

.link-sportpesa {
  background: var(--color-sportpesa-bg);
  color: var(--color-sportpesa);
  border: 1px solid hsla(210, 95%, 62%, 0.3);
}

.link-sportpesa:hover {
  background: hsla(210, 95%, 62%, 0.22);
}

.link-1xbet {
  background: var(--color-1xbet-bg);
  color: var(--color-1xbet);
  border: 1px solid hsla(28, 95%, 60%, 0.3);
}

.link-1xbet:hover {
  background: hsla(28, 95%, 60%, 0.22);
}

/* ─── Empty & Loading States ──────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 3.5rem 1.5rem;
  background: var(--bg-card);
  border: 1px dashed var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

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

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

/* ─── Footer ──────────────────────────────────────────────────────── */
.site-footer {
  margin-top: auto;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-subtle);
  padding: 1.5rem;
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.footer-container {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.disclaimer {
  font-size: 0.75rem;
  color: hsl(215, 12%, 45%);
}

/* ─── Responsive Breakdown ────────────────────────────────────────── */
@media (max-width: 768px) {
  .header-container {
    flex-direction: column;
    align-items: flex-start;
  }
  .header-actions {
    width: 100%;
    justify-content: space-between;
  }
  .controls-row {
    flex-direction: column;
    align-items: stretch;
  }
  .card-footer {
    flex-direction: column;
    align-items: flex-start;
  }
}
