/* ============================================================
   APEX PICKLEBALL — Main Stylesheet
   ============================================================ */

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

:root {
  --pink:        #e367e3;
  --navy:        #180e3c;
  --purple:      #332467;
  --white:       #ffffff;
  --pink-dim:    rgba(227,103,227,0.15);
  --pink-glow:   rgba(227,103,227,0.35);
  --glass:       rgba(255,255,255,0.04);
  --glass-b:     rgba(227,103,227,0.18);
  --text:         #ffffff;
  --text-muted:   rgba(255,255,255,0.45);
  --border:       var(--glass-b);
  --bg:           var(--navy);
  --bg-secondary: rgba(24,14,60,0.5);
  --radius:       10px;
  --radius-lg:    16px;
  --shadow:       0 8px 24px rgba(0,0,0,0.35);
}

/* Light mode variables */
[data-theme="light"] {
  --pink:        #e367e3;
  --navy:        #f0f2f5;
  --purple:      #180e3c;
  --white:       #180e3c;
  --pink-dim:    rgba(227,103,227,0.1);
  --pink-glow:   rgba(227,103,227,0.2);
  --glass:       rgba(255,255,255,0.92);
  --glass-b:     rgba(24,14,60,0.1);
  --text:         #180e3c;
  --text-muted:   rgba(24,14,60,0.5);
  --border:       rgba(24,14,60,0.1);
  --bg:           #f0f2f5;
  --bg-secondary: #ffffff;
  --radius:       10px;
  --radius-lg:    16px;
  --shadow:       0 2px 12px rgba(24,14,60,0.08);
}

@import url('https://fonts.googleapis.com/css2?family=Syne:wght@400;600;700;800&family=DM+Sans:wght@300;400;500&display=swap');

html, body { min-height: 100vh; width: 100%; overflow-x: hidden; }

body {
  font-family: 'DM Sans', sans-serif;
  font-size: 15px;
  line-height: 1.6;
  color: var(--text);
  background: var(--navy);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 70% 55% at 85% 5%,  rgba(227,103,227,0.16) 0%, transparent 60%),
    radial-gradient(ellipse 55% 65% at 5%  90%,  rgba(51,36,103,0.55)   0%, transparent 60%);
  pointer-events: none;
  z-index: 0;
}

[data-theme="light"] body::before {
  background:
    radial-gradient(ellipse 70% 55% at 85% 5%,  rgba(24,14,60,0.04) 0%, transparent 60%),
    radial-gradient(ellipse 55% 65% at 5%  90%,  rgba(227,103,227,0.06)   0%, transparent 60%);
}

a { color: var(--pink); text-decoration: none; }
a:hover { text-decoration: underline; }

/* --- Navbar ----------------------------------------------- */
.navbar {
  background: rgba(24,14,60,0.88);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--glass-b);
  position: sticky;
  top: 0;
  z-index: 100;
  width: 100%;
  padding: 0 32px;
}

[data-theme="light"] .navbar {
  background: rgba(24,14,60,0.95);
}

[data-theme="light"] .nav-links a {
  color: rgba(255,255,255,0.7);
}

[data-theme="light"] .nav-links a:hover {
  color: var(--pink);
  background: rgba(227,103,227,0.15);
}

.nav-inner {
  max-width: 1100px;
  margin: 0 auto;
  height: 62px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.nav-logo {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: 'Syne', sans-serif;
  font-weight: 800;
  font-size: 20px;
  color: var(--white);
  text-decoration: none;
}

.nav-logo .accent { color: var(--pink); }

[data-theme="light"] .nav-logo { color: #ffffff; }

.nav-links {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 4px;
}

.nav-links a {
  padding: 6px 14px;
  border-radius: 20px;
  color: rgba(255,255,255,0.6);
  font-size: 14px;
  transition: all 0.2s;
  text-decoration: none;
}

.nav-links a:hover { color: var(--white); background: var(--glass); }
.nav-links a.active { color: var(--pink); }

/* --- Buttons ---------------------------------------------- */
.btn-primary, .btn-outline, .btn-danger {
  display: inline-block;
  padding: 7px 18px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.2s;
  text-decoration: none;
  font-family: 'DM Sans', sans-serif;
}

.btn-primary  {
  background: linear-gradient(135deg, var(--pink) 0%, #b84eb8 100%);
  color: var(--white);
  border: none;
  box-shadow: 0 4px 18px rgba(227,103,227,0.28);
}
.btn-outline  {
  background: var(--pink-dim);
  color: var(--pink);
  border: 1px solid var(--glass-b);
}
.btn-danger   {
  background: rgba(220,50,50,0.14);
  color: #ff8585;
  border: 1px solid rgba(220,50,50,0.28);
}
.btn-primary:hover { opacity: 0.88; transform: translateY(-1px); text-decoration: none; }
.btn-outline:hover { background: var(--pink); color: var(--white); text-decoration: none; }
.btn-danger:hover { opacity: 0.88; text-decoration: none; }

button.btn-primary, button.btn-outline, button.btn-danger {
  font-family: inherit;
  font-size: 13px;
}

/* --- Theme toggle button ------------------------------------ */
.theme-toggle {
  background: var(--glass);
  border: 1px solid var(--glass-b);
  border-radius: 20px;
  padding: 6px 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text);
  transition: all 0.2s;
}

.theme-toggle:hover {
  background: var(--pink-dim);
  border-color: var(--pink);
}

.theme-toggle svg {
  width: 18px;
  height: 18px;
}

/* --- Flash messages --------------------------------------- */
.flash {
  max-width: 1100px;
  margin: 16px auto 0;
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 500;
  position: relative;
  z-index: 1;
}

.flash-info    { background: rgba(24,95,165,0.14);  border: 1px solid rgba(24,95,165,0.28);  color: #6ba3e8; }
.flash-success { background: var(--pink-dim);        border: 1px solid var(--glass-b);         color: var(--pink); }
.flash-error   { background: rgba(220,50,50,0.14);   border: 1px solid rgba(220,50,50,0.28);   color: #ff8585; }
.flash-warning { background: rgba(186,117,23,0.14);  border: 1px solid rgba(186,117,23,0.28);  color: #e8b86b; }

/* --- Main content ----------------------------------------- */
.main-content {
  flex: 1;
  max-width: 1100px;
  margin: 32px auto;
  padding: 0 32px 60px;
  width: 100%;
  position: relative;
  z-index: 1;
}

/* --- Cards ------------------------------------------------ */
.card {
  background: var(--glass);
  border: 1px solid var(--glass-b);
  border-radius: var(--radius-lg);
  padding: 30px;
  backdrop-filter: blur(10px);
  position: relative;
  z-index: 1;
}

.card-title {
  font-family: 'Syne', sans-serif;
  font-size: 17px;
  font-weight: 700;
  margin-bottom: 22px;
  padding-bottom: 14px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

[data-theme="light"] .card-title {
  border-bottom: 1px solid rgba(24,14,60,0.08);
}

/* --- Page header ------------------------------------------ */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  position: relative;
  z-index: 1;
}

.page-title {
  font-family: 'Syne', sans-serif;
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.4px;
}

/* --- Forms ------------------------------------------------ */
.form-group { margin-bottom: 18px; }

label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: rgba(255,255,255,0.4);
  text-transform: uppercase;
  letter-spacing: 0.7px;
  margin-bottom: 7px;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
select,
textarea {
  width: 100%;
  padding: 11px 15px;
  border: 1px solid var(--glass-b);
  border-radius: 10px;
  font-size: 14px;
  font-family: 'DM Sans', sans-serif;
  background: rgba(24,14,60,0.55);
  color: var(--white);
  transition: border-color 0.2s;
  -webkit-appearance: none;
  appearance: none;
}

[data-theme="light"] input[type="text"],
[data-theme="light"] input[type="email"],
[data-theme="light"] input[type="password"],
[data-theme="light"] input[type="number"],
[data-theme="light"] input[type="date"],
[data-theme="light"] select,
[data-theme="light"] textarea {
  background: rgba(255,255,255,0.9);
  color: var(--text);
  border-color: rgba(24,14,60,0.15);
}

[data-theme="light"] select option {
  background: #ffffff;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--pink);
  box-shadow: 0 0 0 3px rgba(227,103,227,0.12);
}

input:disabled { opacity: 0.35; cursor: not-allowed; }
select option { background: #180e3c; }

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

/* --- Tables ----------------------------------------------- */
.table-wrap { overflow-x: auto; position: relative; z-index: 1; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th {
  text-align: left;
  padding: 9px 13px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: rgba(255,255,255,0.28);
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

[data-theme="light"] th {
  color: rgba(24,14,60,0.5);
  border-bottom: 1px solid rgba(24,14,60,0.1);
}

td {
  padding: 12px 13px;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  color: rgba(255,255,255,0.75);
  vertical-align: middle;
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(227,103,227,0.04); }

[data-theme="light"] td {
  color: rgba(24,14,60,0.75);
  border-bottom: 1px solid rgba(24,14,60,0.06);
}

[data-theme="light"] tr:hover td {
  background: rgba(24,14,60,0.03);
}

/* --- Badges ----------------------------------------------- */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
}

.badge-green  { background: rgba(227,103,227,0.18); color: var(--pink);  border: 1px solid rgba(227,103,227,0.28); }
.badge-amber  { background: rgba(186,117,23,0.14);  color: #e8b86b; border: 1px solid rgba(186,117,23,0.28); }
.badge-red    { background: rgba(220,50,50,0.14);   color: #ff8585; border: 1px solid rgba(220,50,50,0.22); }
.badge-gray   { background: rgba(255,255,255,0.06); color: rgba(255,255,255,0.4); border: 1px solid rgba(255,255,255,0.08); }
.badge-blue   { background: rgba(24,95,165,0.14);  color: #6ba3e8; border: 1px solid rgba(24,95,165,0.28); }

/* --- Match card ------------------------------------------- */
.match-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
  position: relative;
  z-index: 1;
}

.match-card {
  background: var(--glass);
  border: 1px solid var(--glass-b);
  border-radius: var(--radius-lg);
  padding: 18px;
  backdrop-filter: blur(8px);
  transition: border-color 0.2s, transform 0.2s;
}

.match-card:hover { border-color: var(--pink); transform: translateY(-2px); }

.match-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
  font-size: 13px;
  color: rgba(255,255,255,0.45);
}

.match-teams {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.match-team {
  flex: 1;
  font-size: 14px;
  font-weight: 500;
  text-align: center;
  color: var(--white);
}

[data-theme="light"] .match-team {
  color: #180e3c;
}

.match-vs {
  font-size: 12px;
  color: rgba(255,255,255,0.45);
  font-weight: 600;
  padding: 0 8px;
}

[data-theme="light"] .match-vs {
  color: rgba(24,14,60,0.4);
}

.match-score {
  text-align: center;
  margin-top: 12px;
  font-size: 22px;
  font-weight: 800;
  color: var(--pink);
  letter-spacing: 2px;
  font-family: 'Syne', sans-serif;
}

/* --- Leaderboard ------------------------------------------ */
.rank-number {
  font-weight: 700;
  font-size: 16px;
  color: rgba(255,255,255,0.28);
}

.rank-1 .rank-number { color: #FFD700; }
.rank-2 .rank-number { color: #C0C0C0; }
.rank-3 .rank-number { color: #CD7F32; }

/* --- Auth forms ------------------------------------------- */
.auth-wrap {
  max-width: 420px;
  margin: 60px auto;
  position: relative;
  z-index: 1;
}

.auth-logo {
  text-align: center;
  margin-bottom: 28px;
}

.auth-logo img { height: 56px; }
.auth-logo-img { height: 80px; width: auto; }
.auth-logo h1 {
  font-family: 'Syne', sans-serif;
  font-size: 24px;
  font-weight: 800;
  margin-top: 10px;
  color: var(--white);
}

.auth-heading {
  font-family: 'Syne', sans-serif;
  font-size: 22px;
  font-weight: 700;
  text-align: center;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  color: var(--white);
}

[data-theme="light"] .auth-heading {
  color: #180e3c;
  border-bottom-color: rgba(24,14,60,0.08);
}

.auth-footer-text {
  text-align: center;
  color: var(--text-muted);
  margin-top: 20px;
  font-size: 13px;
  padding-top: 16px;
  border-top: 1px solid rgba(255,255,255,0.06);
}

[data-theme="light"] .auth-footer-text {
  border-top-color: rgba(24,14,60,0.08);
}

[data-theme="light"] .auth-logo h1 {
  color: #180e3c;
}

/* --- Footer ----------------------------------------------- */
.footer {
  border-top: 1px solid var(--glass-b);
  background: rgba(24,14,60,0.5);
  margin-top: auto;
  position: relative;
  z-index: 1;
}

.footer-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 16px 32px;
  font-size: 12px;
  color: rgba(255,255,255,0.18);
  text-align: center;
}

[data-theme="light"] .footer {
  background: rgba(255,255,255,0.9);
  border-top: 1px solid rgba(24,14,60,0.08);
}

[data-theme="light"] .footer-inner {
  color: rgba(24,14,60,0.4);
}

/* Light mode overrides for inline styles */
[data-theme="light"] [style*="color:rgba(255,255,255,0.45)"] {
  color: rgba(24,14,60,0.6) !important;
}

[data-theme="light"] [style*="color:rgba(255,255,255,0.75)"] {
  color: rgba(24,14,60,0.8) !important;
}

[data-theme="light"] [style*="color:rgba(255,255,255,0.4)"] {
  color: rgba(24,14,60,0.5) !important;
}

[data-theme="light"] [style*="color:rgba(255,255,255,0.28)"] {
  color: rgba(24,14,60,0.4) !important;
}

[data-theme="light"] [style*="color:rgba(255,255,255,0.18)"] {
  color: rgba(24,14,60,0.4) !important;
}

/* Auth pages specific overrides */
[data-theme="light"] .auth-wrap h1 {
  color: #180e3c !important;
}

[data-theme="light"] .auth-wrap p {
  color: rgba(24,14,60,0.6) !important;
}

[data-theme="light"] .auth-wrap .card {
  background: rgba(255,255,255,0.95) !important;
}

[data-theme="light"] .auth-wrap label {
  color: rgba(24,14,60,0.6) !important;
}

/* --- Utilities -------------------------------------------- */
.text-center { text-align: center; }
.text-muted  { color: var(--text-muted); }
.mt-8  { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-16 { margin-bottom: 16px; }
.gap-8 { gap: 8px; }
.flex  { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }

/* --- Responsive ------------------------------------------- */
@media (max-width: 640px) {
  .form-row { grid-template-columns: 1fr; }
  .nav-links { gap: 2px; }
  .nav-links a { padding: 6px 8px; }
  .match-grid { grid-template-columns: 1fr; }
  .page-header { flex-direction: column; align-items: flex-start; gap: 12px; }
}
