/* ═══════════════════════════════════════════════════════════
   TeamTrack — Global Stylesheet
   Mobile-first, sport-themed, clean & modern
═══════════════════════════════════════════════════════════ */

/* ── CSS Variables / Themes ─────────────────────────────── */
:root {
  --primary: #1a4f8a;
  --primary-dark: #123a6a;
  --primary-light: #2d6cbf;
  --accent: #e8a020;
  --accent-dark: #c87a10;
  --bg: #f0f4f8;
  --surface: #ffffff;
  --surface2: #f8fafc;
  --border: #dde3ea;
  --text: #1a2332;
  --text-muted: #6b7a8d;
  --success: #1a7a1a;
  --success-bg: #eafaea;
  --warning: #b86c00;
  --warning-bg: #fff8e1;
  --danger: #b91c1c;
  --danger-bg: #fef2f2;
  --info: #0369a1;
  --info-bg: #e0f2fe;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow: 0 2px 8px rgba(0,0,0,.09);
  --shadow-lg: 0 4px 20px rgba(0,0,0,.13);
  --sport-icon: '🏆';
  --sport-banner-bg: linear-gradient(135deg, #1a4f8a 0%, #2d6cbf 100%);
  --sport-pattern: none;
  --header-height: 60px;
}

/* Sport Themes */
.theme-softball {
  --primary: #cc3333; --primary-dark: #991111; --primary-light: #e05555;
  --accent: #f5c518; --sport-icon: '🥎';
  --sport-banner-bg: linear-gradient(135deg, #8b1a1a 0%, #cc3333 60%, #e8a020 100%);
}
.theme-baseball {
  --primary: #003087; --primary-dark: #001a5c; --primary-light: #1a4faa;
  --accent: #e63946; --sport-icon: '⚾';
  --sport-banner-bg: linear-gradient(135deg, #001a5c 0%, #003087 60%, #c8102e 100%);
}
.theme-soccer {
  --primary: #1a7a1a; --primary-dark: #0f5a0f; --primary-light: #2ea02e;
  --accent: #f7c948; --sport-icon: '⚽';
  --sport-banner-bg: linear-gradient(135deg, #0a4a0a 0%, #1a7a1a 60%, #2ea02e 100%);
}
.theme-football {
  --primary: #3b4a1e; --primary-dark: #252f12; --primary-light: #5a6e2e;
  --accent: #c87a10; --sport-icon: '🏈';
  --sport-banner-bg: linear-gradient(135deg, #1a2008 0%, #3b4a1e 60%, #c87a10 100%);
}
.theme-flag_football {
  --primary: #7c2d8e; --primary-dark: #561f64; --primary-light: #9b3db0;
  --accent: #f0a500; --sport-icon: '🚩';
  --sport-banner-bg: linear-gradient(135deg, #3d1547 0%, #7c2d8e 60%, #f0a500 100%);
}
.theme-basketball {
  --primary: #c85000; --primary-dark: #8a3500; --primary-light: #e06010;
  --accent: #1a1a1a; --sport-icon: '🏀';
  --sport-banner-bg: linear-gradient(135deg, #5a2000 0%, #c85000 60%, #e06010 100%);
}
.theme-track {
  --primary: #5a189a; --primary-dark: #3c1068; --primary-light: #7b2fbe;
  --accent: #f72585; --sport-icon: '🏃';
  --sport-banner-bg: linear-gradient(135deg, #2d0a4e 0%, #5a189a 60%, #f72585 100%);
}
.theme-ultimate {
  --primary: #0077b6; --primary-dark: #005b8a; --primary-light: #0096d6;
  --accent: #f4d03f; --sport-icon: '🥏';
  --sport-banner-bg: linear-gradient(135deg, #003a5c 0%, #0077b6 60%, #00b4d8 100%);
}
.theme-generic {
  --primary: #1a4f8a; --sport-icon: '🏆';
}

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

html { font-size: 16px; -webkit-text-size-adjust: 100%; }

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

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

img { max-width: 100%; height: auto; }

/* ── Layout ───────────────────────────────────────────────── */
.page-wrapper { min-height: 100vh; display: flex; flex-direction: column; }

.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1rem;
}

.main-content {
  flex: 1;
  padding: 1.5rem 1rem;
}

@media (min-width: 768px) {
  .main-content { padding: 2rem 1.5rem; }
  .container { padding: 0 1.5rem; }
}

/* ── Header / Nav ─────────────────────────────────────────── */
.site-header {
  background: var(--primary);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow);
  height: var(--header-height);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--header-height);
  gap: 1rem;
}

.site-logo {
  font-size: 1.25rem;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: .5rem;
}
.site-logo:hover { text-decoration: none; color: #fff; }
.site-logo .logo-icon { font-size: 1.4rem; }

/* Mobile nav */
.nav-toggle {
  display: flex;
  flex-direction: column;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: .4rem;
}
.nav-toggle span {
  display: block;
  width: 24px;
  height: 2px;
  background: #fff;
  border-radius: 2px;
  transition: .2s;
}

.site-nav {
  display: none;
  position: fixed;
  top: var(--header-height);
  left: 0;
  right: 0;
  background: var(--primary-dark);
  padding: 1rem;
  flex-direction: column;
  gap: .25rem;
  z-index: 99;
  max-height: calc(100vh - var(--header-height));
  overflow-y: auto;
}
.site-nav.open { display: flex; }

.site-nav a, .site-nav button.nav-link {
  display: block;
  color: rgba(255,255,255,.9);
  padding: .6rem .75rem;
  border-radius: var(--radius);
  font-size: .95rem;
  font-weight: 500;
  background: none;
  border: none;
  text-align: left;
  cursor: pointer;
  width: 100%;
}
.site-nav a:hover, .site-nav button.nav-link:hover,
.site-nav a.active, .site-nav button.nav-link.active {
  background: rgba(255,255,255,.15);
  text-decoration: none;
}

.nav-divider {
  height: 1px;
  background: rgba(255,255,255,.2);
  margin: .5rem 0;
}

.nav-section-label {
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: rgba(255,255,255,.5);
  padding: .25rem .75rem;
}

@media (min-width: 900px) {
  .nav-toggle { display: none; }
  .site-nav {
    display: flex !important;
    position: static;
    flex-direction: row;
    background: none;
    padding: 0;
    gap: .15rem;
    max-height: none;
    overflow: visible;
  }
  .site-nav a, .site-nav button.nav-link {
    font-size: .875rem;
    padding: .4rem .65rem;
    white-space: nowrap;
  }
  .nav-divider { width: 1px; height: 24px; margin: auto .25rem; }
  .nav-section-label { display: none; }
}

/* ── Sport Banner ─────────────────────────────────────────── */
.sport-banner {
  background: var(--sport-banner-bg);
  color: #fff;
  padding: 2.5rem 1.5rem;
  text-align: center;
  position: relative;
  overflow: hidden;
}
.sport-banner::before {
  content: var(--sport-icon);
  position: absolute;
  font-size: 12rem;
  opacity: .06;
  right: -2rem;
  top: -2rem;
  line-height: 1;
  pointer-events: none;
}
.sport-banner h1 { font-size: clamp(1.5rem, 4vw, 2.5rem); font-weight: 800; }
.sport-banner p { opacity: .85; margin-top: .5rem; font-size: 1.05rem; }

/* ── Cards ────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.card-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  flex-wrap: wrap;
}
.card-header h2, .card-header h3 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: .4rem;
}
.card-body { padding: 1.25rem; }

/* ── Buttons ──────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .5rem 1rem;
  border-radius: var(--radius);
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: background .15s, transform .1s, box-shadow .15s;
  text-decoration: none;
  line-height: 1.4;
  white-space: nowrap;
}
.btn:hover { text-decoration: none; transform: translateY(-1px); box-shadow: var(--shadow); }
.btn:active { transform: translateY(0); }

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); color: #fff; }
.btn-accent { background: var(--accent); color: #fff; }
.btn-accent:hover { background: var(--accent-dark); color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-outline {
  background: transparent;
  color: var(--primary);
  border: 2px solid var(--primary);
}
.btn-outline:hover { background: var(--primary); color: #fff; }
.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: var(--border); color: var(--text); }
.btn-sm { padding: .3rem .65rem; font-size: .8rem; }
.btn-lg { padding: .75rem 1.5rem; font-size: 1rem; }
.btn-full { width: 100%; justify-content: center; }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }

/* ── Forms ────────────────────────────────────────────────── */
.form-group { margin-bottom: 1.1rem; }
.form-label {
  display: block;
  font-size: .875rem;
  font-weight: 600;
  margin-bottom: .35rem;
  color: var(--text);
}
.form-label .required { color: var(--danger); margin-left: .2rem; }

.form-control {
  display: block;
  width: 100%;
  padding: .55rem .85rem;
  font-size: .95rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  transition: border-color .15s, box-shadow .15s;
  font-family: inherit;
}
.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(26,79,138,.12);
}
.form-control::placeholder { color: var(--text-muted); }

textarea.form-control { resize: vertical; min-height: 90px; }
select.form-control { cursor: pointer; }

.form-hint { font-size: .78rem; color: var(--text-muted); margin-top: .3rem; }
.form-error { font-size: .78rem; color: var(--danger); margin-top: .3rem; }

.form-check {
  display: flex;
  align-items: center;
  gap: .5rem;
  cursor: pointer;
  font-size: .9rem;
}
.form-check input[type=checkbox],
.form-check input[type=radio] { width: 16px; height: 16px; cursor: pointer; accent-color: var(--primary); }

.form-row {
  display: grid;
  gap: 1rem;
}
@media (min-width: 600px) { .form-row.cols-2 { grid-template-columns: 1fr 1fr; } }
@media (min-width: 768px) { .form-row.cols-3 { grid-template-columns: 1fr 1fr 1fr; } }

/* ── Alerts / Flash ───────────────────────────────────────── */
.alert {
  padding: .8rem 1rem;
  border-radius: var(--radius);
  font-size: .9rem;
  display: flex;
  align-items: flex-start;
  gap: .6rem;
  margin-bottom: 1rem;
}
.alert-success { background: var(--success-bg); color: #145214; border-left: 4px solid var(--success); }
.alert-warning { background: var(--warning-bg); color: #7a4700; border-left: 4px solid var(--warning); }
.alert-danger  { background: var(--danger-bg);  color: #8b0000; border-left: 4px solid var(--danger); }
.alert-info    { background: var(--info-bg);    color: #014669; border-left: 4px solid var(--info); }

/* ── Tables ───────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th {
  background: var(--surface2);
  padding: .65rem .85rem;
  text-align: left;
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-muted);
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}
td {
  padding: .7rem .85rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--surface2); }
.table-actions { display: flex; gap: .35rem; flex-wrap: wrap; }

/* ── Badges ───────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: .2rem .55rem;
  border-radius: 20px;
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  white-space: nowrap;
}
.badge-primary { background: var(--primary); color: #fff; }
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-danger  { background: var(--danger-bg);  color: var(--danger); }
.badge-info    { background: var(--info-bg);    color: var(--info); }
.badge-muted   { background: var(--border);     color: var(--text-muted); }

/* ── Pagination ───────────────────────────────────────────── */
.pagination { display: flex; gap: .3rem; flex-wrap: wrap; margin-top: 1rem; }
.page-link {
  padding: .4rem .75rem;
  border-radius: var(--radius);
  border: 1.5px solid var(--border);
  color: var(--primary);
  font-size: .875rem;
  font-weight: 500;
  background: var(--surface);
}
.page-link:hover { background: var(--primary); color: #fff; text-decoration: none; border-color: var(--primary); }
.page-link.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ── Modal ────────────────────────────────────────────────── */
.modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.modal-backdrop.open { display: flex; }
.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 540px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: slideUp .2s ease;
}
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.modal-header {
  padding: 1.1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-header h3 { font-size: 1.05rem; font-weight: 700; }
.modal-close {
  background: none; border: none; cursor: pointer;
  font-size: 1.4rem; color: var(--text-muted); line-height: 1; padding: .2rem;
}
.modal-close:hover { color: var(--text); }
.modal-body { padding: 1.25rem; }
.modal-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border);
  display: flex;
  gap: .5rem;
  justify-content: flex-end;
  flex-wrap: wrap;
}

/* ── Dashboard Grid ───────────────────────────────────────── */
.dash-grid {
  display: grid;
  gap: 1.25rem;
  grid-template-columns: 1fr;
}
@media (min-width: 600px) { .dash-grid.cols-2 { grid-template-columns: 1fr 1fr; } }
@media (min-width: 900px) {
  .dash-grid.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
  .dash-grid.cols-4 { grid-template-columns: 1fr 1fr 1fr 1fr; }
}

/* ── Stat Cards ───────────────────────────────────────────── */
.stat-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 1rem;
}
.stat-icon {
  font-size: 2rem;
  width: 52px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  border-radius: var(--radius);
  flex-shrink: 0;
}
.stat-info { flex: 1; min-width: 0; }
.stat-value { font-size: 1.6rem; font-weight: 800; color: var(--primary); line-height: 1; }
.stat-label { font-size: .8rem; color: var(--text-muted); margin-top: .25rem; }

/* ── Schedule ─────────────────────────────────────────────── */
.schedule-date-group { margin-bottom: 1.5rem; }
.schedule-date-header {
  background: var(--primary);
  color: #fff;
  padding: .5rem 1rem;
  border-radius: var(--radius) var(--radius) 0 0;
  font-weight: 700;
  font-size: .9rem;
}
.game-row {
  display: flex;
  align-items: center;
  padding: .75rem 1rem;
  border: 1px solid var(--border);
  border-top: none;
  background: var(--surface);
  gap: .75rem;
  flex-wrap: wrap;
}
.game-row:last-child { border-radius: 0 0 var(--radius) var(--radius); }
.game-time { font-weight: 700; color: var(--primary); min-width: 70px; font-size: .9rem; }
.game-teams { flex: 1; font-weight: 600; }
.game-vs { color: var(--text-muted); font-size: .8rem; margin: 0 .35rem; }
.game-score { font-weight: 700; color: var(--success); font-size: .9rem; }
.game-field { font-size: .8rem; color: var(--text-muted); }
.game-conflict { background: var(--danger-bg) !important; border-color: var(--danger) !important; }

/* ── Roster ───────────────────────────────────────────────── */
.player-card {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .7rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  margin-bottom: .5rem;
}
.jersey-num {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--primary);
  color: #fff;
  font-weight: 800;
  font-size: 1rem;
  border-radius: 50%;
  flex-shrink: 0;
}
/* Gender-colored avatars — applied via inline style from gender_color() */
.avatar-male   { background: #1a4f8a !important; }
.avatar-female { background: #d63384 !important; }
.avatar-unset  { background: #6b7a8d !important; }
.player-info { flex: 1; min-width: 0; }
.player-name { font-weight: 600; }
.player-meta { font-size: .8rem; color: var(--text-muted); }

/* ── Team Badge ───────────────────────────────────────────── */
.team-badge {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .25rem .65rem;
  border-radius: 20px;
  font-weight: 700;
  font-size: .85rem;
}
.team-color-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ── Admin Sidebar Layout ─────────────────────────────────── */
@media (min-width: 1024px) {
  .admin-layout {
    display: grid;
    grid-template-columns: 240px 1fr;
    gap: 1.5rem;
    align-items: start;
  }
  .admin-sidebar {
    position: sticky;
    top: calc(var(--header-height) + 1rem);
  }
}

.sidebar-nav { list-style: none; }
.sidebar-nav li a {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .55rem .85rem;
  border-radius: var(--radius);
  color: var(--text);
  font-size: .9rem;
  font-weight: 500;
  transition: background .12s;
}
.sidebar-nav li a:hover { background: var(--bg); text-decoration: none; }
.sidebar-nav li a.active { background: var(--primary); color: #fff; }
.sidebar-nav .nav-group-label {
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--text-muted);
  padding: .75rem .85rem .25rem;
  font-weight: 600;
}

/* ── Footer ───────────────────────────────────────────────── */
.site-footer {
  background: var(--primary-dark);
  color: rgba(255,255,255,.7);
  text-align: center;
  padding: 1.25rem;
  font-size: .8rem;
  margin-top: auto;
}
.site-footer a { color: rgba(255,255,255,.85); }

/* ── Misc Utilities ───────────────────────────────────────── */
.text-center { text-align: center; }
.text-right  { text-align: right; }
.text-muted  { color: var(--text-muted); }
.text-danger { color: var(--danger); }
.text-success{ color: var(--success); }
.fw-bold { font-weight: 700; }
.mt-1 { margin-top: .5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: .5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.gap-1 { gap: .5rem; }
.gap-2 { gap: 1rem; }
.d-flex { display: flex; }
.align-center { align-items: center; }
.flex-wrap { flex-wrap: wrap; }
.justify-between { justify-content: space-between; }
.justify-end { justify-content: flex-end; }
.w-100 { width: 100%; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; }

/* ── Conflict Warning Banner ──────────────────────────────── */
.conflict-banner {
  background: var(--danger-bg);
  border: 2px solid var(--danger);
  border-radius: var(--radius);
  padding: .85rem 1rem;
  margin-bottom: 1rem;
  display: flex;
  align-items: flex-start;
  gap: .75rem;
}
.conflict-banner .conflict-icon { font-size: 1.4rem; flex-shrink: 0; }
.conflict-banner ul { margin: .35rem 0 0 1.2rem; font-size: .88rem; }
.conflict-banner li { margin-bottom: .2rem; }

/* ── Loading Spinner ──────────────────────────────────────── */
.spinner {
  display: inline-block;
  width: 20px; height: 20px;
  border: 3px solid rgba(255,255,255,.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Empty State ──────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 3rem 1.5rem;
  color: var(--text-muted);
}
.empty-state .empty-icon { font-size: 3rem; display: block; margin-bottom: 1rem; }
.empty-state h3 { font-size: 1.1rem; margin-bottom: .5rem; color: var(--text); }

/* ── Print ────────────────────────────────────────────────── */
@media print {
  .site-header, .site-nav, .nav-toggle, .btn:not(.btn-print-show), .no-print { display: none !important; }
  body { background: #fff; }
  .card { box-shadow: none; border: 1px solid #ddd; }
  table { font-size: .8rem; }
  th, td { padding: .4rem .6rem; }
}
