.coach-calendar {
  padding: 24px;
  background: #131827;
  border: 1px solid #30384d;
  border-radius: 18px;
  color: #f5f7ff;
}

.coach-calendar-header {
  margin-bottom: 22px;
}

.coach-calendar-header h2 {
  margin: 0 0 16px;
  font-size: 1.5rem;
}

.coach-calendar-header p {
  color: #aeb9d1;
  margin-top: 14px;
}

.coach-calendar-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.coach-calendar-controls button {
  padding: 9px 14px;
  border: 1px solid #424b64;
  border-radius: 8px;
  background: #252d42;
  color: #f5f7ff;
  cursor: pointer;
}

.coach-calendar-controls button:hover {
  background: #5147d9;
}

.coach-calendar-grid {
  display: grid;
  gap: 10px;
}

.coach-calendar-week,
.coach-calendar-month {
  grid-template-columns: repeat(7, minmax(0, 1fr));
}

.coach-calendar-day {
  min-width: 0;
  min-height: 150px;
  padding: 10px;
  border: 1px solid #30384d;
  border-radius: 10px;
  background: #1b2233;
}

.coach-calendar-date {
  display: block;
  width: 100%;
  padding: 8px 4px;
  border: 0;
  background: transparent;
  color: #f5f7ff;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
}

.coach-calendar-sessions {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-top: 8px;
}

.coach-calendar-session {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 100%;
  padding: 9px;
  border: 1px solid #5147d9;
  border-radius: 8px;
  background: #29265a;
  color: #fff;
  text-align: left;
  cursor: pointer;
  overflow-wrap: anywhere;
}

.coach-calendar-session strong {
  font-size: 0.82rem;
}

.coach-calendar-session span,
.coach-calendar-session small {
  font-size: 0.72rem;
  color: #cbd1f4;
}

.coach-calendar-session:hover {
  background: #39347a;
}

.coach-calendar-day {
  overflow-wrap: anywhere;
}

.coach-calendar-day:has(.coach-calendar-session) {
  border-color: #5147d9;
}

.coach-calendar-day:not(:has(.coach-calendar-session)) {
  opacity: 0.85;
}

.coach-calendar-day .coach-calendar-date:hover {
  color: #a99fff;
}

.coach-calendar-day .coach-calendar-date:focus-visible,
.coach-calendar-session:focus-visible,
.coach-calendar-controls button:focus-visible {
  outline: 2px solid #a99fff;
  outline-offset: 2px;
}

.coach-calendar-day:empty {
  min-height: 100px;
}

.coach-calendar-day .coach-calendar-sessions:empty {
  min-height: 20px;
}

.coach-calendar-day .coach-calendar-sessions:empty::after {
  content: "No sessions";
  color: #79859d;
  font-size: 0.7rem;
}

.coach-calendar-day .coach-calendar-session + .coach-calendar-session {
  margin-top: 2px;
}

.coach-calendar-day .coach-calendar-session small {
  text-transform: capitalize;
}

.coach-calendar-day .coach-calendar-session strong {
  line-height: 1.35;
}

.coach-calendar-day .coach-calendar-session span {
  line-height: 1.3;
}

.coach-calendar-day .coach-calendar-session small {
  line-height: 1.2;
}

.coach-calendar-day .coach-calendar-date {
  line-height: 1.4;
}

.coach-calendar-day .coach-calendar-sessions {
  max-width: 100%;
}

.coach-calendar-day .coach-calendar-session {
  min-width: 0;
}

.coach-calendar-day .coach-calendar-session * {
  min-width: 0;
}

.coach-calendar-day .coach-calendar-session strong,
.coach-calendar-day .coach-calendar-session span {
  white-space: normal;
}

.coach-calendar-day .coach-calendar-session small {
  white-space: normal;
}

.coach-calendar-day .coach-calendar-date {
  white-space: normal;
}

.coach-calendar-day .coach-calendar-sessions {
  overflow: visible;
}

.coach-calendar-day .coach-calendar-session {
  transition: background 0.15s ease;
}

.coach-calendar-day .coach-calendar-date {
  transition: color 0.15s ease;
}

.coach-calendar-day .coach-calendar-session:active {
  background: #5147d9;
}

.coach-calendar-day .coach-calendar-date:active {
  color: #c6bdff;
}

.coach-calendar-day .coach-calendar-session:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.coach-calendar-day .coach-calendar-date:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.coach-calendar-day .coach-calendar-session[aria-current="true"] {
  border-color: #c6bdff;
}

.coach-calendar-controls button[aria-pressed="true"] {
  background: #5147d9;
  border-color: #8277ff;
}

.coach-calendar-day .coach-calendar-date[aria-current="date"] {
  color: #c6bdff;
}

.coach-calendar-day .coach-calendar-session:hover strong {
  color: #fff;
}

.coach-calendar-day .coach-calendar-session:hover span {
  color: #e2e0ff;
}

.coach-calendar-day .coach-calendar-session:hover small {
  color: #d5d1ff;
}

.coach-calendar-day .coach-calendar-session:focus-visible {
  background: #39347a;
}

.coach-calendar-day .coach-calendar-date:focus-visible {
  border-radius: 4px;
}

.coach-calendar-day .coach-calendar-sessions {
  align-items: stretch;
}

.coach-calendar-day .coach-calendar-session {
  box-sizing: border-box;
}

.coach-calendar-day {
  box-sizing: border-box;
}

.coach-calendar-grid {
  width: 100%;
}

.coach-calendar-day {
  width: 100%;
}

.coach-calendar-day .coach-calendar-date {
  box-sizing: border-box;
}

.coach-calendar-controls button {
  font: inherit;
}

.coach-calendar-session {
  font: inherit;
}

.coach-calendar-date {
  font: inherit;
}

.coach-calendar-day .coach-calendar-date {
  font-weight: 600;
}

.coach-calendar-day .coach-calendar-session strong {
  font-weight: 600;
}

.coach-calendar-day .coach-calendar-session span {
  font-weight: 400;
}

.coach-calendar-day .coach-calendar-session small {
  font-weight: 400;
}

.coach-calendar-month .coach-calendar-day {
  min-height: 120px;
}

.coach-calendar-day .coach-calendar-session {
  word-break: normal;
}

.coach-calendar-day .coach-calendar-date {
  word-break: normal;
}

.coach-calendar-day .coach-calendar-session {
  border-style: solid;
}

.coach-calendar-day {
  border-style: solid;
}

@media (max-width: 900px) {
  .coach-calendar {
    padding: 14px;
  }

  .coach-calendar-week,
  .coach-calendar-month {
    grid-template-columns: repeat(7, minmax(115px, 1fr));
    overflow-x: auto;
  }

  .coach-calendar-grid {
    overflow-x: auto;
  }
}

@media (max-width: 600px) {
  .coach-calendar-header h2 {
    font-size: 1.25rem;
  }

  .coach-calendar-day {
    padding: 7px;
  }

  .coach-calendar-day .coach-calendar-date {
    font-size: 0.8rem;
  }

  .coach-calendar-session {
    padding: 7px;
  }

  .coach-calendar-day .coach-calendar-session strong {
    font-size: 0.75rem;
  }

  .coach-calendar-day .coach-calendar-session span,
  .coach-calendar-day .coach-calendar-session small {
    font-size: 0.68rem;
  }
}

/* V2 calendar readability improvements */

.coach-calendar-session {
  overflow-wrap: normal;
  word-break: normal;
}

.coach-calendar-session strong {
  overflow-wrap: normal;
  word-break: normal;
  hyphens: none;
  line-height: 1.4;
}

.coach-calendar-week {
  grid-template-columns: repeat(7, minmax(145px, 1fr));
  overflow-x: auto;
}

.coach-calendar-month {
  grid-template-columns: repeat(7, minmax(120px, 1fr));
  overflow-x: auto;
}

.coach-calendar-month .coach-calendar-day {
  min-height: 110px;
}

.coach-calendar-month .coach-calendar-session {
  padding: 6px;
}

.coach-calendar-month .coach-calendar-session strong {
  font-size: 0.72rem;
}

@media (max-width: 900px) {
  .coach-calendar-week {
    grid-template-columns: repeat(7, minmax(145px, 1fr));
  }

  .coach-calendar-month {
    grid-template-columns: repeat(7, minmax(120px, 1fr));
  }
}

/* Compact month calendar */

.coach-calendar-month {
  grid-template-columns: repeat(7, minmax(0, 1fr));
  overflow-x: visible;
}

.coach-calendar-month .coach-calendar-day {
  min-height: 105px;
  padding: 6px;
}

.coach-calendar-month .coach-calendar-session {
  padding: 5px;
}

.coach-calendar-month .coach-calendar-session strong {
  font-size: 0.68rem;
  line-height: 1.25;
}

.coach-calendar-month .coach-calendar-session span,
.coach-calendar-month .coach-calendar-session small {
  display: none;
}

.coach-calendar-more {
  border: 0;
  background: transparent;
  color: #b8adff;
  cursor: pointer;
  font-size: 0.72rem;
  text-align: left;
  padding: 4px;
}

@media (max-width: 700px) {
  .coach-calendar-month {
    grid-template-columns: repeat(7, minmax(95px, 1fr));
    overflow-x: auto;
  }
}

/* Athlete-specific calendar colours */

.coach-calendar-session {
  border-left: 4px solid var(--athlete-colour, #8875ff);
  border-top-color: #424b64;
  border-right-color: #424b64;
  border-bottom-color: #424b64;
  background: #252d42;
}

.coach-calendar-session:hover {
  background: #343d55;
}

.coach-calendar-month .coach-calendar-session
.coach-calendar-athlete-name {
  display: block;
  font-size: 0.65rem;
  color: #c4cbe0;
  margin-top: 2px;
}

.coach-calendar-month .coach-calendar-session strong {
  font-size: 0.7rem;
}

/* Coach calendar athlete and group filters */

.coach-calendar-filters {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin: 16px 0 20px;
  max-width: 650px;
}

.coach-calendar-filters label {
  display: flex;
  flex-direction: column;
  gap: 7px;
  color: #cbd3e6;
  font-size: 0.85rem;
  font-weight: 600;
}

.coach-calendar-filters select {
  width: 100%;
  min-height: 42px;
  padding: 10px 12px;
  border: 1px solid #424b64;
  border-radius: 9px;
  background: #252d42;
  color: #f5f7ff;
  font: inherit;
}

.coach-calendar-filters select:focus-visible {
  outline: 2px solid #a99fff;
  outline-offset: 2px;
}

@media (max-width: 600px) {
  .coach-calendar-filters {
    grid-template-columns: 1fr;
  }
}

/* Calendar programme assignment form */

.coach-calendar-assignment {
  margin: 20px 0;
  padding: 22px;
  background: #1c2436;
  border: 1px solid #38445e;
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 16px;
}

.coach-calendar-assignment h3 {
  margin: 0;
  color: #f5f7ff;
}

.coach-calendar-assignment label {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  max-width: 420px;
  color: #cbd3e6;
}

.coach-calendar-assignment select,
.coach-calendar-assignment input[type="date"] {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid #46516a;
  border-radius: 9px;
  background: #252d42;
  color: #f5f7ff;
  color-scheme: dark;
  font: inherit;
}

.coach-calendar-assignment .athlete-form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}

.coach-calendar-assignment #coachCalendarCancel,
.coach-calendar-assignment #calendarDirectTrainingCancel {
  background: #30394e;
  color: #f5f7ff;
  border: 1px solid #46516a;
  border-radius: 10px;
  padding: 12px 20px;
  font: inherit;
  cursor: pointer;
}

.coach-calendar-assignment #coachCalendarCancel:hover:not(:disabled),
.coach-calendar-assignment #calendarDirectTrainingCancel:hover:not(:disabled) {
  background: #414d66;
}

.coach-calendar-assignment #coachCalendarCancel:disabled,
.coach-calendar-assignment #calendarDirectTrainingCancel:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}


/* Programme preview */

.coach-calendar-preview {
  margin: 16px 0;
  padding: 18px;
  border: 1px solid #dbe3ee;
  border-radius: 12px;
  background: #f8fafc;
}

.coach-calendar-preview h4 {
  margin: 0 0 12px;
  font-size: 1rem;
  color: #172554;
}

.coach-calendar-preview > p {
  margin: 8px 0;
  line-height: 1.5;
}

.coach-calendar-preview-sessions {
  display: grid;
  gap: 10px;
  margin-top: 16px;
  max-height: 360px;
  overflow-y: auto;
}

.coach-calendar-preview-session {
  padding: 12px 14px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #ffffff;
}

.coach-calendar-preview-session strong {
  color: #1e40af;
}

.coach-calendar-preview-session p {
  margin: 6px 0;
  line-height: 1.45;
}

.coach-calendar-assignment button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

@media (max-width: 600px) {
  .coach-calendar-preview {
    padding: 12px;
  }
}
/* Calendar direct training session preview */

.calendar-preview-controls {
  margin: 14px 0;
}

.calendar-preview-controls button {
  padding: 10px 16px;
  border: 1px solid #64748b;
  border-radius: 8px;
  background: #334155;
  color: #ffffff;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.calendar-preview-controls button:hover:not(:disabled) {
  background: #475569;
}

.calendar-preview-controls button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.calendar-session-preview {
  margin: 16px 0 20px;
  padding: 20px;
  border: 1px solid #cbd5e1;
  border-radius: 12px;
  background: #f8fafc;
  color: #0f172a;
}

.calendar-session-preview h3 {
  margin: 0 0 12px;
  font-size: 1.2rem;
}

.calendar-session-preview h4 {
  margin: 16px 0 10px;
  font-size: 1rem;
}

.calendar-preview-meta,
.calendar-preview-exercise-details {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 10px 0;
}

.calendar-preview-meta span,
.calendar-preview-exercise-details span {
  display: inline-block;
  padding: 6px 10px;
  border-radius: 6px;
  background: #e2e8f0;
  color: #334155;
  font-size: 0.85rem;
}

.calendar-preview-exercise {
  margin-top: 12px;
  padding: 14px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #ffffff;
}

.calendar-preview-exercise h4 {
  margin-top: 0;
}

.calendar-preview-exercise p {
  margin: 8px 0;
  line-height: 1.5;
}

@media (max-width: 600px) {
  .calendar-session-preview {
    padding: 14px;
  }

  .calendar-preview-controls button {
    width: 100%;
  }

  .calendar-preview-exercise {
    padding: 12px;
  }
}

/* Calendar session preview refinements */

.calendar-session-preview {
  background: #111827;
  color: #f3f4f6;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 14px;
  padding: 24px;
}

.calendar-session-preview h3,
.calendar-session-preview h4 {
  color: #ffffff;
}

.calendar-preview-training-plan {
  margin-top: 24px;
}

.calendar-preview-training-plan h4 {
  margin: 0 0 12px;
  font-size: 0.9rem;
  font-weight: 700;
}

.calendar-preview-training-plan p {
  margin: 0;
  color: #dbe3ef;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 1.8;
}

.calendar-preview-exercises {
  margin-top: 24px;
}

.calendar-session-preview .calendar-preview-meta span {
  background: rgba(255, 255, 255, 0.08);
  color: #e5e7eb;
}

.calendar-session-preview .calendar-preview-exercise {
  color: #e5e7eb;
}


/* Direct training assignment removal */
.coach-calendar-session-wrapper {
  position: relative;
  min-width: 0;
}

.coach-calendar-session-wrapper .coach-calendar-session {
  display: block;
  width: 100%;
}

.coach-calendar-session-wrapper:has(
  .coach-calendar-remove-assignment
) .coach-calendar-session {
  padding-right: 30px;
}

.coach-calendar-remove-assignment {
  position: absolute;
  top: 5px;
  right: 5px;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  padding: 0;
  border: 1px solid #ef4444;
  border-radius: 5px;
  background: #252d42;
  color: #f87171;
  font: inherit;
  font-size: 18px;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
}

.coach-calendar-remove-assignment:hover {
  background: #7f1d1d;
  color: #ffffff;
}

.coach-calendar-remove-assignment:focus-visible {
  outline: 2px solid #f87171;
  outline-offset: 2px;
}

.coach-calendar-remove-assignment:disabled {
  opacity: 0.55;
  cursor: wait;
}

@media (max-width: 600px) {
  .coach-calendar-remove-assignment {
    width: 26px;
    height: 26px;
    top: 4px;
    right: 4px;
  }

  .coach-calendar-session-wrapper:has(
    .coach-calendar-remove-assignment
  ) .coach-calendar-session {
    padding-right: 34px;
  }
}

/* Training status dots and calendar legend */
.coach-calendar-status-legend {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px 16px;
  margin: 12px 0;
  padding: 10px 12px;
  border: 1px solid #424b64;
  border-radius: 8px;
  background: #252d42;
  color: #e5e7eb;
  font-size: 0.8rem;
}

.coach-calendar-status-legend > strong {
  margin-right: 6px;
}

.coach-calendar-legend-item,
.coach-calendar-session-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.coach-calendar-status-dot {
  display: inline-block;
  flex: 0 0 auto;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #94a3b8;
}

.coach-calendar-status-dot[data-status="SCHEDULED"] {
  background: #94a3b8;
}

.coach-calendar-status-dot[data-status="IN_PROGRESS"] {
  background: #f59e0b;
}

.coach-calendar-status-dot[data-status="COMPLETED"] {
  background: #22c55e;
}

.coach-calendar-status-dot[data-status="PARTIAL"] {
  background: #a78bfa;
}

.coach-calendar-status-dot[data-status="SKIPPED"] {
  background: #ef4444;
}

.coach-calendar-status-dot[data-status="CANCELLED"] {
  background: transparent;
  border: 2px solid #cbd5e1;
  box-sizing: border-box;
}

@media (max-width: 600px) {
  .coach-calendar-status-legend {
    gap: 8px 12px;
    font-size: 0.75rem;
  }
}

/* Month view training status dots */
.coach-calendar-month .coach-calendar-session {
  position: relative;
  padding-right: 19px;
}

.coach-calendar-month .coach-calendar-session .coach-calendar-session-status {
  display: block;
  position: absolute;
  top: 7px;
  right: 6px;
  width: 9px;
  height: 9px;
  font-size: 0;
  line-height: 0;
}

.coach-calendar-month .coach-calendar-session .coach-calendar-status-dot {
  display: block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
}

/* Preserve space for the existing cancellation X */
.coach-calendar-month .coach-calendar-session-wrapper:has(
  .coach-calendar-remove-assignment
) .coach-calendar-session .coach-calendar-session-status {
  right: 25px;
}