/* Calendar: red/amber/green status colours, separate driver dots and a real week. */
.calendar-search-summary:not([hidden]) {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px 16px;
  padding: 10px 12px;
  margin-bottom: 12px;
  border-radius: 10px;
  background: #eef2ff;
  color: #20396b;
}
.calendar-search-summary > div { flex: 1 1 220px; min-width: 0; }
.calendar-search-summary strong { display: block; font-size: 14px; overflow-wrap: anywhere; }
.calendar-search-summary span { display: block; margin-top: 3px; font-size: 12px; color: #536079; }
.calendar-search-summary button { flex: 0 0 auto; }

#calendar-workspace .calendar-panel {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

#calendar-workspace .calendar-legend {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 6px;
  margin: 0 0 12px;
  font-size: 12px;
  font-weight: 500;
}

.calendar-colour-key { width: 100%; min-width: 0; }
.calendar-colour-key > summary { display: flex; align-items: center; gap: 9px; min-height: 36px; color: #35435c; font-size: 12px; cursor: pointer; list-style: none; }
.calendar-colour-key > summary::-webkit-details-marker { display: none; }
.calendar-colour-key > summary::after { content: "+"; margin-left: auto; font-size: 18px; font-weight: 500; }
.calendar-colour-key[open] > summary::after { content: "−"; }
.calendar-colour-key > summary:focus-visible { outline: 3px solid #96b3f4; outline-offset: 2px; border-radius: 5px; }
#calendar-workspace .calendar-colour-key__preview { display: inline-flex; gap: 3px; }
.calendar-colour-key__preview i { width: 14px; height: 14px; border: 2px solid; border-radius: 4px; }
.calendar-colour-key__hint { color: #687386; font-size: 11px; font-weight: 400; }
.calendar-colour-key__content { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 12px; padding-block: 2px 8px; }
.calendar-colour-key__statuses, .calendar-colour-key__drivers { display: flex; align-items: center; flex-wrap: wrap; gap: 5px; min-width: 0; }
.calendar-colour-key__label { font-size: 11px; color: #52617a; }
#calendar-workspace .calendar-status-key { display: inline-flex; }

#calendar-workspace .calendar-driver-key {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding: 5px 9px;
  border: 1px solid transparent;
  border-radius: 7px;
  color: #38465d;
  background: var(--driver-fill, #f1f3f7);
  font: inherit;
  cursor: pointer;
}

#calendar-workspace .calendar-driver-key--all { background: #f3f6fc; border-color: #dbe3f2; }
#calendar-workspace .calendar-driver-key[aria-pressed="true"] {
  border-color: var(--driver-colour, #2b468c);
  box-shadow: inset 0 0 0 1px var(--driver-colour, #2b468c);
  font-weight: 700;
}
#calendar-workspace .calendar-driver-key:focus-visible { outline: 3px solid #96b3f4; outline-offset: 2px; }

.calendar-driver-key__dot {
  width: 9px;
  height: 9px;
  flex: 0 0 9px;
  border-radius: 50%;
  background: var(--driver-colour, #7a879b);
}

.journey-driver-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  flex: 0 0 8px;
  margin-right: 4px;
  border-radius: 50%;
  background: var(--driver-colour, #7a879b);
}

#calendar-workspace .calendar-review-key {
  margin-left: auto;
  color: #687386;
  font-size: 11px;
}

.mobile-calendar {
  display: none;
}

#jobs-calendar {
  position: relative;
  --fc-border-color: #e8ecf2;
  --fc-today-bg-color: #f7f9ff;
  min-width: 0;
  min-height: 0;
  flex: 1 1 0;
}

#jobs-calendar .fc-toolbar {
  gap: 12px;
  margin-bottom: 14px;
}

#jobs-calendar .fc-toolbar-title {
  color: #23345b;
  font-size: 18px;
  font-weight: 650;
  letter-spacing: -0.35px;
}

#jobs-calendar .fc-button {
  min-height: 38px;
  padding: 7px 12px;
  border-color: #e3e8f1;
  color: #506079;
  background: #fff;
  font-size: 13px;
  font-weight: 600;
  box-shadow: none;
}

#jobs-calendar .fc-button:disabled {
  color: #8b96a6;
  background: #f5f7fa;
  opacity: 1;
}

#jobs-calendar .fc-button-primary:not(:disabled).fc-button-active,
#jobs-calendar .fc-button-primary:not(:disabled):active {
  border-color: #263f8b;
  color: #fff;
  background: #263f8b;
}

#jobs-calendar .fc-button-primary:not(:disabled):hover {
  border-color: #b8c6e8;
  color: #233d88;
  background: #edf1fc;
}

#jobs-calendar .fc-button:focus-visible {
  outline: 3px solid #96b3f4;
  outline-offset: 2px;
}

#jobs-calendar .fc-timegrid-slot {
  height: 48px;
}

#jobs-calendar .fc-timegrid-slot-label,
#jobs-calendar .fc-col-header-cell-cushion {
  color: #667388;
  font-size: 12px;
  font-weight: 500;
}

#jobs-calendar .fc-col-header-cell-cushion {
  padding-block: 11px;
  color: #394762;
  font-weight: 600;
  white-space: nowrap;
}

#jobs-calendar .fc-event {
  border-width: 1px 1px 1px 5px;
  border-radius: 7px;
  box-shadow: none;
  font-weight: 500;
}

/* Passing a date does not change whether a journey is assigned or completed. */
#jobs-calendar .fc-event.event-past { filter: none; opacity: 1; }
#jobs-calendar .fc-event .fc-event-main { color: inherit; }
#jobs-calendar .fc-event.is-large-booking { border-left-width: 8px; }
#jobs-calendar .calendar-job .large-booking-badge { flex: 0 0 auto; font-size: 10px; padding: 2px 4px; }
#jobs-calendar .fc-daygrid-event .large-booking-badge { font-size: 9px; }
#jobs-calendar .calendar-job__customer-line { display: flex; flex-wrap: wrap; align-items: center; flex: 0 0 auto; gap: 2px 6px; min-width: 0; }
#jobs-calendar .calendar-job__customer-line .calendar-job__customer { flex: 0 1 auto; min-width: 0; max-width: 100%; }
#jobs-calendar .calendar-job__phone { min-width: 0; max-width: 100%; font-size: 11px; font-weight: 600; white-space: normal; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }

#jobs-calendar .fc-event.event-pending {
  border-style: dashed;
  border-left-style: solid;
}

#jobs-calendar .fc-event.event-unread {
  box-shadow: inset 0 -3px 0 #d22f43;
}

#jobs-calendar .calendar-job {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 7px;
  line-height: 1.25;
}

#jobs-calendar .calendar-job__top {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 5px;
}

#jobs-calendar .calendar-job__time {
  font-size: 12px;
  font-weight: 700;
}

#jobs-calendar .calendar-job__end-time { font-size: 11px; font-weight: 500; white-space: nowrap; }
#jobs-calendar .calendar-job__overnight {
  display: block;
  font-size: 10px;
  line-height: 1.25;
  font-weight: 600;
  white-space: normal;
}
#jobs-calendar .calendar-job__continuation {
  border-bottom: 1px dashed currentColor;
  padding-bottom: 3px;
}
#jobs-calendar .calendar-job__top { gap: 2px; }
#jobs-calendar .calendar-job__type { margin-left: auto; }
#jobs-calendar .calendar-job__customer { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }

#jobs-calendar .calendar-job__type {
  padding: 0;
  background: transparent;
  font-size: 9px;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
}

#jobs-calendar .calendar-job__customer {
  flex: 0 0 auto;
  font-size: 12px;
  font-weight: 650;
}

#jobs-calendar .calendar-job__route {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  white-space: normal;
  font-size: 11px;
  font-weight: 400;
  opacity: 0.9;
}

#jobs-calendar .calendar-job__driver {
  display: flex;
  flex: 0 0 auto;
  justify-content: space-between;
  gap: 4px;
  font-size: 10px;
  font-weight: 600;
  opacity: 1;
}

#jobs-calendar .calendar-job__review {
  padding: 0 4px;
  border-radius: 4px;
  color: #815519;
  background: #fff2d7;
  font-size: 9px;
}

#jobs-calendar .fc-timegrid-event-short .calendar-job {
  gap: 2px;
  padding: 4px 5px 15px;
}

#jobs-calendar .fc-timegrid-event-short .calendar-job__status,
#jobs-calendar .fc-daygrid-event .calendar-job__route,
#jobs-calendar .fc-daygrid-event .calendar-job__type {
  display: none;
}

#jobs-calendar .fc-timegrid-event-short .calendar-job__route { display: -webkit-box; font-size: 10px; line-height: 1.2; -webkit-line-clamp: 2; }
#jobs-calendar .fc-timegrid-event-short .calendar-job__driver { display: flex; font-size: 10px; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#jobs-calendar .fc-timegrid-event-short .calendar-job__customer { font-size: 11px; }
#jobs-calendar .fc-timegrid-event-short .calendar-job__type { font-size: 8px; }

#jobs-calendar .fc-daygrid-event .calendar-job {
  min-width: 0;
  gap: 2px;
  padding: 3px 4px;
}

#jobs-calendar .fc-daygrid-event .calendar-job__customer,
#jobs-calendar .fc-daygrid-event .calendar-job__phone,
#jobs-calendar .fc-daygrid-event .calendar-job__time {
  font-size: 10px;
}

#jobs-calendar .fc-daygrid-event .calendar-job__driver {
  min-width: 0;
  font-size: 10px;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#jobs-calendar .fc-timegrid-event .fc-event-resizer-end {
  display: block;
  right: 8px;
  left: 8px;
  bottom: 2px;
  height: 14px;
  border-bottom-width: 3px;
  opacity: 0.75;
  cursor: ns-resize;
}

#jobs-calendar .fc-timegrid-event.fc-event-resizable .calendar-job {
  padding-bottom: 19px;
}

#jobs-calendar .fc-timegrid-event .fc-event-resizer-end:hover {
  opacity: 1;
}

@media (max-width: 767px) {
  #calendar-workspace {
    display: flex;
    height: auto;
    min-height: 0;
  }

  #calendar-workspace[hidden] {
    display: none;
  }

  #calendar-workspace .calendar-panel {
    height: auto;
    width: 100%;
    overflow: visible;
    padding: 12px;
    border-radius: 18px;
  }

  #calendar-workspace .calendar-legend {
    flex-wrap: wrap;
    overflow: visible;
    min-height: 0;
    margin-bottom: 8px;
    gap: 4px;
  }

  #calendar-workspace .calendar-review-key {
    display: none;
  }

  #calendar-workspace .calendar-driver-key {
    display: inline-flex;
    min-height: 44px;
    padding: 4px 7px;
    font-size: 11px;
  }

  #jobs-calendar {
    /* FullCalendar writes an inline height for its desktop time grid. */
    height: auto !important;
    flex: 0 0 auto;
    overflow: visible;
  }

  #jobs-calendar .fc-header-toolbar {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    grid-template-areas: "navigation title" "views views";
    gap: 7px 8px;
    margin-bottom: 8px;
  }

  #jobs-calendar .fc-toolbar-chunk:first-child {
    grid-area: navigation;
    justify-content: flex-start;
  }

  #jobs-calendar .fc-toolbar-chunk:nth-child(2) {
    grid-area: title;
    justify-content: flex-end;
  }

  #jobs-calendar .fc-toolbar-chunk:last-child {
    grid-area: views;
    width: 100%;
  }

  #jobs-calendar .fc-toolbar-chunk:last-child .fc-button-group {
    display: flex;
    width: 100%;
    gap: 3px;
    padding: 3px;
    border-radius: 11px;
    background: #f0f3f8;
  }

  #jobs-calendar .fc-toolbar-chunk:last-child .fc-button {
    flex: 1;
    min-height: 44px;
    margin: 0;
    border: 0;
    border-radius: 8px;
    background: transparent;
    font-size: 13px;
  }

  #jobs-calendar .fc-toolbar-chunk:last-child .fc-button-active {
    color: #263f8b;
    background: #fff;
    box-shadow: 0 1px 4px rgb(31 48 83 / 10%);
  }

  #jobs-calendar .fc-toolbar-title {
    font-size: 13px;
    font-weight: 600;
    white-space: normal;
    text-align: right;
  }

  #jobs-calendar .fc-button {
    min-height: 44px;
    padding: 6px 7px;
    font-size: 11px;
  }

  #jobs-calendar .fc-today-button {
    margin-left: 5px;
    padding-inline: 9px;
  }

  /* The same date navigation drives a complete week overview on phones. */
  #jobs-calendar .fc-view-harness {
    display: none;
  }

  #jobs-calendar .mobile-calendar {
    display: flex;
    flex: 0 0 auto;
    flex-direction: column;
    min-height: 0;
    min-width: 0;
    overflow: visible;
  }

  .mobile-calendar__days {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    flex: 0 0 auto;
    gap: 3px;
    padding-bottom: 8px;
    border-bottom: 1px solid #edf0f6;
  }

  #jobs-calendar .mobile-calendar__day {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    min-width: 0;
    min-height: 76px;
    height: auto;
    padding: 5px 0;
    border: 1px solid transparent;
    border-radius: 9px;
    background: #f8f9fc;
    color: #38465d;
    font-size: 12px;
    line-height: 1.2;
    box-shadow: none;
  }

  #jobs-calendar .mobile-calendar__day.is-today {
    border-color: #b7c5ed;
    background: #eff3ff;
  }

  #jobs-calendar .mobile-calendar__day[aria-pressed="true"] {
    border-color: #263f8b;
    background: #263f8b;
    color: #fff;
  }

  .mobile-calendar__weekday {
    font-size: 10px;
    font-weight: 500;
  }

  .mobile-calendar__date {
    font-size: 16px;
    font-weight: 650;
  }

  .mobile-calendar__dots {
    display: flex;
    gap: 2px;
    height: 6px;
    margin-top: 2px;
  }

  .mobile-calendar__dots i {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    box-shadow: 0 0 0 1px #fff;
  }

  .mobile-calendar__count {
    font-size: 9px;
    font-weight: 600;
  }

  .mobile-calendar__agenda-heading {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    min-height: 45px;
  }

  .mobile-calendar__agenda-heading h3 {
    margin: 0;
    color: #25375b;
    font-size: 14px;
    font-weight: 650;
  }

  .mobile-calendar__agenda-heading h3 span {
    margin-left: 5px;
    color: #768296;
    font-size: 11px;
    font-weight: 500;
  }

  #jobs-calendar .mobile-calendar__agenda-heading button {
    width: auto;
    min-height: 44px;
    padding: 6px 0 6px 8px;
    border: 0;
    background: transparent;
    color: #263f8b;
    font-size: 12px;
    font-weight: 600;
  }

  .mobile-calendar__agenda {
    flex: 0 0 auto;
    min-height: 80px;
    min-width: 0;
    overflow: visible;
    padding: 1px 1px 16px;
  }

  .mobile-calendar__group + .mobile-calendar__group {
    margin-top: 15px;
  }

  .mobile-calendar__group h4 {
    margin: 0 0 7px;
    color: #788498;
    font-size: 11px;
    font-weight: 600;
  }

  #jobs-calendar .mobile-calendar__job {
    display: grid;
    grid-template-columns: 51px minmax(0, 1fr) 8px;
    align-items: start;
    gap: 8px;
    width: 100%;
    min-width: 0;
    min-height: 82px;
    height: auto;
    margin: 0 0 7px;
    padding: 11px 9px;
    border: 1px solid #e6eaf2;
    border-left: 5px solid var(--job-colour);
    border-radius: 10px;
    background: var(--job-fill, #fff);
    color: var(--job-ink, #293852);
    text-align: left;
    white-space: normal;
    box-shadow: 0 2px 5px rgb(31 48 83 / 3%);
  }

  #jobs-calendar .mobile-calendar__job.needs-review {
    border-top-style: dashed;
    border-bottom-style: dashed;
    border-right-style: dashed;
  }

  #jobs-calendar .mobile-calendar__job.is-large-booking { border-left-width: 8px; }
  #jobs-calendar .mobile-calendar__job .large-booking-badge { color: var(--job-ink, #293852); }

  .mobile-calendar__time {
    display: flex;
    flex-direction: column;
    gap: 3px;
    color: var(--job-ink, #223b81);
    font-size: 16px;
    font-weight: 650;
    font-variant-numeric: tabular-nums;
    line-height: 1.2;
  }

  .mobile-calendar__time small {
    color: #7a8798;
    font-size: 9px;
    font-weight: 400;
  }

  .mobile-calendar__job-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
    gap: 4px;
    font-size: 12px;
    font-weight: 400;
    line-height: 1.3;
    overflow-wrap: anywhere;
  }

  .mobile-calendar__job-info strong {
    color: var(--job-ink, #293852);
    font-size: 13px;
    font-weight: 650;
  }

  .mobile-calendar__customer { display: flex; flex-wrap: wrap; gap: 2px 6px; }
  .mobile-calendar__phone { font-weight: 600; font-variant-numeric: tabular-nums; }

  .mobile-calendar__assignment {
    display: flex;
    align-items: center;
    gap: 4px;
    color: var(--job-ink, #69758a);
    font-size: 10px;
  }

  .mobile-calendar__status { width: fit-content; padding: 3px 5px; border-radius: 4px; background: rgb(255 255 255 / 72%); color: var(--job-ink, #293852); font-size: 10px; font-weight: 600; }
  .calendar-colour-key > summary { min-height: 44px; }
  .calendar-colour-key__content { max-height: none; overflow: visible; }
  #calendar-workspace .calendar-colour-key .calendar-review-key { display: block; margin-left: 0; font-size: 10px; }

  .mobile-calendar__assignment i {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--job-colour);
  }

  .mobile-calendar__assignment em {
    margin-left: auto;
    padding: 2px 4px;
    border-radius: 4px;
    background: #fff2d7;
    color: #815519;
    font-size: 9px;
    font-style: normal;
  }

  .mobile-calendar__chevron {
    align-self: center;
    color: #8a95a7;
    font-size: 20px;
  }

  .mobile-calendar__empty {
    padding: 38px 16px;
    border-radius: 12px;
    background: #f8f9fc;
    text-align: center;
  }

  .mobile-calendar__empty strong {
    color: #3d4a61;
    font-size: 14px;
    font-weight: 600;
  }

  .mobile-calendar__empty p {
    margin: 7px 0 0;
    color: #79869a;
    font-size: 12px;
  }

  #jobs-calendar .mobile-calendar__days--month .mobile-calendar__day {
    min-height: 48px;
    gap: 0;
    padding: 3px 0;
  }

  .mobile-calendar__days--month .mobile-calendar__day:nth-child(n+8) .mobile-calendar__weekday,
  .mobile-calendar__days--month .mobile-calendar__count {
    display: none;
  }

  #jobs-calendar .mobile-calendar__day.is-outside {
    background: transparent;
    color: #b6beca;
    opacity: 1;
  }

  #jobs-calendar .mobile-calendar button:focus-visible,
  .mobile-calendar__agenda:focus-visible {
    outline: 3px solid #96b3f4;
    outline-offset: -2px;
  }
}
