/* General Styling */
:root {
    --primary-color: #2c6e49;
    --primary-hover: #23583b;
    --background-color: #f0f8ff;
    --text-color: #333;
    --border-color: #ddd;
    --available-color: #28a745;
    --booked-color: #dc3545;
    --selected-color: #ffc107;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
    background-color: var(--background-color);
    color: var(--text-color);
    line-height: 1.6;
}

.container {
    max-width: 900px;
    margin: 20px auto;
    padding: 20px;
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

header {
    background-color: var(--primary-color);
    color: white;
    padding: 1.5rem;
    text-align: center;
    border-radius: 8px 8px 0 0;
    margin: -20px -20px 20px -20px;
}

h2 {
    color: var(--primary-color);
    margin-bottom: 20px;
    text-align: center;
}

/* Form Styling */
fieldset {
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 25px;
}

legend {
    color: var(--primary-color);
    font-weight: bold;
    padding: 0 10px;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
}

.form-group {
    display: flex;
    flex-direction: column;
}

label {
    margin-bottom: 5px;
    font-weight: 500;
}

input, select {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 16px;
}

button {
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 15px 30px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 18px;
    font-weight: bold;
    width: 100%;
    margin-top: 10px;
    transition: background-color 0.2s ease-in-out;
}

button:hover {
    background-color: var(--primary-hover);
}

/* Court Map Styling */
#court-map-container {
    padding: 10px 0;
}

.placeholder-text {
    text-align: center;
    color: #888;
    padding: 20px;
}

.court-section {
    margin-bottom: 20px;
}

.court-section h3 {
    margin-bottom: 15px;
    color: var(--text-color);
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 5px;
}

.court-grid {
    display: grid;
    gap: 15px;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
}

.court {
    padding: 20px 10px;
    border-radius: 4px;
    text-align: center;
    font-weight: bold;
    color: white;
    cursor: pointer;
    border: 2px solid transparent;
    transition: transform 0.2s, box-shadow 0.2s;
}

.court:hover {
    transform: translateY(-3px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.court.available {
    background-color: var(--available-color);
}

.court.booked {
    background-color: var(--booked-color);
    cursor: not-allowed;
    opacity: 0.6;
}

.court.selected {
    border-color: var(--primary-color);
    box-shadow: 0 0 10px var(--primary-color);
    transform: scale(1.05);
}

/* Alert Message Styling */
.alert {
    padding: 15px;
    margin-bottom: 20px;
    border-radius: 4px;
    border: 1px solid transparent;
}

.alert.hidden {
    display: none;
}

.alert-success {
    background-color: #d4edda;
    color: #155724;
    border-color: #c3e6cb;
}

.alert-error {
    background-color: #f8d7da;
    color: #721c24;
    border-color: #f5c6cb;
}
/* --- ADMIN STYLES --- */

/* Login Form */
#login-form {
    max-width: 400px;
    margin: 50px auto;
    padding: 30px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: #fff;
}
.login-error {
    color: var(--booked-color);
    margin-top: 10px;
    text-align: center;
}

/* Logout Button */
.logout-button {
    display: inline-block;
    background-color: var(--booked-color);
    color: white;
    padding: 8px 15px;
    text-decoration: none;
    border-radius: 4px;
    margin-bottom: 20px;
    float: right;
}
.logout-button:hover {
    opacity: 0.9;
}

/* Calendar Styling */
#calendar {
    margin-top: 50px;
}
.fc-event {
    cursor: pointer;
}

/* Modal Styling */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0,0,0,0.5);
}

.modal-content {
    background-color: #fefefe;
    margin: 10% auto;
    padding: 30px;
    border: 1px solid #888;
    width: 80%;
    max-width: 500px;
    border-radius: 8px;
    position: relative;
}

.close-button {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    position: absolute;
    top: 10px;
    right: 20px;
}

.close-button:hover,
.close-button:focus {
    color: black;
    text-decoration: none;
    cursor: pointer;
}

.modal-actions {
    margin-top: 20px;
    display: flex;
    gap: 10px;
}
.modal-actions .save-button {
    background-color: var(--primary-color);
}
.modal-actions .cancel-booking-button {
    background-color: var(--booked-color);
}

/* --- UI ENHANCEMENTS --- */

/* Improved Date Input */
input[type="date"] {
    padding: 15px;
    font-size: 1.1em;
    font-weight: bold;
    color: var(--primary-color);
    border: 2px solid var(--border-color);
    cursor: pointer;
    position: relative;
}

/* Card Selection UI (for Players and Time) */
.card-selection {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 15px;
    margin-top: 10px;
}

.player-card, .time-slot-bar {
    padding: 15px;
    text-align: center;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
    font-weight: 500;
}

.player-card:hover, .time-slot-bar:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.player-card.selected, .time-slot-bar.selected {
    background-color: var(--primary-color);
    color: white;
    font-weight: bold;
    transform: scale(1.05);
}

/* Time Slot Bars with Availability */
.time-slot-bar small {
    display: block;
    font-size: 0.8em;
    margin-top: 4px;
    color: var(--available-color);
}

.time-slot-bar.selected small {
    color: white;
}

.time-slot-bar.full {
    background-color: #f8f9fa;
    color: #adb5bd;
    cursor: not-allowed;
    border-color: #e9ecef;
}

.time-slot-bar.full small {
    color: var(--booked-color);
}

/* New Selected Court Color */
.court.selected {
    background-color: #007bff; /* A bright blue for selection */
    border-color: #0056b3;
    box-shadow: 0 0 10px #007bff;
    transform: scale(1.05);
}

/* Booking Confirmation Overlay */
#confirmation-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
}

.confirmation-box {
    background: white;
    padding: 40px;
    border-radius: 10px;
    text-align: center;
    max-width: 500px;
    box-shadow: 0 5px 20px rgba(0,0,0,0.3);
}

.confirmation-box h2 {
    color: var(--primary-color);
    font-size: 2em;
    margin-bottom: 20px;
}

#close-confirmation {
    margin-top: 20px;
    width: auto;
    padding: 12px 30px;
}

#confirmation-overlay.hidden {
    display: none;
}

/* Admin Link Footer */
footer {
    text-align: center;
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
}

footer a {
    color: #888;
    text-decoration: none;
}
/* --- Admin calendar phone optimizations --- */
@media (max-width: 768px) {
  /* Make toolbar wrap nicely (you already have a version of this; keep one) */
  .fc-header-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: .25rem;
    align-items: center;
  }
  .fc-toolbar-chunk:nth-child(1) { order: 1; }
  .fc-toolbar-chunk:nth-child(2) { order: 2; flex: 1; text-align: center; }
  .fc-toolbar-chunk:nth-child(3) { order: 3; }

  /* Tighten button sizing for thumbs */
  .fc .fc-button {
    font-size: .95rem;
    padding: .35rem .6rem;
    line-height: 1.1;
  }

  /* Reduce header title size a bit */
  .fc .fc-toolbar-title {
    font-size: 1.05rem;
    line-height: 1.2;
  }

  /* Timegrid clean-up (if user switches to time/day views) */
  .fc-timegrid-slot-label-frame {
    font-size: .85rem;
  }
  .fc-timegrid-slot {
    height: 2.25rem; /* a bit taller for touch */
  }
  .fc .fc-scroller {
    overscroll-behavior: contain; /* avoid scroll jank inside container */
  }

  /* List view readability (default on phones) */
  .fc-list, .fc-list-table {
    font-size: 1rem;
  }
  .fc-list-event-time, .fc-list-event-title {
    padding: .5rem .25rem !important;
  }

  /* Modal: edge-to-edge & stacked actions on small screens */
  .modal-content {
    width: 96%;
    margin: 15% auto;
    padding: 18px;
  }
  .modal-actions {
    flex-direction: column;
  }
  .modal-actions .save-button,
  .modal-actions .cancel-booking-button {
    width: 100%;
    padding: 12px;
  }
}

/* Slightly larger tap targets everywhere */
.fc a, .fc button, .fc td, .fc th {
  touch-action: manipulation;
}
/* Month view readability */
.fc-daygrid-event {
  white-space: normal;         /* allow wrapping */
  line-height: 1.2;
}
.fc-daygrid-event .fc-event-time {
  font-weight: 600;
}
.fc-daygrid-event .fc-event-title {
  display: block;
  font-size: .9rem;
}

/* "More" popover: bigger text for thumbs */
.fc-popover .fc-popover-body {
  font-size: 1rem;
}

/* Bottom sheet for day details */
.day-sheet {
  position: fixed;
  inset: 0;
  display: none;
  z-index: 9999;
}
.day-sheet[aria-hidden="false"] { display: block; }

.day-sheet__backdrop {
  position: absolute; inset: 0;
  background: rgba(0,0,0,.35);
}

.day-sheet__panel {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  max-height: 80vh;
  background: #fff;
  border-radius: 16px 16px 0 0;
  box-shadow: 0 -8px 24px rgba(0,0,0,.2);
  display: flex; flex-direction: column;
}

.day-sheet__header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid #eee;
}
.day-sheet__header h3 { margin: 0; font-size: 1.05rem; }

.day-sheet__close {
  border: none; background: transparent; font-size: 1.25rem; line-height: 1;
}

.day-sheet__content {
  overflow: auto;
  padding: 8px 12px 16px;
}

.day-sheet__list {
  list-style: none; margin: 0; padding: 0;
}
.day-sheet__item {
  border: 1px solid #eee;
  border-radius: 10px;
  padding: 10px 12px;
  margin: 8px 0;
}
.day-sheet__item h4 {
  margin: 0 0 6px 0; font-size: 1rem;
}
.day-sheet__meta {
  font-size: .95rem; color: #444; line-height: 1.35;
}

@media (min-width: 768px) {
  .day-sheet__panel { max-width: 480px; margin: 0 auto; }
}
