* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  width: 100%;
  min-height: 100%;
  background: #f5f6f7;
}

body {
  min-height: 100vh;
  font-family: Arial, Helvetica, sans-serif;
  color: #222;
}

/*
 * MAIN PAGE
 */

.schedule-page {
  width: calc(100% - 3rem);
  max-width: 1100px;
  min-width: 0;
  margin: 1.5rem auto;
  padding: 1.5rem;
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
}

.schedule-page h1 {
  margin: 0;
  font-size: 1.75rem;
}

.schedule-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.schedule-actions {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-shrink: 0;
}

.schedule-action-button {
  min-height: 44px;
  padding: 0.65rem 1rem;
  border: 1px solid #1769aa;
  border-radius: 6px;
  background: #fff;
  color: #1769aa;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.schedule-action-button:hover {
  background: #eef6fb;
}

.schedule-action-button:focus-visible {
  outline: 3px solid #1769aa;
  outline-offset: 2px;
}

.schedule-action-button--primary {
  background: #1769aa;
  color: #fff;
}

.schedule-action-button--primary:hover {
  background: #125486;
}

.schedule-action-button:disabled {
  cursor: wait;
  opacity: 0.65;
}

.pdf-only-title {
  display: none;
}

/*
 * FULLCALENDAR
 */

#calendar,
.fc {
  width: 100%;
  max-width: 100%;
  min-width: 0;
}

.fc .fc-button {
  min-width: 44px;
  min-height: 44px;
}

.fc .fc-toolbar-title {
  font-size: 1.2rem;
  text-align: center;
}

/*
 * DAY AND DATE HEADERS
 */

.fc .fc-list-day-cushion {
  padding: 0.8rem 0.9rem;
  background: #e8eaec;
  font-size: 1.05rem;
  font-weight: 700;
}

.fc .fc-list-day-text,
.fc .fc-list-day-side-text {
  color: #1f2933;
  font-weight: 700;
  text-decoration: none;
}

/*
 * CURRENT DAY
 */

.fc .fc-list-day.is-current-day .fc-list-day-cushion {
  background: #e8eaec;
  border-left: 5px solid #1769aa;
}

.fc .fc-list-day.is-current-day .fc-list-day-text,
.fc .fc-list-day.is-current-day .fc-list-day-side-text {
  color: #1f2933;
}

.fc .fc-list-day.is-current-day .fc-list-day-text::after {
  content: "Today";
  display: inline-block;
  margin-left: 0.65rem;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  background: #1769aa;
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  line-height: 1.35;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  vertical-align: middle;
}

/*
 * EVENT ROWS
 */

.fc .fc-list-event {
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.fc .fc-list-event * {
  -webkit-tap-highlight-color: transparent;
}

.fc .fc-list-event td {
  padding-top: 1rem;
  padding-bottom: 1rem;
  vertical-align: middle;
  background: #fff;
}

.fc .fc-list-event.is-current-day-event td {
  background: #fff;
}

@media (hover: hover) and (pointer: fine) {
  .fc .fc-list-event:hover td,
  .fc .fc-list-event.is-current-day-event:hover td {
    background: #f4f6f8;
  }
}

.fc .fc-list-event:focus-visible {
  outline: 3px solid #1769aa;
  outline-offset: 2px;
}

/*
 * TIME COLUMN
 */

.fc .fc-list-event-time {
  width: 8.5rem;
  min-width: 8.5rem;
  max-width: 8.5rem;
  padding-right: 0.75rem;
  white-space: normal;
  overflow-wrap: normal;
  word-break: normal;
  hyphens: none;
  font-weight: 600;
  line-height: 1.25;
}

.fc .fc-list-event-graphic {
  width: 1.75rem;
  min-width: 1.75rem;
}

.fc .fc-list-event-title {
  width: 100%;
  font-size: 1rem;
  font-weight: 600;
}

.fc-theme-standard td,
.fc-theme-standard th,
.fc-theme-standard .fc-list {
  border-color: #d2d5d8;
}

/*
 * EVENT TITLE AND ADD-TO-CALENDAR BUTTON
 */

.calendar-event-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  width: 100%;
  min-width: 0;
}

.calendar-event-title {
  min-width: 0;
  overflow-wrap: anywhere;
  color: #222;
  font-weight: 600;
  line-height: 1.4;
}

.add-to-calendar-button {
  display: inline-flex;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: 36px;
  margin-left: auto;
  padding: 0.3rem 0.35rem;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: #1769aa;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
  cursor: pointer;
}

.add-to-calendar-button__icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.add-to-calendar-button__text {
  position: relative;
}

.add-to-calendar-button__text::after {
  position: absolute;
  right: 0;
  bottom: -2px;
  left: 0;
  height: 1px;
  background: currentColor;
  content: "";
  opacity: 0.45;
  transform: scaleX(0);
  transform-origin: left;
  transition:
    transform 160ms ease,
    opacity 160ms ease;
}

.add-to-calendar-button:hover {
  background: #f1f3f5;
  color: #0f587f;
}

.add-to-calendar-button:hover
  .add-to-calendar-button__text::after {
  opacity: 1;
  transform: scaleX(1);
}

.add-to-calendar-button:focus-visible {
  outline: 3px solid #1769aa;
  outline-offset: 2px;
}

.add-to-calendar-button:active {
  background: #e5e8eb;
}

/*
 * EVENT MODAL
 */

body.modal-open {
  overflow: hidden;
}

.event-modal {
  position: fixed;
  inset: 0;
  z-index: 99999;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(0, 0, 0, 0.58);
}

.event-modal.is-open {
  display: flex;
}

.event-modal[hidden] {
  display: none !important;
}

.event-modal__dialog {
  position: relative;
  z-index: 1;
  width: min(620px, 100%);
  max-height: calc(100dvh - 2rem);
  overflow-y: auto;
  padding: 1.5rem;
  border-radius: 14px;
  background: #fff;
  color: #222;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
  transform: translateY(12px);
  transition: transform 0.2s ease;
  overscroll-behavior: contain;
}

.event-modal.is-open .event-modal__dialog {
  transform: translateY(0);
}

.event-modal__dialog h2 {
  margin: 0;
  padding-right: 3rem;
  font-size: 1.5rem;
  line-height: 1.25;
}

.event-modal__close {
  position: absolute;
  top: 0.65rem;
  right: 0.75rem;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: #edf1f4;
  color: #222;
  font-size: 2rem;
  line-height: 1;
  cursor: pointer;
}

.event-modal__close:hover,
.event-modal__close:focus {
  background: #dfe6eb;
}

.event-details {
  display: grid;
  gap: 0.9rem;
  margin: 1.5rem 0;
}

.event-details > div {
  display: grid;
  grid-template-columns: 90px 1fr;
  gap: 0.75rem;
}

.event-details dt {
  font-weight: 700;
}

.event-details dd {
  margin: 0;
}

.event-description {
  padding-top: 1rem;
  border-top: 1px solid #d9dee2;
}

.event-description h3 {
  margin: 0 0 0.5rem;
  font-size: 1rem;
}

.event-description p {
  margin: 0;
  line-height: 1.55;
  white-space: pre-wrap;
}

/*
 * WEEKLY PDF / PRINT CALENDAR
 */

.pdf-weekly-template {
  display: none;
  width: 10.2in;
  margin: 0;
  padding: 0;
  background: #fff;
  color: #111;
  font-family: Arial, Helvetica, sans-serif;
}

.pdf-weekly-header {
  margin-bottom: 0.22in;
  padding-top: 0.04in;
  text-align: center;
}

.pdf-weekly-header h2 {
  margin: 0;
  color: #111;
  font-size: 22px;
  font-weight: 700;
  line-height: 1.2;
}

.pdf-weekly-date-range {
  margin: 0.08in 0 0;
  color: #444;
  font-size: 13px;
  font-weight: 600;
}

.pdf-weekly-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  width: 100%;
  border-top: 1px solid #888;
  border-left: 1px solid #888;
  background: #fff;
}

.pdf-weekly-day {
  min-width: 0;
  min-height: 6.35in;
  border-right: 1px solid #888;
  border-bottom: 1px solid #888;
  background: #fff;
}

.pdf-weekly-day-header {
  min-height: 0.58in;
  padding: 0.1in 0.06in;
  border-bottom: 1px solid #888;
  background: #e8eaec;
  text-align: center;
  break-inside: avoid;
  page-break-inside: avoid;
}

.pdf-weekly-day-name {
  display: block;
  color: #111;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.2;
}

.pdf-weekly-day-date {
  display: block;
  margin-top: 0.04in;
  color: #444;
  font-size: 10px;
  font-weight: 600;
  line-height: 1.2;
}

.pdf-weekly-events {
  display: block;
  width: 100%;
}

.pdf-weekly-event {
  display: block;
  padding: 0.09in 0.065in;
  border-bottom: 1px solid #d5d5d5;
  background: #fff;
  break-inside: avoid;
  page-break-inside: avoid;
}

.pdf-weekly-event:last-child {
  border-bottom: 0;
}

.pdf-weekly-event-time {
  display: block;
  margin-bottom: 0.025in;
  color: #111;
  font-size: 9px;
  font-weight: 700;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.pdf-weekly-event-title {
  display: block;
  color: #111;
  font-size: 9.5px;
  font-weight: 700;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.pdf-weekly-event-location {
  display: block;
  margin-top: 0.025in;
  color: #555;
  font-size: 8px;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.pdf-weekly-empty {
  padding: 0.13in 0.07in;
  color: #777;
  font-size: 9px;
  font-style: italic;
  text-align: center;
}

/*
 * TABLET
 */

@media (max-width: 767px) {
  .schedule-page {
    width: calc(100% - 1rem);
    margin: 0.5rem auto;
    padding: 0.75rem;
    border-radius: 8px;
  }

  .schedule-page h1 {
    font-size: 1.4rem;
  }

  .schedule-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .schedule-actions {
    width: 100%;
  }

  .schedule-action-button {
    flex: 1;
  }

  .fc .fc-toolbar {
    gap: 0.4rem;
  }

  .fc .fc-toolbar-title {
    font-size: 1rem;
  }

  .fc .fc-list-event-time {
    width: 7.5rem;
    min-width: 7.5rem;
    max-width: 7.5rem;
    padding-right: 0.5rem;
    font-size: 0.9rem;
  }

  .calendar-event-content {
    gap: 0.75rem;
  }

  .add-to-calendar-button {
    font-size: 0.85rem;
  }
}

/*
 * SMALL MOBILE
 */

@media (max-width: 560px) {
  .fc .fc-list-event-time {
    width: 7rem;
    min-width: 7rem;
    max-width: 7rem;
  }

  .calendar-event-content {
    align-items: flex-start;
    flex-direction: column;
    gap: 0.55rem;
  }

  .add-to-calendar-button {
    align-self: flex-end;
    margin-left: 0;
    padding-right: 0.25rem;
  }
}

@media (max-width: 500px) {
  .schedule-actions {
    flex-direction: column;
  }

  .schedule-action-button {
    width: 100%;
  }

  .event-modal {
    position: absolute;
    inset: 0;
    display: none;
    align-items: initial;
    justify-content: initial;
    padding: 0;
  }

  .event-modal.is-open {
    display: block;
  }

  .event-modal__dialog {
    position: absolute;
    top: var(--mobile-modal-top, 50%);
    left: 50%;
    width: min(92%, 520px);
    max-width: 520px;
    max-height: calc(100dvh - 2rem);
    overflow-y: auto;
    padding: 1.25rem;
    padding-bottom:
      calc(1.25rem + env(safe-area-inset-bottom));
    border-radius: 18px;
    transform: translate(-50%, -50%);
  }

  .event-modal.is-open .event-modal__dialog {
    transform: translate(-50%, -50%);
  }

  .event-modal__dialog h2 {
    font-size: 1.3rem;
  }

  .event-details > div {
    grid-template-columns: 1fr;
    gap: 0.2rem;
  }

  .event-details dt {
    font-size: 0.85rem;
    color: #555;
  }
}

/*
 * WEEKLY CALENDAR PRINTING
 */

@media print {
  @page {
    size: letter landscape;
    margin: 0.3in;
  }

  html,
  body {
    width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: visible !important;
    background: #fff !important;
  }

  body.printing-weekly .schedule-page,
  body.printing-weekly .event-modal {
    display: none !important;
  }

  body.printing-weekly .pdf-weekly-template {
    display: block !important;
    position: static !important;
    width: 100% !important;
    min-height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    visibility: visible !important;
    opacity: 1 !important;
    background: #fff !important;
    color: #111 !important;
  }

  body.printing-weekly .pdf-weekly-header {
    display: block !important;
    margin: 0 0 0.22in !important;
    padding: 0 !important;
    text-align: center !important;
  }

  body.printing-weekly .pdf-weekly-header h2 {
    margin: 0 !important;
    font-size: 22px !important;
    font-weight: 700 !important;
    line-height: 1.2 !important;
  }

  body.printing-weekly .pdf-weekly-date-range {
    margin: 0.08in 0 0 !important;
    font-size: 13px !important;
    font-weight: 600 !important;
  }

  body.printing-weekly .pdf-weekly-grid {
    display: grid !important;
    grid-template-columns:
      repeat(7, minmax(0, 1fr)) !important;
    width: 100% !important;
    border-top: 1px solid #888 !important;
    border-left: 1px solid #888 !important;
    background: #fff !important;
  }

  body.printing-weekly .pdf-weekly-day {
    display: block !important;
    min-width: 0 !important;
    min-height: 6.35in !important;
    border-right: 1px solid #888 !important;
    border-bottom: 1px solid #888 !important;
    background: #fff !important;
  }

  body.printing-weekly .pdf-weekly-day-header {
    display: block !important;
    min-height: 0.58in !important;
    padding: 0.1in 0.06in !important;
    border-bottom: 1px solid #888 !important;
    background: #e8eaec !important;
    text-align: center !important;
    break-inside: avoid !important;
    page-break-inside: avoid !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  body.printing-weekly .pdf-weekly-day-name {
    display: block !important;
    font-size: 12px !important;
    font-weight: 700 !important;
    line-height: 1.2 !important;
  }

  body.printing-weekly .pdf-weekly-day-date {
    display: block !important;
    margin-top: 0.04in !important;
    font-size: 10px !important;
    font-weight: 600 !important;
  }

  body.printing-weekly .pdf-weekly-events {
    display: block !important;
    width: 100% !important;
  }

  body.printing-weekly .pdf-weekly-event {
    display: block !important;
    padding: 0.09in 0.065in !important;
    border-bottom: 1px solid #d5d5d5 !important;
    background: #fff !important;
    break-inside: avoid !important;
    page-break-inside: avoid !important;
  }

  body.printing-weekly .pdf-weekly-event-time {
    display: block !important;
    margin-bottom: 0.025in !important;
    font-size: 9px !important;
    font-weight: 700 !important;
    line-height: 1.25 !important;
  }

  body.printing-weekly .pdf-weekly-event-title {
    display: block !important;
    font-size: 9.5px !important;
    font-weight: 700 !important;
    line-height: 1.3 !important;
  }

  body.printing-weekly .pdf-weekly-event-location {
    display: block !important;
    margin-top: 0.025in !important;
    font-size: 8px !important;
  }

  body.printing-weekly .pdf-weekly-empty {
    padding: 0.13in 0.07in !important;
    font-size: 9px !important;
    font-style: italic !important;
    text-align: center !important;
  }
}
#calendar-status {
  margin: 1rem 0;
  padding: 0.85rem 1rem;
  border-radius: 6px;
  background: #f1f3f5;
  color: #333;
  font-weight: 600;
}

/* Empty-day placeholder rows */
.fc .calendar-empty-day-event {
  cursor: default;
}

.fc .calendar-empty-day-event:hover td {
  background: inherit;
}

.fc .calendar-empty-day-event .fc-list-event-time,
.fc .calendar-empty-day-event .fc-list-event-graphic {
  width: 0;
  padding-left: 0;
  padding-right: 0;
  border: 0;
}

.fc .calendar-empty-day-message {
  color: #666;
  font-style: italic;
  font-weight: 400;
  pointer-events: none;
}

/* Empty-day message should stay subtle */

.fc .calendar-empty-day-message,
.fc .calendar-empty-day-message
.calendar-event-title {
  color: #8a8a8a;
  font-style: italic;
  font-weight: 400;
}

.fc .calendar-empty-day-event td {
  background: #fafafa;
}