/* ── Variables ──────────────────────────────────────────────────────────── */
:root {
  --red:     #E81828;
  --navy:    #002D72;
  --white:   #FFFFFF;
  --red-dk:  #b5121e;
  --navy-lt: #1a4a9e;
  --bg:      #f4f5f7;
  --surface: #ffffff;
  --border:  #dde1e7;
  --text:    #1a1a2e;
  --muted:   #6b7280;
  --radius:  8px;
  --shadow:  0 2px 8px rgba(0,0,0,.10);
  --have:    #166534;
  --have-bg: #dcfce7;
  --signed:  #854d0e;
  --signed-bg: #fef9c3;
  --dont:    #9ca3af;
  --dont-bg: #f3f4f6;
  --no-auto:    #7c3aed;
  --no-auto-bg: #ede9fe;
  --in-person:    #1d4ed8;
  --in-person-bg: #dbeafe;
}

/* ── Reset ──────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-tap-highlight-color: transparent; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
}
img { display: block; }
button, select, input { font: inherit; }

/* ── Login page ─────────────────────────────────────────────────────────── */
.login-page {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(145deg, var(--navy) 0%, #001a4d 100%);
  padding: 1.5rem;
}
.login-card {
  background: var(--surface);
  border-radius: 16px;
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 20px 60px rgba(0,0,0,.4);
  text-align: center;
}
.login-icon {
  font-size: 3.5rem;
  line-height: 1;
  margin-bottom: .5rem;
}
.login-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--navy);
  margin-bottom: .25rem;
}
.login-sub {
  font-size: .9rem;
  color: var(--muted);
  margin-bottom: 2rem;
}
.login-form label {
  display: block;
  text-align: left;
  font-size: .85rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: .4rem;
  letter-spacing: .05em;
  text-transform: uppercase;
}
.login-form input[type="password"] {
  width: 100%;
  padding: .75rem 1rem;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  font-size: 1rem;
  outline: none;
  transition: border-color .2s;
  margin-bottom: 1.25rem;
}
.login-form input[type="password"]:focus {
  border-color: var(--red);
}
.btn-login {
  width: 100%;
  padding: .85rem;
  background: var(--red);
  color: var(--white);
  border: none;
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  letter-spacing: .03em;
  transition: background .2s, transform .1s;
}
.btn-login:hover  { background: var(--red-dk); }
.btn-login:active { transform: scale(.98); }
.login-error {
  margin-top: 1rem;
  padding: .65rem 1rem;
  background: #fee2e2;
  color: #991b1b;
  border-radius: var(--radius);
  font-size: .9rem;
}

/* ── App layout ─────────────────────────────────────────────────────────── */
.app-header {
  background: linear-gradient(135deg, var(--red) 0%, var(--red-dk) 100%);
  color: var(--white);
  padding: calc(1rem + env(safe-area-inset-top)) 1.25rem 1rem;
  display: flex;
  align-items: center;
  gap: .75rem;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 10px rgba(0,0,0,.25);
}
.header-logo { font-size: 1.8rem; line-height: 1; flex-shrink: 0; }
.header-text { flex: 1; min-width: 0; }
.header-text h1 { font-size: 1.1rem; font-weight: 800; line-height: 1.2; }
.header-text p  { font-size: .78rem; opacity: .85; }
.btn-logout {
  background: rgba(255,255,255,.15);
  border: 1px solid rgba(255,255,255,.3);
  color: var(--white);
  padding: .45rem .9rem;
  border-radius: 20px;
  font-size: .8rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background .2s;
  flex-shrink: 0;
}
.btn-logout:hover { background: rgba(255,255,255,.25); }

/* ── Stats bar ───────────────────────────────────────────────────────────── */
.stats-bar {
  background: var(--navy);
  color: var(--white);
  padding: .5rem 1.25rem;
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
  font-size: .82rem;
}
.stats-bar span { opacity: .8; cursor: pointer; border-radius: 4px; padding: .15rem .35rem; transition: opacity .15s, background .15s; }
.stats-bar span:hover { opacity: 1; background: rgba(255,255,255,.15); }
.stats-bar span.stat-active { opacity: 1; background: rgba(255,255,255,.22); outline: 1.5px solid rgba(255,255,255,.5); }
.stats-bar strong { opacity: 1; font-weight: 700; }
.stat-have      { color: #86efac; }
.stat-signed    { color: #fde68a; }
.stat-no-auto   { color: #c4b5fd; }
.stat-in-person { color: #93c5fd; }

/* ── Filter bar ─────────────────────────────────────────────────────────── */
.filter-bar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: .75rem 1.25rem;
  display: flex;
  gap: .6rem;
  flex-wrap: wrap;
  align-items: center;
}
.filter-bar input,
.filter-bar select {
  padding: .5rem .75rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: .88rem;
  outline: none;
  background: var(--bg);
  transition: border-color .2s;
}
.filter-bar input:focus,
.filter-bar select:focus { border-color: var(--red); }
#searchInput  { flex: 1 1 160px; min-width: 140px; }
#posFilter    { flex: 0 1 110px; }
#yearInput    { flex: 0 1 90px; }
/* ── Status multi-select dropdown ──────────────────────────────────────────── */
.status-dropdown { position: relative; flex: 0 1 150px; }
.status-dropdown-btn {
  width: 100%;
  padding: .5rem .75rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: .88rem;
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
  text-align: left;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: .25rem;
  white-space: nowrap;
  overflow: hidden;
}
.status-dropdown-btn.active { border-color: var(--red); color: #000; }
.dd-arrow { font-size: .7rem; flex-shrink: 0; }
.status-dropdown-menu {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  min-width: 185px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  z-index: 200;
  padding: .3rem 0;
}
.status-dropdown-menu.open { display: block; }
.status-dropdown-menu label {
  display: flex;
  align-items: center;
  gap: .55rem;
  padding: .48rem .85rem;
  font-size: .85rem;
  cursor: pointer;
  user-select: none;
}
.status-dropdown-menu label:hover { background: var(--bg); }
.status-dropdown-menu input[type="checkbox"] { accent-color: var(--red); width: 15px; height: 15px; cursor: pointer; }
.btn-clear {
  padding: .5rem .9rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  font-size: .82rem;
  cursor: pointer;
  color: var(--muted);
  white-space: nowrap;
  transition: all .2s;
}
.btn-clear:hover { border-color: var(--red); color: var(--red); }

/* ── Roster count ─────────────────────────────────────────────────────────── */
.roster-count {
  padding: .5rem 1.25rem;
  font-size: .82rem;
  color: var(--muted);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.roster-count strong { color: var(--text); }

/* ── Table ──────────────────────────────────────────────────────────────── */
.table-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.roster-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .9rem;
  min-width: 520px;
}
.roster-table thead {
  background: var(--navy);
  color: var(--white);
  position: sticky;
  top: 0;
}
.roster-table th {
  padding: .7rem 1rem;
  text-align: left;
  font-weight: 600;
  font-size: .82rem;
  letter-spacing: .04em;
  text-transform: uppercase;
  white-space: nowrap;
  user-select: none;
}
.roster-table th.sortable { cursor: pointer; }
.roster-table th.sortable:hover { background: var(--navy-lt); }
.sort-icon { opacity: .5; margin-left: .3rem; font-size: .75rem; }
.sort-icon.asc::after  { content: '▲'; opacity: 1; }
.sort-icon.desc::after { content: '▼'; opacity: 1; }
th.sort-active .sort-icon { opacity: 1; }

.roster-table tbody tr { border-bottom: 1px solid var(--border); }
.roster-table tbody tr:nth-child(even) { background: #fafbff; }
.roster-table tbody tr:hover { background: #eef2ff; }

.roster-table td { padding: .6rem 1rem; vertical-align: middle; }
.col-photo { width: 52px; padding-right: 0 !important; }

/* ── Avatar ─────────────────────────────────────────────────────────────── */
.avatar-wrap {
  width: 38px; height: 38px;
  border-radius: 50%;
  overflow: hidden;
  background: var(--red);
  position: relative;
  flex-shrink: 0;
}
/* Image absolutely fills the circle, covering initials beneath */
.avatar-img {
  position: absolute;
  inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  object-position: top center;
  z-index: 1;
}
/* Initials sit beneath as fallback — visible only when image hides itself */
.avatar-initials {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--white);
  font-size: .72rem;
  font-weight: 700;
  line-height: 1;
}

/* ── Player name ─────────────────────────────────────────────────────────── */
.player-name { font-weight: 600; }

/* ── Position badge ──────────────────────────────────────────────────────── */
.pos-badge {
  display: inline-block;
  background: #e8eaf6;
  color: var(--navy);
  padding: .2rem .55rem;
  border-radius: 4px;
  font-size: .8rem;
  font-weight: 700;
  min-width: 32px;
  text-align: center;
}

/* ── Status select ───────────────────────────────────────────────────────── */
.status-select {
  padding: .3rem .6rem;
  border-radius: 6px;
  border: 1.5px solid transparent;
  font-size: .82rem;
  font-weight: 600;
  cursor: pointer;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23666'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right .5rem center;
  padding-right: 1.6rem;
  transition: box-shadow .15s;
}
.status-select:focus { box-shadow: 0 0 0 3px rgba(232,24,40,.25); }

.status-have      { background-color: var(--have-bg);      color: #000; border-color: #86efac; }
.status-signed    { background-color: var(--signed-bg);    color: #000; border-color: #fde68a; }
.status-dont      { background-color: var(--dont-bg);      color: #000; border-color: #d1d5db; }
.status-no-auto   { background-color: var(--no-auto-bg);   color: #000; border-color: #c4b5fd; }
.status-in-person { background-color: var(--in-person-bg); color: #000; border-color: #93c5fd; }

/* ── Loading / empty ─────────────────────────────────────────────────────── */
.loading-row td, .empty-row td {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--muted);
  font-size: .95rem;
}
.spinner {
  display: inline-block;
  width: 22px; height: 22px;
  border: 3px solid var(--border);
  border-top-color: var(--red);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  vertical-align: middle;
  margin-right: .5rem;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Toast ───────────────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--navy);
  color: var(--white);
  padding: .65rem 1.25rem;
  border-radius: 24px;
  font-size: .88rem;
  font-weight: 600;
  box-shadow: var(--shadow);
  opacity: 0;
  transition: opacity .25s, transform .3s;
  pointer-events: none;
  z-index: 999;
  white-space: nowrap;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ── Mobile responsive ───────────────────────────────────────────────────── */
@media (max-width: 600px) {
  .header-text h1 { font-size: 1rem; }
  .filter-bar { padding: .6rem .75rem; gap: .5rem; }
  #searchInput { flex: 1 1 100%; }
  .stats-bar { gap: 1rem; font-size: .78rem; }

  /* Hide photo column — saves ~50px, lets table fit 375px screens */
  .col-photo { display: none; }

  /* Table fits iPhone without horizontal scroll */
  .roster-table { min-width: 0; width: 100%; font-size: .8rem; }
  .roster-table th { padding: .5rem .5rem; font-size: .72rem; }
  .roster-table td { padding: .5rem .5rem; }

  /* Compact status dropdown on mobile */
  .status-select { font-size: .75rem; padding: .25rem .35rem; padding-right: 1.3rem; }
}
