/* Shared styles for the RIPUL spirit site.
   Extracted from the original 2024/2025 static pages and extended
   for captain/admin dashboards. */

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  margin: 0;
  padding: 20px;
  background-color: #f4f4f8;
  color: #333;
  line-height: 1.6;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 15px;
}

header {
  background-color: #fff;
  padding: 20px;
  border-radius: 8px;
  margin-bottom: 20px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  text-align: center;
  position: relative;
}

.season-nav {
  margin-bottom: 20px;
  padding: 10px;
  background-color: #f8f8f8;
  border-radius: 4px;
}

.season-nav a {
  display: inline-block;
  padding: 8px 16px;
  margin: 0 5px;
  text-decoration: none;
  color: #333;
  border-radius: 4px;
  transition: all 0.2s;
  font-size: 1.1em;
}

.season-nav a:hover { background-color: #e0e0e0; }

.season-nav a.active {
  background-color: #333;
  color: white;
  font-size: 1.4em;
  font-weight: bold;
  padding: 12px 24px;
}

header img.logo {
  max-width: 350px;
  margin-bottom: 10px;
}

header h1 {
  margin: 0 0 15px 0;
  text-align: center;
  color: #333;
  font-size: 2.5em;
}

header .description-text {
  font-size: 0.9em;
  color: #555;
  margin-bottom: 20px;
  max-width: 800px;
  margin-left: auto;
  margin-right: auto;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 15px;
  margin-bottom: 20px;
  align-items: center;
}

.controls label { font-weight: bold; margin-right: 5px; }

.controls input[type="text"],
.controls select {
  padding: 10px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 1em;
  flex-grow: 1;
  min-width: 150px;
}
.controls input[type="text"] { max-width: 300px; }

#errorMessage {
  color: #b00020;
  background-color: #ffebee;
  border: 1px solid #ef9a9a;
  padding: 10px;
  border-radius: 4px;
  margin-bottom: 20px;
  text-align: center;
}

.date-group { margin-bottom: 30px; }

.date-header {
  font-size: 1.5em;
  font-weight: bold;
  margin: 20px 0;
  padding: 10px;
  background: white;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.05);
  text-align: center;
}

.games-grid { display: grid; gap: 15px; }

.game-pairing {
  background-color: #fff;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.05);
  padding: 15px;
}
.game-pairing.test-game {
  background-color: #fffaf0;
  border: 2px dashed #ff9800;
}

.team-entry {
  padding: 8px 0;
  border-bottom: 1px solid #eee;
}
.team-entry:last-child { border-bottom: none; }

.team-name {
  display: flex;
  align-items: center;
  font-weight: bold;
  margin-bottom: 4px;
}
.team-name .name-text { font-size: 1.2em; }
.team-name .name-text a { color: inherit; text-decoration: none; }
.team-name .name-text a:hover { text-decoration: underline; }

.team-color {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  margin-right: 8px;
  display: inline-block;
}

.team-shoutout { margin-left: 20px; color: #555; }

.loading-message {
  text-align: center;
  padding: 20px;
  font-size: 1.2em;
  color: #777;
}

.highlight {
  background-color: yellow;
  font-weight: bold;
}

/* Team colors */
.team-lime { background-color: #c2e51c; }
.team-navy { background-color: #001f3f; }
.team-forest { background-color: #228B22; }
.team-silver { background-color: #C0C0C0; }
.team-gold { background-color: #FFD700; }
.team-pink { background-color: #FFC0CB; }
.team-kelly { background-color: #4CBB17; }
.team-orange { background-color: #FFA500; }
.team-purple { background-color: #800080; }
.team-red { background-color: #FF0000; }
.team-atomic { background-color: #008080; }
.team-black { background-color: #000000; }
.team-carolina { background-color: #7BAFD4; }
.team-maroon { background-color: #800000; }
.team-white { background-color: #FFFFFF; border: 1px solid #ccc; }
.team-yellow { background-color: #FFFF00; }

.team-filter-buttons button {
  padding: 8px 12px;
  margin: 5px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.9em;
  color: white;
  min-width: 80px;
}
.team-filter-buttons button.active-filter {
  box-shadow: 0 0 0 2px black, 0 0 0 4px white;
  font-weight: bold;
}
.team-filter-buttons button.team-white,
.team-filter-buttons button.team-yellow,
.team-filter-buttons button.team-lime,
.team-filter-buttons button.team-pink,
.team-filter-buttons button.team-silver { color: #333; }

.team-filter-buttons button.all-teams-btn {
  background-color: #f0f0f0;
  color: #333;
}

/* Admin impersonation banner */
.impersonation-banner {
  background: #fff3cd;
  border: 2px solid #f0ad4e;
  color: #8a6d3b;
  padding: 12px 18px;
  border-radius: 6px;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.impersonation-banner strong { color: #6b4a1a; }

/* Auth bar in upper right of header */
.auth-bar {
  position: absolute;
  top: 20px;
  right: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.9em;
  flex-wrap: wrap;
  justify-content: flex-end;
  max-width: calc(100% - 40px);
}
.auth-bar button {
  padding: 8px 14px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.95em;
  background-color: #4285F4;
  color: white;
  font-weight: 500;
}
.auth-bar button.secondary {
  background-color: #eee;
  color: #333;
}
.auth-bar button:hover { opacity: 0.9; }
.auth-bar .user-email { color: #555; }

/* Spirit prize winners line on public site */
.team-shoutout .prize-winners {
  margin-top: 8px;
  color: #6a1b9a;
}

/* ---------- Captain dashboard ---------- */

.dash-game-card {
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.06);
  padding: 16px;
  margin-bottom: 14px;
  border-left: 6px solid #ddd;
}
.dash-game-card.action-required { border-left-color: #d32f2f; background: #fff8f8; }
.dash-game-card.completed { border-left-color: #2e7d32; }
.dash-game-card.upcoming { border-left-color: #1976d2; }
.dash-game-card.test-game { border-left-color: #ff9800; background: #fffaf0; }

/* Compact upcoming-game card: just the header row, no submission sections. */
.dash-game-card.compact {
  padding: 10px 14px;
  margin-bottom: 6px;
}
.dash-game-card.compact .dash-game-header { margin-bottom: 0; }
.dash-game-card.compact .dash-game-title { font-size: 1em; font-weight: 600; }

.test-game-banner {
  background: #fff3cd;
  border: 1px dashed #ff9800;
  color: #8a4a00;
  padding: 8px 12px;
  border-radius: 4px;
  margin-bottom: 10px;
  font-size: 0.9em;
}

.dash-game-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  flex-wrap: wrap;
  gap: 10px;
}
.dash-game-title { font-size: 1.2em; font-weight: bold; }
.dash-game-date { color: #666; font-size: 0.95em; }

.status-pill {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.85em;
  font-weight: 600;
}
.status-pill.todo { background: #ffcdd2; color: #b71c1c; }
.status-pill.done { background: #c8e6c9; color: #1b5e20; }
.status-pill.upcoming { background: #bbdefb; color: #0d47a1; }
.status-pill.test { background: #ffe0b2; color: #8a4a00; }

.dash-section {
  margin-top: 10px;
  padding: 10px 12px;
  background: #fafafa;
  border-radius: 6px;
}
.dash-section h4 {
  margin: 0 0 6px 0;
  font-size: 0.95em;
  color: #444;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.dash-section .empty { color: #999; font-style: italic; }

.btn {
  padding: 9px 16px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.95em;
  background-color: #1976d2;
  color: white;
  font-weight: 500;
}
.btn.secondary { background: #eee; color: #333; }
.btn.danger { background: #d32f2f; }
.btn:hover { opacity: 0.92; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---------- Submission form ---------- */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
  padding: 20px;
}
.modal {
  background: white;
  border-radius: 10px;
  max-width: 700px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  padding: 28px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.3);
}
.modal h2 { margin-top: 0; }

.form-field { margin-bottom: 20px; }
.form-field label.field-label {
  display: block;
  font-weight: bold;
  color: #1976d2;
  font-size: 1.05em;
  margin-bottom: 4px;
}
.form-field .field-help {
  color: #555;
  font-size: 0.9em;
  margin-bottom: 8px;
  white-space: pre-line;
}
.form-field input[type="text"],
.form-field textarea {
  width: 100%;
  padding: 10px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 1em;
  box-sizing: border-box;
  font-family: inherit;
}
.form-field textarea { min-height: 80px; resize: vertical; }
.form-field .radio-row { display: flex; align-items: flex-start; gap: 8px; margin: 4px 0; }
.form-field .radio-row input[type="radio"] { flex-shrink: 0; margin-top: 3px; }
.form-field .radio-row label { line-height: 1.35; }

.chip-picker {
  border: 1px solid #ddd;
  border-radius: 4px;
  padding: 8px;
  background: #fafafa;
  max-height: 220px;
  overflow-y: auto;
}
.chip {
  display: inline-block;
  padding: 5px 12px;
  margin: 4px;
  background: #eee;
  border-radius: 999px;
  cursor: pointer;
  font-size: 0.9em;
  user-select: none;
  transition: all 0.15s;
}
.chip.selected {
  background: #1976d2;
  color: white;
  font-weight: 500;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid #eee;
}

/* Public vs private grouping inside the submission form */
.form-section {
  border: 1px solid #e3e3e3;
  border-radius: 8px;
  padding: 14px 16px;
  margin: 18px 0;
  background: #fff;
}
.form-section.public { background: #f0f7ff; border-color: #b3d4fc; }
.form-section.captains { background: #fff5e6; border-color: #ffd6a1; }
.form-section.admins { background: #f4f1fa; border-color: #d6c8ec; }

.form-section-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.form-section-badge {
  font-size: 0.75em;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 3px 8px;
  border-radius: 999px;
  color: white;
}
.form-section-badge.public { background: #1976d2; }
.form-section-badge.captains { background: #ef6c00; }
.form-section-badge.admins { background: #6a1b9a; }
.form-section-note {
  font-size: 0.85em;
  color: #555;
}
.form-section .form-field:last-child { margin-bottom: 0; }

/* ---------- Admin panel ---------- */
.admin-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 20px;
  border-bottom: 2px solid #ddd;
}
.admin-tabs button {
  padding: 10px 18px;
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 1em;
  color: #555;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
}
.admin-tabs button.active {
  color: #1976d2;
  border-bottom-color: #1976d2;
  font-weight: 600;
}

table.data {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}
table.data th, table.data td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid #eee;
}
table.data th {
  background: #f5f5f5;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
}
table.data tr:hover { background: #fafafa; }

.diff-line { padding: 2px 8px; font-family: ui-monospace, monospace; font-size: 0.9em; }
.diff-line.added { background: #e8f5e9; }
.diff-line.removed { background: #ffebee; }

@media (min-width: 768px) {
  .games-grid {
    grid-template-columns: repeat(auto-fill, minmax(400px, 1fr));
  }
}

/* ---------- Mobile (<= 640px) ---------- */
@media (max-width: 640px) {
  body { padding: 8px; font-size: 16px; }
  .container { padding: 0; }

  /* Header collapses: auth bar moves out of absolute positioning so it
     never overlaps the logo or title */
  header { padding: 14px 12px; }
  .auth-bar {
    position: static;
    justify-content: center;
    margin-bottom: 12px;
    font-size: 0.95em;
  }
  header img.logo { max-width: 220px; }
  header h1 { font-size: 1.6em; margin: 0 0 10px 0; }
  header .description-text { font-size: 0.9em; margin-bottom: 14px; }

  /* Season nav — keep active link from ballooning */
  .season-nav { padding: 6px; margin-bottom: 14px; }
  .season-nav a {
    padding: 8px 12px;
    margin: 2px;
    font-size: 1em;
  }
  .season-nav a.active {
    font-size: 1.1em;
    padding: 10px 16px;
  }

  /* Controls stack full width */
  .controls { flex-direction: column; align-items: stretch; gap: 10px; }
  .controls > div { width: 100%; }
  .controls input[type="text"],
  .controls select {
    width: 100%;
    max-width: none;
    min-width: 0;
    font-size: 16px; /* prevents iOS auto-zoom on focus */
  }

  /* Team filter buttons: tighter, scrollable row */
  .team-filter-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin: 0;
  }
  .team-filter-buttons button {
    padding: 8px 10px;
    margin: 0;
    font-size: 0.85em;
    min-width: 0;
    flex: 0 0 auto;
  }

  /* Date headers a bit smaller */
  .date-header { font-size: 1.2em; padding: 8px; }

  /* Game cards: keep readable */
  .game-pairing { padding: 12px; }
  .team-name .name-text { font-size: 1.1em; }
  .team-shoutout { margin-left: 16px; }

  /* Buttons: ensure 44px touch target */
  .btn,
  .auth-bar button,
  .controls select {
    min-height: 44px;
  }

  /* Captain header buttons: stack with spacing */
  header .btn { display: inline-block; margin: 4px 2px; }

  /* Impersonation banner stacks */
  .impersonation-banner {
    flex-direction: column;
    align-items: stretch;
    text-align: center;
  }

  /* Captain dashboard cards */
  .dash-game-card { padding: 12px; }
  .dash-game-header { gap: 6px; }
  .dash-game-title { font-size: 1.05em; }

  /* Modal: nearly full-screen with less padding */
  .modal-backdrop { padding: 0; align-items: stretch; }
  .modal {
    border-radius: 0;
    max-height: 100vh;
    height: 100vh;
    width: 100%;
    max-width: 100%;
    /* Extra bottom padding so the Save button isn't crammed against the iOS
       home-bar / browser chrome — captains were having trouble tapping it. */
    padding: 18px 14px calc(160px + env(safe-area-inset-bottom, 0px)) 14px;
  }
  .form-field { margin-bottom: 16px; }
  .form-field input[type="text"],
  .form-field textarea {
    font-size: 16px; /* iOS no-zoom */
  }
  .form-actions {
    flex-direction: column-reverse;
    gap: 8px;
    margin-bottom: 60px;
  }
  .form-actions .btn { width: 100%; min-height: 44px; }
  .chip { padding: 8px 14px; font-size: 0.95em; }
  /* On mobile the roster lists are long and a nested scrollbar on the picker
     felt awkward — let it grow as tall as it needs and rely on the modal's
     own scroll instead. */
  .chip-picker { max-height: none; overflow: visible; }
  .form-section { padding: 12px; margin: 14px 0; }

  /* Admin tabs: horizontal scroll instead of wrapping/overflowing */
  .admin-tabs {
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
  }
  .admin-tabs button {
    flex: 0 0 auto;
    padding: 10px 14px;
    font-size: 0.95em;
    white-space: nowrap;
  }

  /* Tables: allow horizontal scroll on their containers */
  #tabContent { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  table.data { font-size: 0.9em; }
  table.data th, table.data td {
    padding: 8px;
    white-space: nowrap;
  }
}
