/* ==========================================================================
   Great Plains Masters - Dark Mode Leaderboard Styles
   ========================================================================== */

/* CSS Variables */
:root {
  /* Background Colors */
  --bg-primary: #0d0d0d;
  --bg-secondary: #1a1a1a;
  --bg-tertiary: #252525;

  /* Accent Colors */
  --accent-red: #e52228;
  --accent-red: #c41e3a;
  --accent-silver: #c0c0c0;
  --accent-bronze: #cd7f32;

  /* Text Colors */
  --text-primary: #ffffff;
  --text-secondary: #b0b0b0;
  --text-muted: #666666;

  /* Table Colors */
  --row-odd: #1a1a1a;
  --row-even: #141414;
  --row-hover: #2a2a2a;

  /* Borders */
  --border-subtle: #333333;
  --border-accent: #e52228;

  /* Spacing */
  --spacing-xs: 0.25rem;
  --spacing-sm: 0.5rem;
  --spacing-md: 1rem;
  --spacing-lg: 1.5rem;
  --spacing-xl: 2rem;
  --spacing-2xl: 3rem;
}

/* ==========================================================================
   Base Styles
   ========================================================================== */

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-secondary);
  line-height: 1.6;
  min-height: 100vh;
}

/* ==========================================================================
   Typography
   ========================================================================== */

h1, h2, h3, h4, h5, h6 {
  font-family: 'Oswald', 'Impact', sans-serif;
  color: var(--text-primary);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

h1 { font-size: 2.5rem; }
h2 { font-size: 1.75rem; }
h3 { font-size: 1.25rem; }

/* ==========================================================================
   Layout
   ========================================================================== */

.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 var(--spacing-md);
}

/* ==========================================================================
   Header
   ========================================================================== */

.site-header {
  background: #e52228;
  border-bottom: none;
  padding: var(--spacing-md) 0;
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--spacing-md);
}

.logo-section {
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
}

.logo {
  height: 60px;
  width: auto;
}

.site-title {
  font-size: 1.5rem;
  margin: 0;
}

/* ==========================================================================
   Page Navigation
   ========================================================================== */

.page-nav {
  display: flex;
  gap: var(--spacing-sm);
  align-items: center;
}

.nav-link {
  color: var(--text-primary);
  text-decoration: none;
  font-family: 'Oswald', sans-serif;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: var(--spacing-sm) var(--spacing-md);
  border-radius: 4px;
  transition: background 0.2s ease;
}

.nav-link:hover {
  background: rgba(0, 0, 0, 0.2);
}

.nav-link.active {
  background: rgba(0, 0, 0, 0.3);
}

/* ==========================================================================
   Season Navigation
   ========================================================================== */

.season-nav {
  display: flex;
  gap: var(--spacing-sm);
}

.season-tab {
  display: inline-block;
  padding: var(--spacing-sm) var(--spacing-lg);
  background: rgba(0, 0, 0, 0.2);
  color: var(--text-primary);
  text-decoration: none;
  font-family: 'Oswald', sans-serif;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 4px;
  transition: all 0.2s ease;
  cursor: pointer;
}

.season-tab:hover {
  background: rgba(0, 0, 0, 0.4);
  color: var(--text-primary);
}

.season-tab.active {
  background: var(--text-primary);
  color: #e52228;
  border-color: var(--text-primary);
}

/* ==========================================================================
   Top 3 Podium
   ========================================================================== */

.podium-section {
  padding: var(--spacing-2xl) 0;
  text-align: center;
}

.podium-title {
  margin-bottom: var(--spacing-xl);
  color: #e52228;
}

.podium {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  gap: var(--spacing-lg);
  max-width: 900px;
  margin: 0 auto;
}

.podium-place {
  flex: 1;
  max-width: 280px;
  background: var(--bg-secondary);
  border-radius: 8px;
  padding: var(--spacing-lg);
  border: 2px solid var(--border-subtle);
  transition: transform 0.2s ease;
}

.podium-place:hover {
  transform: translateY(-4px);
}

.podium-place.gold {
  border-color: #e52228;
  order: 2;
  padding-bottom: var(--spacing-2xl);
}

.podium-place.silver {
  border-color: #ff6b6b;
  order: 1;
}

.podium-place.bronze {
  border-color: #c9302c;
  order: 3;
}

.podium-rank {
  font-family: 'Oswald', sans-serif;
  font-size: 3rem;
  font-weight: 700;
  line-height: 1;
  margin-bottom: var(--spacing-sm);
}

.gold .podium-rank { color: #e52228; }
.silver .podium-rank { color: #ff6b6b; }
.bronze .podium-rank { color: #c9302c; }

.podium-player {
  font-family: 'Oswald', sans-serif;
  font-size: 1.25rem;
  color: var(--text-primary);
  margin-bottom: var(--spacing-xs);
  text-transform: uppercase;
}

.podium-club {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-bottom: var(--spacing-sm);
}

.podium-score {
  font-family: 'JetBrains Mono', monospace;
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text-primary);
}

.podium-score span {
  font-size: 0.875rem;
  color: var(--text-muted);
  font-weight: 400;
}

.podium-army {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: var(--spacing-sm);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

/* ==========================================================================
   Controls Section
   ========================================================================== */

.controls-section {
  padding: var(--spacing-lg) 0;
  border-bottom: 1px solid var(--border-subtle);
}

.controls-wrapper {
  display: flex;
  flex-wrap: wrap;
  gap: var(--spacing-md);
  align-items: center;
  justify-content: space-between;
}

.search-box {
  flex: 1;
  min-width: 200px;
  max-width: 400px;
}

.search-input {
  width: 100%;
  padding: var(--spacing-sm) var(--spacing-md);
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  color: var(--text-primary);
  font-size: 0.875rem;
  transition: border-color 0.2s ease;
}

.search-input:focus {
  outline: none;
  border-color: #e52228;
}

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

.filter-group {
  display: flex;
  gap: var(--spacing-sm);
  align-items: center;
}

.filter-select {
  padding: var(--spacing-sm) var(--spacing-md);
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  color: var(--text-primary);
  font-size: 0.875rem;
  cursor: pointer;
}

.filter-select:focus {
  outline: none;
  border-color: #e52228;
}

.stats-bar {
  display: flex;
  gap: var(--spacing-lg);
}

.stat-item {
  text-align: center;
}

.stat-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 1.25rem;
  font-weight: 600;
  color: #e52228;
}

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

/* ==========================================================================
   Leaderboard Table
   ========================================================================== */

.leaderboard-section {
  padding: var(--spacing-xl) 0 var(--spacing-2xl);
}

#leaderboard-table {
  background: transparent;
  border: none;
}

/* Tabulator Overrides for Dark Theme */
.tabulator {
  background-color: transparent;
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  overflow: hidden;
}

.tabulator .tabulator-header {
  background: var(--bg-secondary);
  border-bottom: 2px solid #e52228;
}

.tabulator .tabulator-header .tabulator-col {
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-subtle);
}

.tabulator .tabulator-header .tabulator-col.tabulator-sortable:hover {
  background: var(--bg-tertiary);
}

.tabulator .tabulator-header .tabulator-col .tabulator-col-content {
  padding: var(--spacing-md);
}

.tabulator .tabulator-header .tabulator-col .tabulator-col-title {
  font-family: 'Oswald', sans-serif;
  font-weight: 600;
  color: var(--text-primary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.tabulator .tabulator-tableholder .tabulator-table {
  background: transparent;
}

.tabulator-row {
  background: var(--row-odd);
  border-bottom: 1px solid var(--border-subtle);
  transition: background-color 0.15s ease;
}

.tabulator-row:nth-child(even) {
  background: var(--row-even);
}

.tabulator-row:hover {
  background: var(--row-hover) !important;
}

.tabulator-row .tabulator-cell {
  padding: var(--spacing-md);
  border-right: 1px solid var(--border-subtle);
  color: var(--text-secondary);
}

/* Top 3 Row Highlights - Red Theme */
.tabulator-row.rank-gold {
  background: linear-gradient(90deg, rgba(229,34,40,0.25) 0%, transparent 50%) !important;
  border-left: 4px solid #e52228;
}

.tabulator-row.rank-silver {
  background: linear-gradient(90deg, rgba(229,34,40,0.15) 0%, transparent 50%) !important;
  border-left: 4px solid #ff6b6b;
}

.tabulator-row.rank-bronze {
  background: linear-gradient(90deg, rgba(229,34,40,0.08) 0%, transparent 50%) !important;
  border-left: 4px solid #c9302c;
}

.tabulator-row.top-ten {
  font-weight: 500;
}

/* Medal Icons */
.medal {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-family: 'Oswald', sans-serif;
  font-weight: 700;
  font-size: 1rem;
}

.medal.gold {
  background: linear-gradient(135deg, #e52228 0%, #ff4d4d 50%, #e52228 100%);
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(229, 34, 40, 0.5);
}

.medal.silver {
  background: linear-gradient(135deg, #ff6b6b 0%, #ff8a8a 50%, #ff6b6b 100%);
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(255, 107, 107, 0.4);
}

.medal.bronze {
  background: linear-gradient(135deg, #c9302c 0%, #e04a47 50%, #c9302c 100%);
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(201, 48, 44, 0.4);
}

/* Score Bar */
.score-cell {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
}

.score-value {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 600;
  color: var(--text-primary);
  z-index: 1;
  min-width: 50px;
}

.score-bar {
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  height: 60%;
  background: linear-gradient(90deg, rgba(212, 175, 55, 0.3) 0%, rgba(212, 175, 55, 0.1) 100%);
  border-radius: 2px;
  z-index: 0;
}

/* Record Badge */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.75rem;
  font-weight: 500;
  background: var(--bg-tertiary);
  color: var(--text-secondary);
}

.badge.perfect {
  background: rgba(212, 175, 55, 0.2);
  color: #e52228;
  border: 1px solid #e52228;
}

/* Player Name */
.player-name {
  color: var(--text-primary);
  font-weight: 500;
}

/* ==========================================================================
   Loading State
   ========================================================================== */

.loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--spacing-2xl);
  color: var(--text-muted);
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border-subtle);
  border-top-color: #e52228;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: var(--spacing-md);
}

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

.loading.hidden {
  display: none;
}

/* ==========================================================================
   Error State
   ========================================================================== */

.error-message {
  text-align: center;
  padding: var(--spacing-2xl);
  color: var(--accent-red);
}

.error-message.hidden {
  display: none;
}

/* ==========================================================================
   Footer
   ========================================================================== */

.site-footer {
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-subtle);
  padding: var(--spacing-lg) 0;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.875rem;
}

/* ==========================================================================
   Responsive Design
   ========================================================================== */

@media (max-width: 768px) {
  .header-content {
    flex-direction: column;
    text-align: center;
  }

  .logo-section {
    flex-direction: column;
  }

  .site-title {
    font-size: 1.25rem;
  }

  .season-nav {
    width: 100%;
    justify-content: center;
  }

  .podium {
    flex-direction: column;
    align-items: center;
  }

  .podium-place {
    max-width: 100%;
    width: 100%;
  }

  .podium-place.gold {
    order: 1;
    padding-bottom: var(--spacing-lg);
  }

  .podium-place.silver {
    order: 2;
  }

  .podium-place.bronze {
    order: 3;
  }

  .controls-wrapper {
    flex-direction: column;
  }

  .search-box {
    max-width: 100%;
    width: 100%;
  }

  .stats-bar {
    width: 100%;
    justify-content: space-around;
  }

  .tabulator .tabulator-header .tabulator-col .tabulator-col-content,
  .tabulator-row .tabulator-cell {
    padding: var(--spacing-sm);
  }
}

@media (max-width: 480px) {
  html {
    font-size: 14px;
  }

  .logo {
    height: 48px;
  }

  .podium-rank {
    font-size: 2rem;
  }

  .medal {
    width: 28px;
    height: 28px;
    font-size: 0.875rem;
  }
}

/* ==========================================================================
   Tabulator Responsive Collapse
   ========================================================================== */

.tabulator-responsive-collapse {
  border: none;
  padding: var(--spacing-sm) var(--spacing-md);
  background: var(--bg-tertiary);
}

.tabulator-responsive-collapse table {
  width: 100%;
}

.tabulator-responsive-collapse table tr td {
  padding: var(--spacing-xs) var(--spacing-sm);
}

.tabulator-responsive-collapse table tr td:first-child {
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  font-size: 0.75rem;
}

.tabulator-responsive-collapse-toggle {
  color: #e52228;
}

/* ==========================================================================
   Player Modal
   ========================================================================== */

.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--spacing-md);
}

.modal.hidden {
  display: none !important;
  visibility: hidden;
}

.modal-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(4px);
}

.modal-content {
  position: relative;
  background: var(--bg-secondary);
  border-radius: 12px;
  max-width: 600px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  padding: var(--spacing-xl);
  border: 1px solid var(--border-subtle);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.modal-close {
  position: absolute;
  top: var(--spacing-md);
  right: var(--spacing-md);
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 2rem;
  cursor: pointer;
  line-height: 1;
  padding: 0;
  transition: color 0.2s ease;
}

.modal-close:hover {
  color: #e52228;
}

.modal-header {
  display: flex;
  align-items: center;
  gap: var(--spacing-lg);
  margin-bottom: var(--spacing-xl);
  padding-bottom: var(--spacing-lg);
  border-bottom: 1px solid var(--border-subtle);
}

.modal-rank {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Oswald', sans-serif;
  font-size: 1.5rem;
  font-weight: 700;
  background: var(--bg-tertiary);
  color: var(--text-muted);
  flex-shrink: 0;
}

.modal-rank.rank-1 {
  background: linear-gradient(135deg, #e52228 0%, #ff4d4d 50%, #e52228 100%);
  color: #ffffff;
  box-shadow: 0 4px 15px rgba(229, 34, 40, 0.4);
}

.modal-rank.rank-2 {
  background: linear-gradient(135deg, #ff6b6b 0%, #ff8a8a 50%, #ff6b6b 100%);
  color: #ffffff;
  box-shadow: 0 4px 15px rgba(255, 107, 107, 0.3);
}

.modal-rank.rank-3 {
  background: linear-gradient(135deg, #c9302c 0%, #e04a47 50%, #c9302c 100%);
  color: #ffffff;
  box-shadow: 0 4px 15px rgba(201, 48, 44, 0.3);
}

.modal-player-info {
  flex: 1;
}

.modal-player-name {
  font-family: 'Oswald', sans-serif;
  font-size: 1.75rem;
  color: var(--text-primary);
  margin: 0 0 var(--spacing-xs) 0;
  text-transform: uppercase;
}

.modal-army {
  color: var(--text-muted);
  margin: 0;
  font-size: 0.875rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.modal-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--spacing-md);
  margin-bottom: var(--spacing-xl);
}

.modal-stat-card {
  background: var(--bg-tertiary);
  border-radius: 8px;
  padding: var(--spacing-lg);
  text-align: center;
}

.modal-stat-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 2rem;
  font-weight: 700;
  color: #e52228;
  margin-bottom: var(--spacing-xs);
}

.modal-stat-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.modal-tournaments h3,
.modal-regionals h3 {
  font-family: 'Oswald', sans-serif;
  font-size: 1rem;
  color: var(--text-secondary);
  margin-bottom: var(--spacing-md);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.tournament-grid,
.regional-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: var(--spacing-sm);
}

.tournament-item,
.regional-item {
  background: var(--bg-tertiary);
  border-radius: 6px;
  padding: var(--spacing-sm) var(--spacing-md);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.tournament-item.has-score {
  border-left: 3px solid #e52228;
}

.tournament-item.no-score {
  opacity: 0.5;
}

.tournament-name {
  font-size: 0.75rem;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 80px;
}

.tournament-score,
.tournament-value {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 600;
  color: var(--text-primary);
}

.tournament-score.no-score,
.tournament-value.no-score {
  color: var(--text-muted);
}

.modal-regionals {
  margin-top: var(--spacing-lg);
}

/* Modal responsive */
@media (max-width: 480px) {
  .modal-content {
    padding: var(--spacing-md);
  }

  .modal-header {
    flex-direction: column;
    text-align: center;
  }

  .modal-stats {
    grid-template-columns: 1fr;
  }

  .modal-stat-value {
    font-size: 1.5rem;
  }

  .tournament-grid,
  .regional-grid {
    grid-template-columns: 1fr 1fr;
  }
}

/* Clickable player name */
.player-name-link {
  cursor: pointer;
  transition: color 0.2s ease;
}

.player-name-link:hover {
  color: #e52228;
  text-decoration: underline;
}
