/* ── DUAL MONTH AVAILABILITY CALENDAR ────────────────────────── */
.dual-calendar-card {
  /* Whether two months fit depends on how wide THIS CARD is, not how wide the
     window is. The sidebar is 360-464px on a laptop while the viewport is
     1280-1440, so a viewport media query showed two months in a box that could
     only hold one, and clipped the second. */
  container-type: inline-size;
  container-name: cal;
  background: #ffffff;
  border-radius: 14px;
  border: 1px solid #e5e7eb;
  padding: 16px 14px 12px;
  color: #111827;
  font-family: inherit;
  margin-bottom: 18px;
  box-sizing: border-box;
  width: 100%;
  max-width: 100%;
}

/* Offline warning banner (fail closed) */
.calendar-offline-banner {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #b91c1c;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 12px;
  text-align: center;
  line-height: 1.4;
}

/* Dual Months Wrap */
.calendar-months-wrap {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  width: 100%;
  box-sizing: border-box;
}

/* Month headers & layout */
.calendar-month {
  width: 100%;
  box-sizing: border-box;
  min-width: 0;
}

.month-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 44px;
  height: auto;
  margin-bottom: 8px;
}

.month-title {
  font-size: 15px;
  font-weight: 700;
  color: #111827;
  text-align: center;
  flex: 1;
}

.nav-btn {
  background: transparent;
  border: 1px solid #e5e7eb;
  border-radius: 50%;
  width: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #374151;
  transition: background-color 0.15s ease, border-color 0.15s ease;
  flex-shrink: 0;
  padding: 0;
}

.nav-btn:hover {
  background: #f3f4f6;
  border-color: #d1d5db;
  color: #111827;
}

.header-spacer {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
}

/* Mobile Next Month Button on Month 0 */
.month-header .mobile-next {
  display: inline-flex;
}

/* Weekdays */
.weekdays-row {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  text-align: center;
  font-size: 11px;
  font-weight: 600;
  color: #6b7280;
  margin-bottom: 6px;
}

/* Days Grid */
.days-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  row-gap: 2px;
  column-gap: 0;
  width: 100%;
  box-sizing: border-box;
}

.calendar-day {
  position: relative;
  aspect-ratio: 1;
  /* No min-height. Combined with aspect-ratio it also sets a minimum WIDTH, so
     34px here forced every month to be at least 7 x 34 = 238px and the grid
     overflowed its container -- clipped at 320px on one month, and at 1280 on
     two. The grid's 1fr columns size the cells now, and they stay square. */
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  background: transparent;
  color: #111827;
  transition: background-color 0.12s ease;
  user-select: none;
  padding: 0;
  box-sizing: border-box;
}

.calendar-day.empty {
  cursor: default;
  pointer-events: none;
}

.calendar-day.disabled:not(.blackout) {
  color: #d1d5db;
  cursor: not-allowed;
  pointer-events: none;
}

.calendar-day .day-inner {
  /* Fills the cell the grid gives it, capped so it never looks oversized in a
     wide sidebar. Fixed px here would reintroduce a hard minimum width. */
  width: 100%;
  height: 100%;
  max-width: 32px;
  max-height: 32px;
  aspect-ratio: 1;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  z-index: 2;
  box-sizing: border-box;
  font-variant-numeric: tabular-nums;
}

.calendar-day:not(.disabled):not(.empty):not(.blackout):hover .day-inner {
  background: #f3f4f6;
}

/* Blackout / Booked dates styling */
.calendar-day.blackout {
  cursor: not-allowed !important;
  pointer-events: none !important;
}

.calendar-day.blackout .day-inner {
  color: #9ca3af !important;
  text-decoration: line-through;
  text-decoration-color: #ef4444;
  text-decoration-thickness: 1.5px;
  background: #f9fafb !important;
  border-radius: 50%;
  opacity: 0.7;
  position: relative;
}

.calendar-day.blackout .day-inner::after {
  content: "";
  position: absolute;
  width: 22px;
  height: 1.5px;
  background: #ef4444;
  transform: rotate(-45deg);
  pointer-events: none;
}

/* Turnover / Check-out available dates styling ("Half Hatch") */
.calendar-day.turnover-checkout,
.calendar-day.checkout-only {
  cursor: pointer !important;
  pointer-events: auto !important;
}

.calendar-day.turnover-checkout:not(.range-start):not(.range-end) .day-inner,
.calendar-day.checkout-only:not(.range-start):not(.range-end) .day-inner {
  background: linear-gradient(135deg, #ffffff calc(50% - 0.75px), #cbd5e1 calc(50% - 0.75px), #cbd5e1 calc(50% + 0.75px), #fef2f2 calc(50% + 0.75px)) !important;
  color: #111827 !important;
  text-decoration: none !important;
  font-weight: 600;
  border: 1px solid #cbd5e1;
  position: relative;
  opacity: 1;
}

/* Partial diagonal hatch line across the bottom-right half only */
.calendar-day.turnover-checkout:not(.range-start):not(.range-end) .day-inner::after,
.calendar-day.checkout-only:not(.range-start):not(.range-end) .day-inner::after {
  content: "";
  position: absolute;
  width: 10px;
  height: 1.5px;
  background: #ef4444;
  transform: rotate(-45deg);
  bottom: 4px;
  right: 3px;
  pointer-events: none;
  border-radius: 1px;
  display: block !important;
}

.calendar-day.turnover-checkout:not(.range-start):not(.range-end):hover .day-inner,
.calendar-day.checkout-only:not(.range-start):not(.range-end):hover .day-inner {
  background: linear-gradient(135deg, #f1f5f9 calc(50% - 0.75px), #94a3b8 calc(50% - 0.75px), #94a3b8 calc(50% + 0.75px), #fee2e2 calc(50% + 0.75px)) !important;
  border-color: #0D1B2A;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12);
}

.calendar-day.turnover-checkout.range-end .day-inner,
.calendar-day.checkout-only.range-end .day-inner {
  background: #0D1B2A !important;
  color: #ffffff !important;
  border-color: #0D1B2A !important;
  font-weight: 700;
}

.calendar-day.turnover-checkout.range-end .day-inner::after,
.calendar-day.checkout-only.range-end .day-inner::after {
  display: none !important;
}

/* Selection Range Styling */
.calendar-day.in-range {
  background: #f3f4f6;
}

.calendar-day.range-start {
  background: linear-gradient(to right, transparent 50%, #f3f4f6 50%);
}

.calendar-day.range-end {
  background: linear-gradient(to left, transparent 50%, #f3f4f6 50%);
}

.calendar-day.range-start.range-end {
  background: transparent !important;
}

.calendar-day.range-start .day-inner,
.calendar-day.range-end .day-inner {
  background: #0D1B2A !important;
  color: #ffffff !important;
  font-weight: 700;
  box-shadow: 0 2px 6px rgba(13, 27, 42, 0.3);
}

/* Bottom Actions Row */
.calendar-bottom-row {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid #f3f4f6;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.cal-status-text {
  font-size: 12px;
  color: #4b5563;
  font-weight: 500;
}

.cal-reset-btn {
  background: transparent;
  border: none;
  color: #4b5563;
  font-size: 12px;
  font-weight: 600;
  text-decoration: underline;
  cursor: pointer;
  padding: 4px 8px;
}

.cal-reset-btn:hover {
  color: #0D1B2A;
}

/* Legend */
.calendar-legend {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed #e5e7eb;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  color: #4b5563;
  flex-wrap: wrap;
  gap: 8px;
}

.legend-items {
  display: flex;
  align-items: center;
  gap: 12px;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.legend-swatch {
  display: inline-block;
  border-radius: 50%;
}

.legend-swatch.selected {
  width: 9px;
  height: 9px;
  background: #0D1B2A;
}

.legend-swatch.available {
  width: 10px;
  height: 10px;
  background: #ffffff;
  border: 1px solid #9ca3af;
}

.legend-swatch.turnover {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 1px solid #cbd5e1;
  background: linear-gradient(135deg, #ffffff calc(50% - 0.5px), #cbd5e1 calc(50% - 0.5px), #cbd5e1 calc(50% + 0.5px), #fef2f2 calc(50% + 0.5px));
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
}

.legend-swatch.turnover::after {
  content: "";
  position: absolute;
  width: 5px;
  height: 1px;
  background: #ef4444;
  transform: rotate(-45deg);
  bottom: 1.5px;
  right: 1.5px;
  border-radius: 0.5px;
}

.legend-swatch.blackout {
  width: 12px;
  height: 12px;
  background: #f3f4f6;
  border: 1px solid #d1d5db;
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.legend-swatch.blackout .slash {
  position: absolute;
  width: 100%;
  height: 1.5px;
  background: #ef4444;
  transform: rotate(-45deg);
}

.legend-sync-status {
  font-size: 11px;
  color: #166534;
  font-weight: 600;
}

/* One month whenever the card is too narrow for two. The next arrow has to stay
   reachable here, since it is the only way to look further ahead. */
@container cal (max-width: 439.98px) {
  .calendar-month[data-month-index="1"] {
    display: none !important;
  }
  .calendar-month[data-month-index="0"] .header-spacer {
    display: none;
  }
  .calendar-month[data-month-index="0"] .mobile-next {
    display: inline-flex;
  }
}

/* Two months only once the card can actually hold them:
   2 x (7 x 30px) + 14px gap = 434px. */
@container cal (min-width: 440px) {
  .calendar-months-wrap.show-dual {
    grid-template-columns: 1fr 1fr;
    gap: 14px;
  }
  .calendar-months-wrap.show-dual .calendar-month[data-month-index="1"] {
    display: block;
  }
  .calendar-months-wrap.show-dual .calendar-month[data-month-index="0"] .mobile-next {
    display: none;
  }
  .calendar-months-wrap.show-dual .calendar-month[data-month-index="0"] .header-spacer {
    display: block;
  }
}
