/* Court Schedule */
.schedule-page { --schedule-max: 1400px; }

.stack-team-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1rem;
  margin-bottom: 1.5rem;
  padding: 1rem;
  background: white;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.stack-team-bar p {
  margin: 0;
  font-size: 0.95rem;
}

.stack-team-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.schedule-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
  padding: 1rem;
  background: white;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.date-nav {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.date-nav button {
  background: var(--cream-dark);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.5rem 0.75rem;
  cursor: pointer;
  font-size: 1rem;
}

.date-nav button:hover { background: var(--border); }

.date-display {
  font-weight: 600;
  min-width: 180px;
  text-align: center;
}

.view-toggle {
  display: flex;
  gap: 0.25rem;
  margin-left: auto;
}

.view-toggle button {
  padding: 0.5rem 1rem;
  border: 1px solid var(--border);
  background: white;
  cursor: pointer;
  font-size: 0.875rem;
}

.view-toggle button:first-child { border-radius: var(--radius) 0 0 var(--radius); }
.view-toggle button:last-child { border-radius: 0 var(--radius) var(--radius) 0; }

.view-toggle button.active {
  background: var(--green-primary);
  color: white;
  border-color: var(--green-primary);
}

#court-view-toggle { margin-left: auto; }

.schedule-toolbar .schedule-mode-toggle { margin-left: 0; }

#schedule-help-btn { flex-shrink: 0; }

/* Legend */
.schedule-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.25rem;
  margin-bottom: 1.5rem;
  font-size: 0.875rem;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.legend-swatch {
  width: 16px;
  height: 16px;
  border-radius: 3px;
  border: 1px solid rgba(0,0,0,0.1);
}

/* Court tabs (mobile default) */
.court-tabs {
  display: flex;
  gap: 0.25rem;
  margin-bottom: 1rem;
  overflow-x: auto;
}

.court-tab {
  flex: 1;
  min-width: 70px;
  padding: 0.75rem 0.5rem;
  border: 1px solid var(--border);
  background: white;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.875rem;
  border-radius: var(--radius);
  text-align: center;
}

.court-tab.active {
  background: var(--green-primary);
  color: white;
  border-color: var(--green-primary);
}

.ball-machine-status {
  padding: 0.75rem 1rem;
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

.ball-machine-status.in-use {
  border-color: var(--activity-mens);
  background: #f8f5fc;
}

/* Timeline view (single court) */
.schedule-timeline {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.time-slot {
  display: flex;
  align-items: stretch;
  border-bottom: 1px solid var(--border);
  min-height: 44px;
}

.time-slot:last-child { border-bottom: none; }

.slot-time {
  width: 70px;
  flex-shrink: 0;
  padding: 0.5rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  background: var(--cream);
  display: flex;
  align-items: center;
  justify-content: center;
  border-right: 1px solid var(--border);
}

.slot-content {
  flex: 1;
  min-width: 0;
  padding: 0.5rem 0.75rem;
  display: flex;
  align-items: center;
  cursor: pointer;
  transition: background 0.15s;
}

.slot-content:hover { background: var(--cream); }

.slot-content.open {
  color: var(--green-primary);
  font-weight: 500;
}

.slot-content.open:hover { background: #e8f4ec; }

.slot-content.booked {
  cursor: default;
  align-items: flex-start;
}

.slot-content.booked .slot-label {
  white-space: normal;
  overflow: visible;
  text-overflow: unset;
  line-height: 1.3;
}
.slot-content.booked.own,
.slot-content.booked.editable { cursor: pointer; }
.slot-content.booked.own:hover,
.slot-content.booked.editable:hover { background: #fff8e7; }

.slot-content.activity { cursor: default; font-weight: 600; font-size: 0.9rem; overflow: hidden; }

.slot-label {
  font-size: 0.9rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Grid view (compare all courts) */
.schedule-grid-wrap {
  overflow-x: auto;
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.schedule-grid {
  display: grid;
  grid-template-columns: 70px repeat(4, minmax(120px, 1fr));
  min-width: 600px;
}

.grid-header {
  padding: 0.75rem 0.5rem;
  font-weight: 600;
  font-size: 0.85rem;
  text-align: center;
  background: var(--green-primary);
  color: white;
  border-bottom: 1px solid var(--border);
}

.grid-header.corner {
  background: var(--green-dark);
}

.grid-time {
  padding: 0.35rem 0.5rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  background: var(--cream);
  border-bottom: 1px solid var(--border);
  border-right: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
}

.grid-cell {
  padding: 0.25rem;
  border-bottom: 1px solid var(--border);
  border-right: 1px solid var(--border);
  min-height: 36px;
  min-width: 0;
  font-size: 0.75rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  line-height: 1.2;
  overflow: hidden;
}

.grid-cell.activity {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: block;
  padding: 0.35rem 0.25rem;
}

.grid-cell.booked {
  align-items: flex-start;
  justify-content: flex-start;
  text-align: left;
  padding: 0.35rem 0.25rem;
  white-space: normal;
  overflow: visible;
  text-overflow: unset;
  line-height: 1.25;
}

.grid-cell:hover:not(.activity):not(.booked) { background: #e8f4ec; }
.grid-cell.booked.own,
.grid-cell.booked.editable { cursor: pointer; }

/* Activity & booking colors */
.slot-content.activity-type-challenge-day,
.grid-cell.activity-type-challenge-day,
.legend-swatch.activity-type-challenge-day { background: var(--activity-challenge-day); }
.slot-content.activity-type-mixed-singles,
.grid-cell.activity-type-mixed-singles,
.legend-swatch.activity-type-mixed-singles { background: var(--activity-mixed-singles); color: white; }
.slot-content.activity-type-mixed-doubles,
.grid-cell.activity-type-mixed-doubles,
.legend-swatch.activity-type-mixed-doubles { background: var(--activity-mixed-doubles); color: white; }
.slot-content.activity-type-womens-doubles,
.grid-cell.activity-type-womens-doubles,
.legend-swatch.activity-type-womens-doubles { background: var(--activity-womens-doubles); color: white; }
.slot-content.activity-type-mens-doubles,
.grid-cell.activity-type-mens-doubles,
.legend-swatch.activity-type-mens-doubles { background: var(--activity-mens-doubles); color: white; }
.slot-content.activity-type-womens-30-league,
.grid-cell.activity-type-womens-30-league,
.legend-swatch.activity-type-womens-30-league { background: var(--activity-womens-30-league); color: white; }
.slot-content.activity-type-womens-35-league,
.grid-cell.activity-type-womens-35-league,
.legend-swatch.activity-type-womens-35-league { background: var(--activity-womens-35-league); color: white; }
.slot-content.activity-type-mens-35-league,
.grid-cell.activity-type-mens-35-league,
.legend-swatch.activity-type-mens-35-league { background: var(--activity-mens-35-league); color: white; }
.slot-content.booked,
.grid-cell.booked { background: var(--activity-member); }

.slot-content.booked.reservation-start,
.grid-cell.booked.reservation-start {
  box-shadow: inset 0 2px 0 rgba(27, 94, 59, 0.45);
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 200;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
}

@media (min-width: 600px) {
  .modal-overlay { align-items: center; padding: 1rem; }
}

.modal {
  background: white;
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 1.5rem;
  width: 100%;
  max-width: 420px;
  max-height: 90vh;
  overflow-y: auto;
}

@media (min-width: 600px) {
  .modal { border-radius: var(--radius); }
}

.modal h2 { font-size: 1.25rem; margin-bottom: 0.5rem; }

.modal-meta {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 1.25rem;
}

.duration-control {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin: 1rem 0;
}

.duration-control button {
  width: 40px;
  height: 40px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--cream);
  font-size: 1.25rem;
  cursor: pointer;
}

.duration-control button:hover { background: var(--border); }

.duration-value {
  font-weight: 600;
  font-size: 1.125rem;
  min-width: 80px;
  text-align: center;
}

.modal-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-top: 1.5rem;
  flex-wrap: wrap;
}

.modal-actions-primary {
  display: flex;
  gap: 0.75rem;
  flex: 1;
  justify-content: flex-end;
}

.modal-actions-primary .btn { flex: 1; min-width: 7rem; }

.btn-danger {
  color: #b91c1c;
  border-color: #b91c1c;
}

.btn-danger:hover {
  background: #fef2f2;
}

.ball-machine-unavailable {
  color: var(--activity-mens, #b91c1c);
  font-weight: 600;
}

/* Players */
.players-count {
  font-weight: 500;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.player-chip-list {
  list-style: none;
  margin: 0.5rem 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.player-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--cream);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.3rem 0.75rem;
  font-size: 0.9rem;
}

.player-chip-booker {
  background: var(--green-dark, #1b5e3b);
  border-color: var(--green-dark, #1b5e3b);
  color: #fff;
}

.player-chip-tag {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-muted);
}

.player-chip-remove {
  border: none;
  background: none;
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
  color: var(--text-muted);
  padding: 0;
}

.player-chip-remove:hover {
  color: #b91c1c;
}

.player-add {
  position: relative;
}

.player-add input {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.95rem;
}

.player-search-results {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 2px);
  z-index: 10;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
  max-height: 220px;
  overflow-y: auto;
}

.player-search-item {
  display: flex;
  flex-direction: column;
  width: 100%;
  text-align: left;
  border: none;
  background: none;
  padding: 0.5rem 0.75rem;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
}

.player-search-item:last-child {
  border-bottom: none;
}

.player-search-item:hover {
  background: var(--cream);
}

.player-search-name {
  font-size: 0.9rem;
  font-weight: 500;
}

.player-search-email {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.player-search-guest {
  color: var(--green-dark, #1b5e3b);
  font-weight: 500;
}

.player-search-loading {
  padding: 0.5rem 0.75rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.player-guest-form {
  margin-top: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.player-guest-form input {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.95rem;
}

.player-guest-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
}

.btn-sm {
  padding: 0.35rem 0.75rem;
  font-size: 0.85rem;
}

#reservation-notes {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-family: inherit;
  resize: vertical;
}

.help-modal {
  max-width: 520px;
}

.help-modal-content {
  font-size: 0.95rem;
  line-height: 1.5;
}

.help-modal-content section + section {
  margin-top: 1.25rem;
}

.help-modal-content h3 {
  font-size: 1rem;
  margin: 0 0 0.5rem;
  color: var(--green-dark);
}

.help-modal-content ul {
  margin: 0;
  padding-left: 1.25rem;
}

.help-modal-content li + li {
  margin-top: 0.4rem;
}

.help-modal-contact {
  margin: 1.25rem 0 0;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.help-modal-actions {
  justify-content: stretch;
}

.help-modal-actions .btn {
  width: 100%;
}

.compare-view { display: none; }
.compare-view.active { display: block; }
.tab-view { display: none; }
.tab-view.active { display: block; }

@media (max-width: 899px) {
  .schedule-grid-wrap {
    overflow-x: hidden;
  }

  .schedule-grid {
    min-width: 0;
    width: 100%;
    grid-template-columns: 48px repeat(4, minmax(0, 1fr));
  }

  .grid-header {
    font-size: 0.72rem;
    padding: 0.45rem 0.2rem;
    line-height: 1.2;
  }

  .grid-time {
    font-size: 0.65rem;
    padding: 0.2rem 0.15rem;
  }

  .grid-cell {
    font-size: 0.6rem;
    padding: 0.15rem 0.1rem;
    min-height: 28px;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}

@media (max-width: 380px) {
  .schedule-grid {
    grid-template-columns: 40px repeat(4, minmax(0, 1fr));
  }

  .grid-header {
    font-size: 0.65rem;
    padding: 0.4rem 0.1rem;
  }

  .grid-time {
    font-size: 0.6rem;
  }

  .grid-cell {
    font-size: 0.55rem;
    min-height: 26px;
  }
}

@media (min-width: 900px) {
  .view-toggle { display: flex; }
}

/* Month calendar (shared with admin) */
.admin-calendar {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 1.5rem;
}

.admin-calendar-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.admin-calendar-header h3 {
  margin: 0;
  flex: 1;
  text-align: center;
  font-family: var(--font-display);
  font-size: 1.25rem;
  min-width: 160px;
}

.admin-calendar-nav {
  background: var(--cream-dark);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.4rem 0.75rem;
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
}

.admin-calendar-nav:hover { background: var(--border); }

.admin-calendar-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.25rem;
  margin-bottom: 1rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.admin-calendar-legend span {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.admin-cal-legend-swatch {
  width: 12px;
  height: 12px;
  border-radius: 2px;
  flex-shrink: 0;
}

.admin-cal-legend-swatch.is-booking { background: var(--activity-member); border: 1px solid var(--border); }
.admin-cal-legend-swatch.activity-type-challenge-day { background: var(--activity-challenge-day); }
.admin-cal-legend-swatch.activity-type-mixed-singles { background: var(--activity-mixed-singles); }
.admin-cal-legend-swatch.activity-type-mixed-doubles { background: var(--activity-mixed-doubles); }

.admin-calendar-weekdays {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 1px;
  margin-bottom: 0.25rem;
}

.admin-calendar-weekdays span {
  text-align: center;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  padding: 0.25rem;
}

.admin-calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.admin-cal-day {
  background: white;
  min-height: 110px;
  min-width: 0;
  padding: 0.35rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  overflow: hidden;
}

.admin-cal-day.is-other-month { background: var(--cream); }
.admin-cal-day.is-clickable { cursor: pointer; }
.admin-cal-day.is-clickable:hover { background: var(--cream-dark); }
.admin-cal-day.is-today .admin-cal-day-num {
  background: var(--green-primary);
  color: white;
}
.admin-cal-day.is-selected .admin-cal-day-num {
  box-shadow: 0 0 0 2px var(--green-primary);
}

.admin-cal-day-num {
  font-size: 0.8rem;
  font-weight: 600;
  width: 1.5rem;
  height: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  margin-bottom: 0.15rem;
}

.admin-cal-events {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow: hidden;
}

.admin-cal-event {
  font-size: 0.65rem;
  line-height: 1.25;
  padding: 0.15rem 0.3rem;
  border-radius: 3px;
  min-width: 0;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.admin-cal-event.is-booking {
  background: var(--activity-member);
  color: var(--text-primary);
  border: 1px solid var(--border);
}

.admin-cal-event.activity-type-challenge-day { background: var(--activity-challenge-day); }
.admin-cal-event.activity-type-mixed-singles { background: var(--activity-mixed-singles); color: white; }
.admin-cal-event.activity-type-mixed-doubles { background: var(--activity-mixed-doubles); color: white; }
.admin-cal-event.activity-type-womens-doubles { background: var(--activity-womens-doubles); color: white; }
.admin-cal-event.activity-type-mens-doubles { background: var(--activity-mens-doubles); color: white; }
.admin-cal-event.activity-type-womens-30-league { background: var(--activity-womens-30-league); color: white; }
.admin-cal-event.activity-type-womens-35-league { background: var(--activity-womens-35-league); color: white; }
.admin-cal-event.activity-type-mens-35-league { background: var(--activity-mens-35-league); color: white; }

.admin-cal-more {
  font-size: 0.65rem;
  color: var(--text-muted);
  padding: 0.1rem 0.25rem;
}

@media (max-width: 899px) {
  .admin-calendar {
    padding: 0.65rem;
    overflow-x: hidden;
  }

  .admin-calendar-header h3 {
    font-size: 1.05rem;
    min-width: 0;
  }

  .admin-calendar-legend {
    gap: 0.5rem 0.75rem;
    font-size: 0.72rem;
  }

  .admin-calendar-weekdays span {
    font-size: 0;
    padding: 0.15rem 0;
  }

  .admin-calendar-weekdays span::first-letter {
    font-size: 0.65rem;
    font-weight: 600;
  }

  .admin-calendar-grid {
    width: 100%;
    min-width: 0;
  }

  .admin-cal-day {
    min-height: 58px;
    padding: 0.2rem;
  }

  .admin-cal-day-num {
    font-size: 0.7rem;
    width: 1.25rem;
    height: 1.25rem;
    margin-bottom: 0.1rem;
  }

  .admin-cal-event {
    font-size: 0.55rem;
    padding: 0.1rem 0.15rem;
    line-height: 1.15;
  }

  .admin-cal-more {
    font-size: 0.55rem;
  }
}

@media (max-width: 380px) {
  .admin-cal-day {
    min-height: 48px;
    padding: 0.15rem;
  }

  .admin-cal-day-num {
    font-size: 0.65rem;
    width: 1.1rem;
    height: 1.1rem;
  }

  .admin-cal-event {
    font-size: 0.5rem;
    padding: 0.08rem 0.1rem;
  }

  .admin-cal-more {
    font-size: 0.5rem;
  }
}
