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

body {
  font-family: "Poppins", sans-serif !important;
  background-color: #0d0d0d;
  color: #fff;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

*,
button,
input,
select,
textarea,
span,
div,
p,
a,
h1,
h2,
h3,
h4,
th,
td {
  font-family: "Poppins", sans-serif !important;
}

/* Loading Screen */
.loading-screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: #0d0d0d;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 9999;
  transition: opacity 0.5s ease, visibility 0.5s ease;
}

.loading-screen.hidden {
  opacity: 0;
  visibility: hidden;
}

.loader {
  width: 60px;
  height: 60px;
  border: 4px solid rgba(255, 204, 0, 0.2);
  border-top-color: #ffcc00;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

/* Navbar */
.navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 2rem;
  background: rgba(20, 20, 20, 0.8);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(255, 215, 0, 0.2);
  position: sticky;
  top: 0;
  z-index: 100;
}

.table-container {
  /* overflow-x: auto; Moved to media query */
  background: rgba(20, 20, 20, 0.4);
  border-radius: 4px;
}

/* Logo */
.logo-container {
  display: flex;
  align-items: center;
  gap: 8px;
}

.logo-container a {
  display: flex;
  align-items: center;
}

.logo-img {
  height: 40px;
}

/* Navigation */
.nav-links {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.nav-links a {
  color: #fff;
  text-decoration: none;
  font-weight: 500;
  transition: color 0.3s;
}

.nav-links a:hover {
  color: #ffcc00;
}

.nav-links a.active {
  color: #ffcc00;
}

/* Search box */
.search-box {
  display: flex;
  align-items: center;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  padding: 4px 10px;
  backdrop-filter: blur(8px);
}

.search-box input {
  border: none;
  outline: none;
  background: transparent;
  color: white;
  padding: 5px;
  width: 150px;
}

.search-box button {
  border: none;
  background: transparent;
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
}

.search-box button img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* Burger Icon */
.burger {
  display: none;
  flex-direction: column;
  justify-content: center;
  cursor: pointer;
  width: 25px;
  height: 20px;
  gap: 5px;
}

.burger span {
  background: #ffcc00;
  height: 3px;
  width: 100%;
  border-radius: 5px;
  transition: 0.4s;
}

.burger.active span:nth-child(1) {
  transform: rotate(45deg) translateY(8px);
}

.burger.active span:nth-child(2) {
  opacity: 0;
}

.burger.active span:nth-child(3) {
  transform: rotate(-45deg) translateY(-8px);
}

/* Mobile Menu */
.mobile-menu {
  display: flex;
  flex-direction: column;
  background: rgba(10, 10, 10, 0.95);
  backdrop-filter: blur(12px);
  position: fixed;
  top: 0;
  left: 0;
  height: 100%;
  width: 100%;
  justify-content: center;
  align-items: center;
  gap: 1.5rem;
  z-index: 90;
  opacity: 0;
  pointer-events: none;
  transform: scale(1.05);
  transition: all 0.4s ease;
}

.mobile-menu.open {
  opacity: 1;
  pointer-events: auto;
  transform: scale(1);
}

.mobile-menu a {
  color: #ffcc00;
  font-size: 1.4rem;
  text-decoration: none;
}

.mobile-menu a.active {
  text-decoration: underline;
}

.search-box-mobile {
  display: flex;
  align-items: center;
  gap: 5px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  padding: 5px 10px;
}

.search-box-mobile input {
  background: transparent;
  border: none;
  color: #fff;
  outline: none;
}

.search-box-mobile button {
  border: none;
  background: transparent;
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
}

.search-box-mobile button img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}


/* Event Dashboard */
.event-dashboard {
  padding: 2rem;
  max-width: 1400px;
  margin: 0 auto;
}

/* Tournament Header */
.tournament-header {
  background: rgba(20, 20, 20, 0.4);
  padding: 2rem;
  border-radius: 4px;
  margin-bottom: 2rem;
}

.header-main {
  display: flex;
  align-items: center;
  gap: 2rem;
  margin-bottom: 2rem;
}

.tournament-logo {
  width: 80px;
  height: 80px;
  background: transparent;
  padding: 5px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  /* Glow removed as per request */
}

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

.tournament-title {
  font-size: 2.5rem;
  font-weight: 700;
  letter-spacing: 1px;
  color: #fff;
}

.tournament-info-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 1rem;
}

.info-item {
  display: flex;
  flex-direction: column;
}

.info-label {
  font-size: 0.75rem;
  color: #ffcc00;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.info-value {
  font-size: 1.2rem;
  font-weight: 700;
}

/* Tournament Nav and Tabs */
.tournament-nav {
  display: flex;
  background: rgba(30, 30, 30, 0.8);
  margin-bottom: 2rem;
  border-radius: 4px;
  /* overflow: hidden; Removed to allow dropdown visibility */
  position: relative;
  z-index: 10;
}

.selector-container {
  background: rgba(40, 40, 40, 1);
  padding: 1rem 1.5rem;
  border-right: 1px solid rgba(255, 255, 255, 0.1);
  position: relative;
  z-index: 20;
}

.tournament-selector {
  font-size: 0.8rem;
  font-weight: 700;
  color: #ffcc00;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  cursor: pointer;
  position: relative;
  text-transform: uppercase;
  transition: 0.3s;
}

.tournament-selector:hover {
  color: #fff;
}

.dropdown-menu {
  position: absolute;
  top: 100%;
  left: 0;
  background: #1a1a1a;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  min-width: 160px;
  display: none;
  z-index: 1000;
  margin-top: 5px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.8);
}

.tournament-selector.open .dropdown-menu {
  display: block;
}

.dropdown-item {
  padding: 0.8rem 1.5rem;
  font-size: 0.75rem;
  color: #fff;
  cursor: pointer;
  transition: 0.3s;
}

.dropdown-item:hover {
  background: rgba(255, 204, 0, 0.1);
  color: #ffcc00;
}

.dropdown-item.active {
  color: #ffcc00;
  font-weight: 700;
}

.week-tabs {
  display: flex;
  flex: 1;
}

.week-tab {
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.5);
  padding: 1rem 2rem;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: 0.3s;
  border-bottom: 2px solid transparent;
}

.week-tab.active {
  color: #fff;
  background: rgba(255, 255, 255, 0.05);
  border-bottom: 2px solid #ffcc00;
}

.content-tabs {
  display: flex;
  gap: 4rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  margin-bottom: 2rem;
  justify-content: center;
}

.content-tab {
  background: transparent;
  border: none;
  color: #fff;
  padding: 1rem 0;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  position: relative;
  letter-spacing: 1px;
}

.content-tab.active::after {
  content: "";
  position: absolute;
  bottom: -1px;
  left: 0;
  width: 100%;
  height: 2px;
  background: #ffcc00;
}

/* Leaderboard Section */
.leaderboard-header {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 1rem;
}

.match-toggle {
  display: flex;
  align-items: center;
  gap: 1rem;
  font-size: 0.7rem;
  color: rgba(255, 255, 255, 0.6);
}

.leaderboard-tables {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.leaderboard-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.leaderboard-table th {
  text-align: center;
  /* Center align headers */
  padding: 1rem 0.5rem;
  background: rgba(40, 40, 40, 0.8);
  font-weight: 600;
  color: rgba(255, 255, 255, 0.8);
  text-transform: uppercase;
  white-space: nowrap;
  /* Prevent "TOTAL POINTS" and "PLACE PTS" from wrapping */
}

.leaderboard-table td {
  padding: 1rem 0.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  vertical-align: middle;
  text-align: center;
  /* Center align data */
}

.leaderboard-table tr:nth-child(even) {
  background: rgba(255, 255, 255, 0.02);
}

.rank-cell {
  color: #ffcc00;
  font-weight: 700;
  font-size: 1rem;
}

.team-cell {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  /* Left-align logo and name */
  gap: 0.8rem;
  font-weight: 700;
  white-space: nowrap;
  text-align: left;
}

.team-mini-logo {
  width: 24px;
  height: 24px;
}

.points-cell {
  font-weight: 700;
  font-size: 1rem;
}

.trend {
  font-size: 0.7rem;
  margin-left: 0.5rem;
  padding: 2px 6px;
  border-radius: 4px;
}

.trend.up {
  color: #4caf50;
  background: rgba(76, 175, 80, 0.1);
}

.trend.down {
  color: #f44336;
  background: rgba(244, 67, 54, 0.1);
}

/* Switch UI */
.switch {
  position: relative;
  display: inline-block;
  width: 34px;
  height: 20px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #333;
  transition: .4s;
}

.slider:before {
  position: absolute;
  content: "";
  height: 14px;
  width: 14px;
  left: 3px;
  bottom: 3px;
  background-color: #555;
  transition: .4s;
}

input:checked+.slider {
  background-color: #ffcc00;
}

input:checked+.slider:before {
  transform: translateX(14px);
  background-color: #000;
}

.slider.round {
  border-radius: 34px;
}

.slider.round:before {
  border-radius: 50%;
}

/* Arrow UI */
.arrow-down {
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 5px solid #ffcc00;
}

/* Responsive Styles */
@media (max-width: 1024px) {
  .leaderboard-tables {
    grid-template-columns: 1fr;
  }
}

/* Detailed Table Enhancements */
.detailed-table-container {
  overflow-x: auto;
  background: rgba(20, 20, 20, 0.4);
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.detailed-table {
  width: max-content;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.85rem;
  color: #fff;
  table-layout: auto;
  /* Changed to auto to allow min-width to work */
}

.detailed-table th,
.detailed-table td {
  padding: 10px 12px;
  /* Increased padding */
  text-align: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  white-space: nowrap;
  /* Prevent any wrapping */
}

/* Precise Width Control */
.detailed-table .rank-col {
  min-width: 60px;
}

.detailed-table .team-col {
  min-width: 250px;
  text-align: left;
  padding-left: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-left: none !important;
}

/* TOTAL Section */
.detailed-table .total-k,
.detailed-table .total-p,
.detailed-table td:nth-child(4) {
  /* B/P column */
  min-width: 70px;
}

/* Match Columns (K, PL, PO) */
.detailed-table .sub-headers th:nth-child(n+4),
.detailed-table td:nth-child(n+6) {
  min-width: 55px;
}

/* Match Main Headers */
.detailed-table .main-headers th:nth-child(n+4) {
  min-width: 165px;
  /* 55 * 3 */
}

.detailed-table .main-headers th {
  background: rgba(30, 30, 30, 0.9);
  color: rgba(255, 255, 255, 0.9);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-left: 2px solid rgba(255, 255, 255, 0.1);
}

.detailed-table .sub-headers th {
  background: rgba(0, 0, 0, 0.3);
  color: rgba(255, 255, 255, 0.4);
  font-size: 0.65rem;
  font-weight: 600;
  border-left: 1px solid rgba(255, 255, 255, 0.05);
}

/* Remove left borders for first set of static columns */
.detailed-table .main-headers th:nth-child(1),
.detailed-table .main-headers th:nth-child(2),
.detailed-table .main-headers th:nth-child(3) {
  border-left: none;
}

/* Vertical Dividers for Match Groups */
.detailed-table td:nth-child(3n+6),
.detailed-table th:nth-child(n+4) {
  border-left: 2px solid rgba(255, 255, 255, 0.15);
}

.detailed-table .rank-col {
  color: #ffcc00;
  font-weight: 800;
  border-left: none !important;
}

.detailed-table .team-col {
  text-align: left;
  padding-left: 1rem;
  font-weight: 700;
  text-transform: uppercase;
  border-left: none !important;
}

.detailed-table .total-k {
  color: #ffaa00;
  font-weight: 700;
}

.detailed-table .total-p {
  color: var(--primary-yellow);
  font-weight: 800;
}

.detailed-table .pl-rank {
  font-weight: 700;
}

.detailed-table .highlight-gold {
  color: #ffcc00;
}

.detailed-table .highlight-blue {
  color: #33ccff;
}

.detailed-table .highlight-red {
  color: #ff4d4d;
}

.detailed-table tr:nth-child(even) {
  background: rgba(255, 255, 255, 0.02);
}

.detailed-table tr:hover {
  background: rgba(255, 204, 0, 0.05);
}

.stats-container {
  margin-top: 1.5rem;
  overflow-x: auto;
  position: relative;
}

/* Sticky columns for Team Stats table */
#teamStatsTable th:nth-child(1),
#teamStatsTable td:nth-child(1) {
  position: sticky;
  left: 0;
  z-index: 10;
  background: rgba(40, 40, 40, 0.95);
}

#teamStatsTable th:nth-child(2),
#teamStatsTable td:nth-child(2) {
  position: sticky;
  left: 60px; /* Width of RANK column */
  z-index: 10;
  background: rgba(40, 40, 40, 0.95);
}

/* Add shadow effect to show scrolling */
#teamStatsTable th:nth-child(2)::after,
#teamStatsTable td:nth-child(2)::after {
  content: '';
  position: absolute;
  top: 0;
  right: -10px;
  bottom: 0;
  width: 10px;
  background: linear-gradient(to right, rgba(0, 0, 0, 0.2), transparent);
  pointer-events: none;
}

/* Ensure sticky headers have proper background on hover */
#teamStatsTable tr:hover td:nth-child(1),
#teamStatsTable tr:hover td:nth-child(2) {
  background: rgba(255, 204, 0, 0.08);
}

/* Maintain alternating row colors for sticky columns */
#teamStatsTable tr:nth-child(even) td:nth-child(1),
#teamStatsTable tr:nth-child(even) td:nth-child(2) {
  background: rgba(40, 40, 40, 0.98);
}

#teamStatsTable tr:nth-child(even):hover td:nth-child(1),
#teamStatsTable tr:nth-child(even):hover td:nth-child(2) {
  background: rgba(255, 204, 0, 0.08);
}

.player-cell {
  font-weight: 800;
  color: #ffcc00;
  text-transform: uppercase;
}

.content-section {
  animation: fadeIn 0.3s ease-in-out;
}

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

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Loading States */
.loading-row {
  height: 40px;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.05) 25%, rgba(255, 255, 255, 0.1) 50%, rgba(255, 255, 255, 0.05) 75%);
  background-size: 200% 100%;
  animation: skeleton-loading 1.5s infinite;
  margin: 10px 0;
  border-radius: 4px;
}

/* Map Filter Styles */
.map-select {
  background: rgba(40, 40, 40, 0.8);
  border: 1px solid rgba(255, 204, 0, 0.3);
  color: #fff;
  padding: 5px 15px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  cursor: pointer;
  outline: none;
  transition: 0.3s;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='8' viewBox='0 0 8 8'%3E%3Cpath fill='%23ffcc00' d='M0 2l4 4 4-4z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 30px;
}

.map-select:hover {
  border-color: #ffcc00;
  background-color: rgba(50, 50, 50, 0.9);
}

.sort-header {
  cursor: pointer;
  position: relative;
  padding-right: 25px !important;
  transition: 0.3s;
}

.sort-header:hover {
  background: rgba(255, 204, 0, 0.1) !important;
  color: #ffcc00 !important;
}

.sort-header::after {
  content: '↕';
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.7rem;
  opacity: 0.3;
}

.sort-header.arr-up::after {
  content: '↑';
  opacity: 1;
  color: #ffcc00;
}

.sort-header.arr-down::after {
  content: '↓';
  opacity: 1;
  color: #ffcc00;
}

.table-loading-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(10, 10, 10, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  backdrop-filter: blur(2px);
  border-radius: 12px;
}

@media (max-width: 768px) {
  .table-container {
    overflow-x: auto;
    /* Only allow scroll on mobile */
  }

  .tournament-title {
    font-size: 1.5rem;
  }

  .tournament-info-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .content-tabs {
    gap: 1rem;
    overflow-x: auto;
    justify-content: flex-start;
  }

  .week-tabs {
    overflow-x: auto;
  }

  .header-main {
    flex-direction: column;
    text-align: center;
    gap: 1rem;
  }

  .event-dashboard {
    padding: 1rem;
  }
}

/* Keep current body padding reset or modify it */
@media (min-width: 1025px) {
  body {
    padding: 0;
    /* Remove old padding to allow full width dashboard */
  }
}

/* Footer */
.footer {
  text-align: center;
  padding: 1.5rem 0;
  background: rgba(20, 20, 20, 0.9);
  border-top: 1px solid rgba(255, 215, 0, 0.2);
  margin-top: 4rem;
  width: 100%;
}

.footer p {
  margin: 0.5rem 0;
}

.footer a {
  color: #ffcc00;
  text-decoration: none;
  transition: 0.3s;
}

.footer a:hover {
  text-decoration: underline;
  color: #ffd700;
}