/* =============================================
   V5 ANALYSIS — Fresh Design System
   Phosphor Green dark sci-fi theme
   Mobile-first responsive layout
   ============================================= */

/* =============================================
   DESIGN TOKENS
   ============================================= */
.v5-body {
  --v5-glow: #00ff88;
  --v5-glow-rgb: 0,255,136;
  --v5-surface-0: #060907;
  --v5-surface-1: #0c100e;
  --v5-surface-2: #121714;
  --v5-surface-3: #181e1a;
  --v5-surface-4: #1f2622;
  --v5-border: rgba(255,255,255,0.05);
  --v5-border-glow: rgba(0,255,136,0.10);
  --v5-text-primary: rgba(255,255,255,0.92);
  --v5-text-secondary: rgba(255,255,255,0.55);
  --v5-text-muted: rgba(255,255,255,0.28);
  --v5-danger: #ef4444;
  --v5-warning: #fbbf24;
  --v5-radius: 8px;
}

/* =============================================
   BASE / RESET
   ============================================= */
.v5-body {
  background: var(--v5-surface-0);
  color: var(--v5-text-primary);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  font-size: 13px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
  margin: 0;
  padding: 0;
  overflow-x: hidden;
}

.v5-body a { color: inherit; text-decoration: none; }

/* =============================================
   PAGE WRAPPER
   ============================================= */
.v5-page {
  max-width: 1800px;
  margin: 0 auto;
  padding: 12px;
}

@media (min-width: 768px) {
  .v5-page { padding: 16px; }
}

/* =============================================
   FIXTURE HEADER
   ============================================= */
.v5-header {
  text-align: center;
  padding: 16px 20px 14px;
  background: linear-gradient(180deg, rgba(var(--v5-glow-rgb),0.05) 0%, transparent 50%);
  border: 1px solid var(--v5-border-glow);
  border-radius: var(--v5-radius);
  position: relative;
  overflow: hidden;
  margin-bottom: 12px;
}

/* Top glow accent line */
.v5-header::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent 10%, rgba(var(--v5-glow-rgb),0.5) 50%, transparent 90%);
  box-shadow: 0 0 12px rgba(var(--v5-glow-rgb),0.2);
}

.v5-header__meta-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 14px;
}

.v5-header__league {
  font-size: 10px;
  font-weight: 500;
  color: var(--v5-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.v5-header__dot { color: rgba(255,255,255,0.1); }

.v5-header__stat-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--v5-glow);
  text-shadow: 0 0 6px rgba(var(--v5-glow-rgb),0.3);
}

.v5-header__teams {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
}

@media (min-width: 480px) {
  .v5-header__teams { gap: 32px; }
}

.v5-header__team {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  min-width: 80px;
}

.v5-header__team-link {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  transition: opacity 0.15s;
}

.v5-header__team-link:hover { opacity: 0.7; }

.v5-header__logo {
  width: 40px;
  height: 40px;
  object-fit: contain;
}

@media (min-width: 480px) {
  .v5-header__logo { width: 48px; height: 48px; }
}

.v5-header__logo-placeholder {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--v5-border);
}

.v5-header__team-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--v5-text-primary);
}

@media (min-width: 480px) {
  .v5-header__team-name { font-size: 13px; }
}

.v5-header__center {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}

.v5-header__vs {
  font-size: 18px;
  font-weight: 700;
  color: rgba(var(--v5-glow-rgb),0.15);
  text-shadow: 0 0 16px rgba(var(--v5-glow-rgb),0.08);
}

.v5-header__kickoff {
  font-size: 11px;
  font-weight: 600;
  color: rgba(var(--v5-glow-rgb),0.6);
  text-shadow: 0 0 4px rgba(var(--v5-glow-rgb),0.2);
}

.v5-header__info {
  font-size: 10px;
  color: var(--v5-text-muted);
  margin-top: 12px;
}

.v5-header__info-dot {
  margin: 0 6px;
  opacity: 0.4;
}

/* =============================================
   FILTER BAR
   ============================================= */
.v5-filters {
  background: var(--v5-surface-1);
  border: 1px solid var(--v5-border);
  border-radius: var(--v5-radius);
  padding: 10px 12px;
  margin-bottom: 12px;
}

.v5-filter-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.v5-filter-row + .v5-filter-row {
  margin-top: 8px;
}

.v5-filter-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.v5-filter-group--grow {
  flex: 1;
  min-width: 160px;
}

.v5-filter-label {
  font-size: 9px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  color: var(--v5-text-muted);
  white-space: nowrap;
}

.v5-filter-divider {
  width: 1px;
  height: 20px;
  background: rgba(255,255,255,0.06);
  flex-shrink: 0;
}

/* Toggle buttons (Fouls / Fouls Drawn, All / Lineup Only) */
.v5-toggle {
  display: inline-flex;
  background: rgba(0,0,0,0.35);
  border-radius: 5px;
  padding: 2px;
  gap: 1px;
}

.v5-toggle__btn {
  padding: 5px 10px;
  font-size: 10px;
  font-weight: 500;
  border: none;
  border-radius: 3px;
  cursor: pointer;
  background: transparent;
  color: var(--v5-text-secondary);
  transition: all 0.15s;
  text-decoration: none;
  white-space: nowrap;
  min-height: 28px;
  display: inline-flex;
  align-items: center;
}

.v5-toggle__btn:hover {
  color: rgba(255,255,255,0.7);
  background: rgba(255,255,255,0.04);
}

.v5-toggle__btn--active {
  background: rgba(var(--v5-glow-rgb),0.18) !important;
  color: #fff !important;
  box-shadow: 0 0 0 1px rgba(var(--v5-glow-rgb),0.25);
}

/* Select dropdowns */
.v5-select {
  padding: 5px 22px 5px 8px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 500;
  background: rgba(0,0,0,0.35);
  color: var(--v5-text-secondary);
  border: 1px solid rgba(255,255,255,0.05);
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='8' viewBox='0 0 24 24' fill='none' stroke='rgba(255,255,255,0.3)' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 6px center;
  min-height: 28px;
}

.v5-select:hover {
  border-color: rgba(255,255,255,0.1);
  color: rgba(255,255,255,0.7);
}

.v5-select--grow {
  flex: 1;
  min-width: 140px;
}

/* =============================================
   MAIN CONTENT WRAPPER
   Scopes fresh styling for inner partials
   ============================================= */
.v5-content {
  opacity: 0;
  animation: v5-fadeIn 0.3s ease forwards;
}

@keyframes v5-fadeIn {
  to { opacity: 1; }
}

/* =============================================
   OVERRIDES FOR EXISTING PARTIAL STRUCTURE
   These override styles from _pitch.css, _v4_prop_bets.css
   to apply the fresh V5 aesthetic within .v5-page
   ============================================= */

/* The opposition_profile card wrapper — remove old card styling */
.v5-page .card-opposition-profile {
  background: transparent;
  border: none;
  box-shadow: none;
  margin: 0;
  border-radius: 0;
}

/* Hide the "Opposition Profile" header bar — redundant in v5 layout */
.v5-page .card-opposition-profile > .bg-subtle {
  display: none;
}

/* Clean up card-body padding — override .p-3 utility from css-zero */
.v5-page .card-opposition-profile > .card-body,
.v5-page .card-opposition-profile > .p-3 {
  padding: 0 !important;
}

/* Remove formation-split-view padding */
.v5-page .formation-split-view {
  padding: 0;
}

/* Override generic card styles within v5 pitch area */
.v5-page .column-left .card {
  background: transparent;
  border: none;
  box-shadow: none;
}

/* But keep card styles inside the analysis column */
.v5-page .column-right .card {
  background: var(--v5-surface-2);
  border: 1px solid var(--v5-border);
  border-radius: 6px;
}

/* Override the columns-container grid — wide analysis panel */
.v5-page .columns-container {
  display: grid;
  grid-template-columns: 1fr 840px;
  gap: 16px;
  align-items: start;
}

/* Fresh analysis panel styling */
.v5-page .column-right {
  position: sticky;
  top: 12px;
  max-height: calc(100vh - 24px);
  overflow-y: auto;
  overflow-x: hidden;
  background: var(--v5-surface-1);
  border: 1px solid var(--v5-border-glow);
  border-radius: var(--v5-radius);
  padding: 14px;
  scrollbar-width: thin;
  scrollbar-color: rgba(var(--v5-glow-rgb),0.12) transparent;
}

.v5-page .column-right::-webkit-scrollbar { width: 3px; }
.v5-page .column-right::-webkit-scrollbar-track { background: transparent; }
.v5-page .column-right::-webkit-scrollbar-thumb {
  background: rgba(var(--v5-glow-rgb),0.15);
  border-radius: 2px;
}
.v5-page .column-right:hover::-webkit-scrollbar-thumb {
  background: rgba(var(--v5-glow-rgb),0.3);
}

/* Remove extra padding from pis-12 class */
.v5-page .column-right.pis-12 {
  padding-inline-start: 14px;
}

/* Pitch area — keep internal structure, just clean up outer wrapper */
.v5-page .column-left {
  min-width: 0;
}

/* Split pitch container — add subtle border */
.v5-page .split-pitch-container {
  border: 1px solid rgba(var(--v5-glow-rgb),0.06);
  border-radius: var(--v5-radius);
  overflow: hidden;
}

/* Tab navigation — freshen up */
.v5-page .analysis-tab-btn {
  font-size: 11px;
  font-weight: 500;
  padding: 8px 14px;
  color: var(--v5-text-muted);
  border: none;
  background: transparent;
  cursor: pointer;
  transition: color 0.15s;
  border-bottom: 2px solid transparent;
}

.v5-page .analysis-tab-btn:hover {
  color: var(--v5-text-secondary);
}

.v5-page .analysis-tab-btn.active,
.v5-page .analysis-tab-btn--active {
  color: var(--v5-glow);
  border-bottom-color: var(--v5-glow);
  text-shadow: 0 0 6px rgba(var(--v5-glow-rgb),0.25);
}

/* Summary section cards — cleaner containers */
.v5-page .summary-factor-card {
  background: var(--v5-surface-2);
  border: 1px solid var(--v5-border);
  border-radius: 6px;
  padding: 12px;
  margin-bottom: 10px;
}

.v5-page .summary-section-title {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--v5-text-muted);
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--v5-border);
}

/* Filter toggles inside pitch — match v5 aesthetic */
.v5-page .filter-toggle {
  background: rgba(0,0,0,0.35);
  border-radius: 5px;
  padding: 2px;
}

.v5-page .filter-toggle__btn {
  font-size: 10px;
  padding: 4px 8px;
  border-radius: 3px;
  min-height: 24px;
}

.v5-page .filter-toggle__btn--active {
  background: rgba(var(--v5-glow-rgb),0.18);
  color: #fff;
  box-shadow: 0 0 0 1px rgba(var(--v5-glow-rgb),0.25);
}

/* Pitch sub-filter bars */
.v5-page .pitch-global-filter-bar,
.v5-page .pitch-filter-bar {
  background: var(--v5-surface-1);
  border: 1px solid var(--v5-border);
  border-radius: 6px;
  padding: 8px 10px;
  margin-bottom: 8px;
}

/* Loading overlay */
.v5-page .v4-loading-overlay {
  background: rgba(6,9,7,0.5);
  backdrop-filter: blur(3px);
}

/* Stat boxes — ensure clean look */
.v5-page .summary-stat-boxes {
  gap: 4px;
}

.v5-page .summary-stat-box {
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  min-width: 28px;
  padding: 4px 6px;
}

/* Sidelined / Substitutes sections — compact */
.v5-page .formation-sidelined-section,
.v5-page .formation-substitutes-section,
.v5-page .formation-transfers-section {
  background: var(--v5-surface-1);
  border: 1px solid var(--v5-border);
  border-radius: 6px;
  margin-top: 8px;
  padding: 10px;
}

/* Hide legacy container styles that leak from old page CSS */
.v5-page .v4-opposition-profile-container {
  max-width: none;
}

.v5-page .v4-clickable-mode {
  position: relative;
}

/* =============================================
   TABLET: Stacked single-column
   ============================================= */
@media (max-width: 1399px) {
  .v5-page .columns-container {
    grid-template-columns: 1fr;
    max-width: 760px;
    margin: 0 auto;
  }

  .v5-page .column-right {
    position: static;
    max-height: none;
    overflow-y: visible;
    margin-top: 12px;
  }

  .v5-page .column-right.pis-12 {
    padding-inline-start: 14px;
  }

  .v5-header {
    max-width: 760px;
    margin-inline: auto;
    margin-bottom: 12px;
  }

  .v5-filters {
    max-width: 760px;
    margin-inline: auto;
    margin-bottom: 12px;
  }
}

/* =============================================
   MOBILE: Compact layout + modal-ready
   ============================================= */
@media (max-width: 767px) {
  .v5-page {
    padding: 8px;
  }

  .v5-header {
    padding: 12px 14px 10px;
  }

  .v5-header__teams {
    gap: 16px;
  }

  .v5-header__logo {
    width: 36px;
    height: 36px;
  }

  .v5-header__team-name {
    font-size: 11px;
  }

  .v5-header__vs {
    font-size: 16px;
  }

  .v5-filters {
    padding: 8px 10px;
  }

  .v5-filter-row {
    gap: 8px;
  }

  .v5-toggle__btn {
    padding: 5px 8px;
    font-size: 10px;
    min-height: 32px;
  }

  .v5-select {
    font-size: 10px;
    min-height: 32px;
  }

  /* Analysis panel — full width on mobile */
  .v5-page .column-right {
    padding: 10px;
    border-radius: 6px;
  }

  /* Pitch filter bars — wrap and compact */
  .v5-page .pitch-global-filter-bar,
  .v5-page .pitch-filter-bar {
    padding: 6px 8px;
  }

  /* Pitch team toggle — larger tap targets */
  .v5-page .pitch-team-toggle__btn {
    padding: 10px 14px;
    font-size: 12px;
    min-height: 44px;
  }
}

/* =============================================
   MOBILE ANALYSIS MODAL (< 1000px)
   Slide-up panel for player analysis
   ============================================= */
.v5-modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 1000;
  opacity: 0;
  transition: opacity 0.25s ease;
}

.v5-modal-overlay--active {
  display: block;
  opacity: 1;
}

.v5-modal {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  max-height: 80vh;
  background: var(--v5-surface-1);
  border-top: 1px solid var(--v5-border-glow);
  border-radius: 14px 14px 0 0;
  z-index: 1001;
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
  overflow: hidden;
  display: none;
}

.v5-modal--active {
  display: block;
  transform: translateY(0);
}

.v5-modal__handle {
  display: flex;
  justify-content: center;
  padding: 8px 0 4px;
}

.v5-modal__handle-bar {
  width: 36px;
  height: 4px;
  background: rgba(255,255,255,0.15);
  border-radius: 2px;
}

.v5-modal__content {
  overflow-y: auto;
  max-height: calc(80vh - 20px);
  padding: 0 14px 14px;
  -webkit-overflow-scrolling: touch;
}

/* =============================================
   UTILITY HELPERS
   ============================================= */
.v5-text-glow {
  color: var(--v5-glow);
  text-shadow: 0 0 6px rgba(var(--v5-glow-rgb),0.3);
}

.v5-text-muted { color: var(--v5-text-muted); }
.v5-text-warning { color: var(--v5-warning); }
.v5-text-danger { color: var(--v5-danger); }

/* Error state */
.v5-error {
  text-align: center;
  padding: 40px 20px;
  color: var(--v5-text-secondary);
}

.v5-error__icon {
  font-size: 24px;
  margin-bottom: 12px;
  opacity: 0.5;
}

/* =============================================
   FADE-IN ANIMATION
   ============================================= */
.v5-fade-in {
  opacity: 0;
  animation: v5-fadeIn 0.3s ease 0.05s forwards;
}
