/* ===== CALENDAR ===== */
.calendar-container {
  background: white;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  overflow: auto;
}

.calendar-grid {
  display: grid;
  min-width: 700px;
}

/* Header row: day columns */
.cal-header-row {
  display: grid;
  grid-template-columns: 80px repeat(7, 1fr);
  background: var(--primary);
  color: white;
  position: sticky;
  top: 0;
  z-index: 10;
}

.cal-header-time {
  padding: .6rem .5rem;
  font-size: .75rem;
  font-weight: 600;
  border-right: 1px solid rgba(255,255,255,.2);
  text-align: center;
}

.cal-header-day {
  padding: .6rem .5rem;
  text-align: center;
  border-right: 1px solid rgba(255,255,255,.2);
}
.cal-header-day:last-child { border-right: none; }
.cal-day-name { font-size: .75rem; font-weight: 600; opacity: .8; text-transform: uppercase; }
.cal-day-num { font-size: 1.1rem; font-weight: 700; }
.cal-header-day.today { background: rgba(255,255,255,.15); }
.cal-header-day.today .cal-day-num {
  background: white;
  color: var(--primary);
  border-radius: 50%;
  width: 28px; height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
}

/* Venue section */
.cal-venue-section { border-bottom: 2px solid var(--border); }
.cal-venue-header {
  display: grid;
  grid-template-columns: 80px repeat(7, 1fr);
  background: var(--neutral-light);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 40px;
  z-index: 9;
}
.cal-venue-label {
  grid-column: 1 / -1;
  padding: .4rem .75rem;
  font-size: .8rem;
  font-weight: 700;
  color: var(--primary-dark);
  text-transform: uppercase;
  letter-spacing: .5px;
  background: #f0fdf4;
  border-bottom: 1px solid var(--border);
}

/* Court rows */
.cal-court-row {
  display: grid;
  grid-template-columns: 80px repeat(7, 1fr);
  border-bottom: 1px solid var(--border);
  min-height: 40px;
}
.cal-court-row:last-child { border-bottom: none; }

.cal-court-label {
  padding: .4rem .5rem;
  font-size: .75rem;
  font-weight: 600;
  color: var(--neutral);
  background: #fafafa;
  border-right: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  word-break: break-word;
}

/* Day cells */
.cal-day-cell {
  border-right: 1px solid var(--border);
  padding: 2px;
  min-height: 40px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  position: relative;
}
.cal-day-cell:last-child { border-right: none; }
.cal-day-cell.today { background: #fafff8; }
.cal-day-cell.closed { background: repeating-linear-gradient(45deg, #f9fafb, #f9fafb 4px, #f3f4f6 4px, #f3f4f6 8px); }

/* Slot chip */
.slot-chip {
  display: block;
  padding: 2px 5px;
  border-radius: 4px;
  font-size: .72rem;
  font-weight: 600;
  line-height: 1.3;
  cursor: pointer;
  transition: filter .1s;
  border: none;
  text-align: left;
  width: 100%;
  word-break: break-word;
}
.slot-chip:hover { filter: brightness(.9); }
.slot-chip.available {
  background: var(--primary-light);
  color: var(--primary-dark);
}
.slot-chip.booked {
  background: #fef3c7;
  color: #92400e;
}
.slot-chip.league {
  background: #ede9fe;
  color: #5b21b6;
}
.slot-chip.tournament {
  background: #fce7f3;
  color: #9d174d;
}
.slot-chip.closed {
  background: #f3f4f6;
  color: #9ca3af;
  cursor: default;
}
.slot-chip.admin-can-book {
  background: var(--primary-light);
  color: var(--primary-dark);
}

/* Timeslot label inside chip */
.slot-time { display: block; font-size: .68rem; font-weight: 500; opacity: .75; }

/* Legend */
.cal-legend {
  display: flex;
  flex-wrap: wrap;
  gap: .75rem;
  padding: .75rem 1rem;
  background: #fafafa;
  border-top: 1px solid var(--border);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}
.legend-item {
  display: flex;
  align-items: center;
  gap: .4rem;
  font-size: .78rem;
  color: var(--neutral);
}
.legend-dot {
  width: 12px; height: 12px;
  border-radius: 3px;
  flex-shrink: 0;
}

/* ===== BOOKING DETAIL (inside modal) ===== */
.booking-detail { display: flex; flex-direction: column; gap: 1rem; }
.booking-info-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: .75rem;
}
.booking-info-item { display: flex; flex-direction: column; gap: .2rem; }
.booking-info-item .label { font-size: .75rem; font-weight: 600; color: var(--neutral); text-transform: uppercase; }
.booking-info-item .value { font-size: .95rem; font-weight: 500; }

.timeslot-picker {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
  gap: .4rem;
}
.timeslot-btn {
  padding: .4rem .5rem;
  border-radius: var(--radius);
  border: 1.5px solid var(--border);
  background: white;
  font-size: .8rem;
  cursor: pointer;
  text-align: center;
  transition: all .15s;
}
.timeslot-btn:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); }
.timeslot-btn.selected { background: var(--primary); color: white; border-color: var(--primary); }
.timeslot-btn:disabled { opacity: .4; cursor: not-allowed; background: var(--neutral-light); }

@media (max-width: 640px) {
  /* Contain the 700px-wide grid within the scroll container.
     The existing overflow:auto on .calendar-container handles internal scroll. */
  .calendar-container { max-width: 100%; }
}
