/* =========================================================
   Theme variables
   ========================================================= */
:root {
  --blue: #CE4B00;
  --bg: #C1C6C8;
  --card: #fff;
  --text: #1d2530;
  --muted: #657383;
  --border: #d8dee6;
  --danger: #b42318;
  --dangerBkg: #FBFB46;
  --success: #0f7b3e;
}

/* =========================================================
   Base / layout
   ========================================================= */
* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Arial, system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}

header {
  background: #0b0f14;
  border-bottom: 3px solid #ff6a14;
  padding: 22px 32px;
  display: flex;
  align-items: center;
  gap: 20px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 16px;
}

.brand img {
  width: 64px;
  height: auto;
}

header h1 {
  margin: 0 0 4px;
  font-size: 28px;
  line-height: 1.1;
  letter-spacing: -0.5px;
  color: #f5f7fa;
}

header p {
  margin: 0;
  color: #a9b5c1;
  font-size: 14px;
}

.wrap {
  max-width: 1180px;
  margin: 0 auto;
  padding: 24px;
}

/* =========================================================
   Navigation
   ========================================================= */
.nav {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.nav a {
  display: inline-block;
  text-decoration: none;
  color: var(--blue);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
  font-weight: 700;
}

.nav a.active {
  background: var(--blue);
  color: #fff;
}

/* Push admin links (Teams, Sports, Production Locations) to the right so
   student users are less likely to tap them by mistake. Set Up Game stays
   on the left. */
.nav a:nth-child(2) {
  margin-left: auto;
}

/* =========================================================
   Cards & grids
   ========================================================= */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
  margin-bottom: 18px;
  box-shadow: 0 8px 24px rgba(14, 31, 53, .06);
}

.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.grid3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

/* =========================================================
   Form controls
   ========================================================= */
label {
  display: block;
  font-size: 16px;
  font-weight: 750;
  color: #354458;
  margin-bottom: 6px;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 15px;
  background: #fff;
}

/* =========================================================
   Buttons
   ========================================================= */
button {
  border: 0;
  border-radius: 10px;
  padding: 10px 14px;
  font-weight: 800;
  cursor: pointer;
  background: var(--blue);
  color: white;
}

button.secondary {
  background: #e8edf3;
  color: #18324f;
}

button.danger {
  background: var(--danger);
}

button.success {
  background: var(--success);
}

.buttons {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

/* =========================================================
   Status / message banners
   ========================================================= */
.status {
  padding: 10px 12px;
  border-radius: 10px;
  background: #eef6ff;
  color: #12365f;
  border: 1px solid #cce2ff;
  margin-top: 12px;
}

.error {
  background: #fff1f0;
  color: var(--danger);
  border-color: #ffd0cc;
}

.successmsg {
  background: #edfdf3;
  color: var(--success);
  border-color: #c9f2d9;
}

.muted {
  color: var(--muted);
  font-size: 14px;
}

.pill {
  display: inline-block;
  background: #eef2f7;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  color: #31455f;
  margin-top: 4px;
}

/* =========================================================
   Admin tables
   ========================================================= */
table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
}

th,
td {
  border-bottom: 1px solid var(--border);
  padding: 8px;
  text-align: left;
  vertical-align: top;
}

th {
  font-size: 12px;
  text-transform: uppercase;
  color: #57677c;
  background: #f7f9fb;
}

td input {
  font-size: 13px;
  padding: 7px;
}

/* JSON preview block */
.preview {
  white-space: pre-wrap;
  background: #0b1220;
  color: #e6edf7;
  border-radius: 12px;
  padding: 16px;
  overflow: auto;
  max-height: 420px;
}

/* =========================================================
   Team cards (broadcast scoreboard style)
   ========================================================= */
.teamcard {
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 104px;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 18px;
  background: #fafcff;
  overflow: hidden;
  transition: background-color .2s ease, color .2s ease, border-color .2s ease;
  box-shadow: 0 16px 36px rgba(18, 54, 95, .28);
}

/* Away (left column): logo anchors left, name leans toward center */
.teamcard.away {
  text-align: right;
}

/* Home (right column) mirrored: logo anchors right */
.teamcard.home {
  flex-direction: row-reverse;
}

.teamLogo {
  width: 150px;
  height: 150px;
  flex: 0 0 auto;
  object-fit: contain;
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, .3));
}

.teamText {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 3px;
  min-width: 0;
}

.teamcard.away .teamText {
  align-items: flex-end;
}

.teamMascot {
  font-family: Arial, Helvetica, sans-serif;
  font-size: 24px;
  font-weight: bold;
  letter-spacing: .09em;
  text-transform: uppercase;
  opacity: .85;
  line-height: 1;
}

.teamName {
  font-family: Arial, Helvetica, sans-serif;
  font-size: 30px;
  font-weight: bold;
  letter-spacing: .01em;
  text-transform: uppercase;
  line-height: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.teamCode {
  font-size: 16px;
  font-weight: 700;
  opacity: .65;
  letter-spacing: .05em;
}

/* Legacy team-card helpers (kept for compatibility) */
.teamcard h3 {
  margin: 0 0 8px;
}

.teamcard .pill {
  background: rgba(255, 255, 255, .82);
  color: #1d2530;
}

.teamDetail,
.teamFullName {
  opacity: .92;
}

/* Venue / Location bar (full-width, under the team cards) */
.venueBar {
  width: 100%;
  margin-top: 16px;
  padding: 10px 12px;
  background: #000;
  color: #fff;
  font-family: Arial, Helvetica, sans-serif;
  font-weight: normal;
  font-size: 18px;
  text-align: center;
  border-radius: 10px;
}

/* Unsaved-changes notification banner */
.dirtyNote {
  margin-top: 16px;
  padding: 10px 14px;
  border-radius: 10px;
  background: #fff7e6;
  color: #8a5a00;
  border: 1px solid #ffd591;
  font-weight: 700;
}

/* Light pastel background applied to the Set Up Game card when changes are unsaved */
.card.dirty {
  background: var(--dangerBkg);
  border-color: var(--danger);
  transition: background-color .2s ease, border-color .2s ease;
}

/* =========================================================
   Modal popup (team editor)
   ========================================================= */
.modalOverlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(10, 20, 35, .55);
}

.modalDialog {
  width: 100%;
  max-width: 680px;
  max-height: 90vh;
  overflow: auto;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .35);
}

.modalHeader {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.modalHeader h3 {
  margin: 0;
}

.modalClose {
  background: transparent;
  color: var(--text);
  font-size: 22px;
  line-height: 1;
  padding: 4px 10px;
}

.modalPreview {
  padding: 16px 20px;
  background: #f7f9fb;
}

.modalForm {
  padding: 16px 20px;
}

.modalFooter {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 20px;
  border-top: 1px solid var(--border);
}

/* Compact delete-confirmation dialog */
.modalConfirm {
  max-width: 440px;
}

.modalConfirm p {
  margin: 0;
  font-size: 16px;
}

/* Color swatch shown in the read-only team table */
.swatch {
  display: inline-block;
  width: 26px;
  height: 26px;
  border-radius: 6px;
  border: 1px solid var(--border);
  vertical-align: middle;
}

/* Small logo thumbnail in the read-only team table */
.logoIcon {
  width: 36px;
  height: 36px;
  object-fit: contain;
  vertical-align: middle;
}

.noLogo {
  color: var(--muted);
  font-size: 12px;
  font-style: italic;
}

/* =========================================================
   Small utilities
   ========================================================= */
.small {
  font-size: 12px;
}

.admin-note {
  margin-top: 8px;
}

/* Color picker cell (admin tables) */
.colorCell {
  display: flex;
  gap: 8px;
  align-items: center;
}

.colorCell input[type=color] {
  width: 46px;
  min-width: 46px;
  height: 38px;
  padding: 3px;
}

.colorCell input[type=text] {
  min-width: 110px;
}

/* =========================================================
   Location gate / picker (setup page)
   ========================================================= */
.hidden {
  display: none !important;
}

.locationGate {
  border: 2px solid #d4e2f4;
}

.locationChoices {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 14px;
  margin-top: 16px;
  box-shadow: 0 4px 4px rgba(14, 31, 53, .06);
}

.locationChoice {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
  gap: 4px;
  background: #fff;
  color: var(--blue);
  border: 2px solid var(--border);
  border-radius: 16px;
  padding: 16px;
  box-shadow: 0 6px 16px rgba(14, 31, 53, .05);
  transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease, background .15s ease, color .15s ease;
}

.locationChoice strong {
  font-size: 18px;
}

.locationChoice span {
  font-size: 13px;
  font-weight: 700;
  color: #516176;
}

.locationChoice small {
  font-size: 12px;
  color: #6b7788;
}

.locationChoice:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 24px rgba(14, 31, 53, .10);
  border-color: #9bb5d4;
}

.locationChoice.selected {
  background: var(--blue);
  color: #fff;
  border-color: #071d36;
  transform: scale(1.04);
  box-shadow: 0 16px 36px rgba(18, 54, 95, .28);
}

.locationChoice.selected span,
.locationChoice.selected small {
  color: #e6f0ff;
}

/* Selected-location summary panel */
.selectedLocationPanel {
  display: grid;
  grid-template-columns: 1fr 1.4fr;
  gap: 16px;
  align-items: end;
  margin-top: 18px;
  background: #411C32;
  color: #fff;
  border-radius: 16px;
  padding: 18px;
  border: 1px solid #071d36;
  box-shadow: 0 16px 36px rgba(18, 54, 95, .28);
}

.selectedLocationPanel strong {
  font-size: 28px;
  line-height: 1.1;
}

.selectedLocationPanel label {
  color: #d9e5f5;
}

.selectedLocationPanel input {
  background: #fff;
}

.selectedLocationMeta {
  margin-top: 8px;
  color: #d9e5f5;
  font-size: 14px;
  line-height: 1.45;
}

/* =========================================================
   Admin table edit states (read-only vs editing rows)
   ========================================================= */
td input:disabled,
td input:read-only {
  background: transparent;
  border-color: transparent;
  color: var(--text);
  opacity: 1;
  cursor: default;
}

tr.readonly:hover td {
  background: #f7faff;
}

tr.editing td {
  background: #eef6ff;
}

tr.editing td input {
  border-color: var(--blue);
  background: #fff;
  box-shadow: 0 0 0 2px rgba(18, 54, 95, .15);
}

tr.editing .colorCell input[type=color] {
  border-color: var(--blue);
}

.rowActions {
  display: flex;
  gap: 8px;
  white-space: nowrap;
}

.rowActions button {
  padding: 7px 12px;
  font-size: 13px;
}

/* =========================================================
   Responsive
   ========================================================= */
@media (max-width: 800px) {
  .grid,
  .grid3 {
    grid-template-columns: 1fr;
  }

  .wrap {
    padding: 16px;
  }

  .selectedLocationPanel {
    grid-template-columns: 1fr;
  }

  .locationChoice.selected {
    transform: none;
  }
}
