/* ============================================
   ASCA Volleyball - Styles
   ============================================ */

:root {
  /* Colors - ASCA Rouge */
  --primary: #e63946;
  --primary-dark: #d62828;
  --primary-light: #f4a5ae;
  --accent: #f59e0b;
  --success: #10b981;
  --danger: #ef4444;

  /* Podium colors */
  --gold: #ffd700;
  --silver: #c0c0c0;
  --bronze: #cd7f32;

  /* Background - Dark Mode (default) */
  --bg-dark: #0f0f1a;
  --bg-card: rgba(255, 255, 255, 0.05);
  --bg-card-hover: rgba(255, 255, 255, 0.08);

  /* Text - Dark Mode */
  --text-primary: #ffffff;
  --text-secondary: rgba(255, 255, 255, 0.7);
  --text-muted: rgba(255, 255, 255, 0.4);

  /* Borders */
  --border-color: rgba(255, 255, 255, 0.1);

  /* Shadows */
  --shadow-glow: 0 0 40px rgba(99, 102, 241, 0.3);

  /* Spacing */
  --radius: 16px;
  --radius-sm: 8px;
}

/* Light Mode */
[data-theme="light"] {
  --bg-dark: #f5f7fa;
  --bg-card: rgba(255, 255, 255, 0.9);
  --bg-card-hover: rgba(255, 255, 255, 1);

  --text-primary: #1a1a2e;
  --text-secondary: rgba(26, 26, 46, 0.7);
  --text-muted: rgba(26, 26, 46, 0.5);

  --border-color: rgba(0, 0, 0, 0.1);
  --shadow-glow: 0 4px 20px rgba(99, 102, 241, 0.15);
}

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

body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-dark);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
}

/* Background Gradient */
.background-gradient {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: radial-gradient(
      ellipse at 20% 20%,
      rgba(230, 57, 70, 0.15) 0%,
      transparent 50%
    ),
    radial-gradient(
      ellipse at 80% 80%,
      rgba(214, 40, 40, 0.1) 0%,
      transparent 50%
    ),
    radial-gradient(
      ellipse at 50% 50%,
      rgba(245, 158, 11, 0.05) 0%,
      transparent 50%
    );
  pointer-events: none;
  z-index: 0;
  transition: background 0.3s ease;
}

[data-theme="light"] .background-gradient {
  background: radial-gradient(
      ellipse at 20% 20%,
      rgba(230, 57, 70, 0.08) 0%,
      transparent 50%
    ),
    radial-gradient(
      ellipse at 80% 80%,
      rgba(214, 40, 40, 0.05) 0%,
      transparent 50%
    ),
    radial-gradient(
      ellipse at 50% 50%,
      rgba(245, 158, 11, 0.03) 0%,
      transparent 50%
    );
}

/* Container */
.container {
  position: relative;
  z-index: 1;
  max-width: 1400px;
  margin: 0 auto;
  padding: 2rem;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */
.header {
  margin-bottom: 2rem;
}

.header-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1.5rem;
}

.logo-section {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.logo {
  width: 56px;
  height: 56px;
  background: white;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-glow);
  overflow: hidden;
  padding: 4px;
}

.logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.title-section h1 {
  font-size: 1.75rem;
  font-weight: 700;
  background: linear-gradient(
    135deg,
    var(--text-primary) 0%,
    var(--primary-light) 100%
  );
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.subtitle {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-top: 0.25rem;
}

.last-update-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.5rem;
  padding: 0.5rem 0.75rem;
  background: rgba(99, 102, 241, 0.1);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--primary);
  width: fit-content;
}

.last-update-header svg {
  width: 14px;
  height: 14px;
  color: var(--primary);
}

/* Controls Section */
.controls-section {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

/* Season Selector */
.season-selector {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.season-selector label {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.season-selector select {
  padding: 0.5rem 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  min-width: 140px;
  transition: all 0.2s ease;
  backdrop-filter: blur(10px);
}

.season-selector select:hover {
  border-color: var(--primary);
}

.season-selector select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

.season-selector select option {
  background: var(--bg-dark);
  color: var(--text-primary);
}

/* Refresh Button */
.refresh-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.25rem;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  backdrop-filter: blur(10px);
}

.refresh-btn:hover {
  background: var(--bg-card-hover);
  border-color: var(--primary);
  box-shadow: 0 0 20px rgba(99, 102, 241, 0.2);
}

.refresh-btn:active {
  transform: scale(0.98);
}

.refresh-btn.loading .refresh-icon {
  animation: spin 1s linear infinite;
}

.refresh-icon {
  width: 18px;
  height: 18px;
  transition: transform 0.3s ease;
}

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

/* Theme Toggle Button */
.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.3s ease;
  backdrop-filter: blur(10px);
}

.theme-toggle:hover {
  background: var(--bg-card-hover);
  border-color: var(--primary);
  box-shadow: 0 0 20px rgba(99, 102, 241, 0.2);
}

.theme-toggle:active {
  transform: scale(0.95);
}

.theme-toggle svg {
  width: 20px;
  height: 20px;
  transition: all 0.3s ease;
}

/* Dark mode: show sun, hide moon */
.theme-toggle .icon-sun {
  display: block;
}

.theme-toggle .icon-moon {
  display: none;
}

/* Light mode: hide sun, show moon */
[data-theme="light"] .theme-toggle .icon-sun {
  display: none;
}

[data-theme="light"] .theme-toggle .icon-moon {
  display: block;
}

/* Main Content */
.main-content {
  flex: 1;
}

/* Loading State */
.loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4rem;
  gap: 1.5rem;
}

.spinner {
  width: 48px;
  height: 48px;
  border: 3px solid var(--border-color);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

.loading p {
  color: var(--text-secondary);
  font-size: 0.875rem;
}

/* Error State */
.error-message {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4rem;
  gap: 1rem;
  text-align: center;
}

.error-message svg {
  width: 48px;
  height: 48px;
  color: var(--danger);
}

.error-message p {
  color: var(--text-secondary);
}

.retry-btn {
  margin-top: 0.5rem;
  padding: 0.5rem 1rem;
  background: var(--danger);
  border: none;
  border-radius: var(--radius-sm);
  color: white;
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.retry-btn:hover {
  background: #dc2626;
}

/* Sections */
.section {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  backdrop-filter: blur(10px);
  margin-bottom: 2rem;
  overflow: hidden;
  animation: fadeIn 0.5s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-color);
  background: rgba(0, 0, 0, 0.2);
}

.section-header h2 {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-primary);
}

.section-header h2 svg {
  width: 22px;
  height: 22px;
  color: var(--primary-light);
}

.badge {
  padding: 0.375rem 0.75rem;
  background: var(--primary);
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  color: white;
}

/* Filter Section */
.filter-section {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.filter-section label {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.filter-section select {
  padding: 0.5rem 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.875rem;
  cursor: pointer;
  min-width: 200px;
  transition: all 0.2s ease;
}

.filter-section select:hover {
  border-color: var(--primary);
}

.filter-section select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

.filter-section select option {
  background: var(--bg-dark);
  color: var(--text-primary);
}

/* Matches Info */
.matches-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1.5rem;
  background: rgba(0, 0, 0, 0.1);
  font-size: 0.85rem;
  color: var(--text-muted);
}

.separator {
  color: var(--border-color);
}

/* Table Wrapper */
.table-wrapper {
  overflow-x: auto;
}

/* Standings Table */
.standings-table {
  width: 100%;
  border-collapse: collapse;
}

.standings-table th {
  padding: 0.875rem 1.25rem;
  text-align: left;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border-color);
}

.standings-table td {
  padding: 0.875rem 1.25rem;
  font-size: 0.9rem;
  border-bottom: 1px solid var(--border-color);
  transition: background 0.2s ease;
}

.standings-table tbody tr:last-child td {
  border-bottom: none;
}

.standings-table tbody tr:hover td {
  background: var(--bg-card-hover);
}

.rank-col {
  width: 50px;
  text-align: center !important;
}

.center-col {
  text-align: center !important;
  width: 60px;
}

/* Rank Styling */
.rank {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  font-weight: 700;
  font-size: 0.8rem;
}

.rank.gold {
  background: linear-gradient(135deg, var(--gold), #b8860b);
  color: #1a1a1a;
}

.rank.silver {
  background: linear-gradient(135deg, var(--silver), #a0a0a0);
  color: #1a1a1a;
}

.rank.bronze {
  background: linear-gradient(135deg, var(--bronze), #8b4513);
  color: white;
}

.rank.normal {
  background: var(--bg-card);
  color: var(--text-secondary);
}

/* Team Name in standings */
.team-name-standings {
  font-weight: 500;
}

.team-name-standings.highlight {
  color: var(--primary-light);
}

/* Stats */
.stat-points {
  font-weight: 700;
  color: var(--primary-light);
}

.stat-won {
  color: var(--success);
}

.stat-lost {
  color: var(--danger);
}

/* Matches Table */
.matches-table {
  width: 100%;
  border-collapse: collapse;
}

.matches-table th {
  padding: 0.875rem 1.25rem;
  text-align: left;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border-color);
}

.matches-table td {
  padding: 1rem 1.25rem;
  font-size: 0.9rem;
  border-bottom: 1px solid var(--border-color);
  transition: background 0.2s ease;
}

.matches-table tbody tr:last-child td {
  border-bottom: none;
}

.matches-table tbody tr:hover td {
  background: var(--bg-card-hover);
}

/* Match Row */
.date-cell {
  white-space: nowrap;
  color: var(--text-secondary);
}

.time-cell {
  color: var(--accent);
  font-weight: 500;
}

/* Team names in matches */
.team-cell {
  min-width: 180px;
}

.team-name {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 500;
}

.team-name.selected {
  color: var(--primary-light);
}

.team-name.selected::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  background: var(--primary);
  border-radius: 50%;
}

/* Score */
.score-col {
  text-align: center !important;
  width: 100px;
}

.score-display {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.25rem 0.75rem;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 20px;
  font-weight: 600;
  font-size: 0.9rem;
}

.score-display .vs {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-weight: 400;
}

.score-display.has-score .score1.winner {
  color: var(--success);
}

.score-display.has-score .score2.winner {
  color: var(--success);
}

.score-display.no-score {
  color: var(--text-muted);
  font-size: 0.75rem;
  text-transform: uppercase;
}

/* Venue */
.venue-cell {
  color: var(--text-secondary);
  max-width: 250px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* No results */
.no-results {
  padding: 3rem;
  text-align: center;
  color: var(--text-muted);
}

.no-results svg {
  width: 48px;
  height: 48px;
  margin-bottom: 1rem;
  opacity: 0.5;
}

/* ============================================
   Journées & Match Cards
   ============================================ */

.journees-container {
  padding: 1rem 1.5rem 1.5rem;
}

/* Journée Section */
.journee-section {
  margin-bottom: 2rem;
}

.journee-section:last-child {
  margin-bottom: 0;
}

.journee-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  background: linear-gradient(
    135deg,
    var(--primary) 0%,
    var(--primary-dark) 100%
  );
  border-radius: var(--radius-sm);
  margin-bottom: 1rem;
}

.journee-header h3 {
  font-size: 0.95rem;
  font-weight: 600;
  color: white;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.journee-header h3::before {
  content: "📅";
  font-size: 1rem;
}

.journee-count {
  font-size: 0.75rem;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.8);
  background: rgba(255, 255, 255, 0.2);
  padding: 0.25rem 0.75rem;
  border-radius: 20px;
}

/* Matches Grid */
.matches-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 1rem;
}

/* Match Card */
.match-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 1rem;
  transition: all 0.2s ease;
}

.match-card:hover {
  background: var(--bg-card-hover);
  border-color: var(--primary);
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
}

/* Match à venir - Style discret sans badge */
.match-card.upcoming-match {
  border-left: 4px solid var(--accent);
  background: linear-gradient(135deg, var(--bg-card) 0%, rgba(255, 193, 7, 0.03) 100%);
}

.match-card.upcoming-match:hover {
  border-color: var(--accent);
  box-shadow: 0 8px 25px rgba(255, 193, 7, 0.15);
}

/* PROCHAIN MATCH - Mise en évidence forte */
.match-card.next-match {
  position: relative;
  border: 2px solid var(--primary);
  border-left: 5px solid var(--primary);
  background: linear-gradient(135deg, var(--bg-card) 0%, rgba(200, 30, 50, 0.1) 100%);
  box-shadow: 0 4px 20px rgba(200, 30, 50, 0.25);
  animation: pulse-next 2s ease-in-out infinite;
}

.match-card.next-match::before {
  content: "🏐 PROCHAIN MATCH";
  position: absolute;
  top: -12px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: white;
  background: var(--primary);
  padding: 0.3rem 0.8rem;
  border-radius: 20px;
  white-space: nowrap;
  box-shadow: 0 2px 8px rgba(200, 30, 50, 0.4);
}

.match-card.next-match:hover {
  border-color: var(--primary-dark);
  transform: translateY(-4px) scale(1.02);
  box-shadow: 0 12px 35px rgba(200, 30, 50, 0.35);
}

@keyframes pulse-next {
  0%, 100% {
    box-shadow: 0 4px 20px rgba(200, 30, 50, 0.25);
  }
  50% {
    box-shadow: 0 4px 30px rgba(200, 30, 50, 0.4);
  }
}

/* Match Header */
.match-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border-color);
}

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

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

.match-time {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent);
  background: rgba(245, 158, 11, 0.15);
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
}

.match-status {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 0.25rem 0.6rem;
  border-radius: 4px;
}

.match-status.played {
  background: rgba(16, 185, 129, 0.15);
  color: var(--success);
}

.match-status.upcoming {
  background: rgba(99, 102, 241, 0.15);
  color: var(--primary-light);
}

/* Match Teams */
.match-teams {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.match-teams .team {
  flex: 1;
  text-align: center;
  padding: 0.5rem;
  border-radius: var(--radius-sm);
  transition: background 0.2s ease;
}

.match-teams .team:first-child {
  text-align: left;
}

.match-teams .team:last-child {
  text-align: right;
}

.match-teams .team.selected {
  background: rgba(99, 102, 241, 0.1);
}

.match-teams .team.winner .team-name {
  color: var(--success);
}

.match-teams .team .team-name {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-primary);
  display: block;
}

.match-teams .team.selected .team-name {
  color: var(--primary-light);
}

.match-teams .team.selected .team-name::before {
  content: "●";
  margin-right: 0.5rem;
  font-size: 0.6rem;
  vertical-align: middle;
}

/* Match Score */
.match-score {
  min-width: 80px;
  text-align: center;
  padding: 0.5rem 1rem;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.match-score.pending {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 1px;
}

.match-score.has-score .score {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
}

.match-score.has-score .score.winner {
  color: var(--success);
}

.match-score .score-separator {
  font-size: 0.9rem;
  color: var(--text-muted);
}

/* Sets Detail */
.sets-detail {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 0.5rem;
  flex-wrap: wrap;
}

.set-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.25rem 0.5rem;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  transition: transform 0.2s ease;
}

.set-badge:hover {
  transform: scale(1.05);
}

.set-win {
  color: var(--success);
}

.set-lose {
  color: var(--text-muted);
}

.set-sep {
  color: var(--text-muted);
  font-size: 0.7rem;
}

/* Match Venue */
.match-venue {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border-color);
  font-size: 0.8rem;
  color: var(--text-muted);
}

.match-venue svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

.match-venue span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Footer */
.footer {
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border-color);
  text-align: center;
}

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

.footer a {
  color: var(--primary-light);
  text-decoration: none;
  transition: color 0.2s ease;
}

.footer a:hover {
  color: var(--primary);
}

/* Responsive */
@media (max-width: 1024px) {
  .matches-table,
  .standings-table {
    min-width: 600px;
  }

  .matches-grid {
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  }
}

@media (max-width: 768px) {
  .section-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
  }

  .filter-section {
    width: 100%;
  }

  .filter-section select {
    flex: 1;
  }

  .matches-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .container {
    padding: 1rem;
  }

  .header-content {
    flex-direction: column;
    align-items: flex-start;
  }

  .refresh-btn {
    width: 100%;
    justify-content: center;
  }

  .title-section h1 {
    font-size: 1.5rem;
  }

  .matches-info {
    flex-wrap: wrap;
  }

  .journees-container {
    padding: 1rem;
  }

  .match-teams {
    flex-direction: column;
    gap: 0.5rem;
  }

  .match-teams .team {
    text-align: center !important;
    width: 100%;
  }

  .match-score {
    width: 100%;
  }
}

.footer-link {
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.2s;
}

.footer-link:hover {
  color: var(--primary);
  text-decoration: underline;
}
