/* Reservations Calendar Styles */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  background: #f5f5f5;
  color: #333;
  padding: 8px;
  max-width: 100vw;
  overflow-x: hidden;
  width: 100%;
  box-sizing: border-box;
}

.container {
  max-width: 100%;
  margin: 0 auto;
  width: 100%;
  box-sizing: border-box;
}

/* Header Styles */
.page-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #6b7280;
  margin: 0 0 8px 4px;
  font-weight: 600;
}

.header {
  background: white;
  padding: 12px;
  border-radius: 8px;
  margin-bottom: 12px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  width: 100%;
  box-sizing: border-box;
}

/* Bottom row: property legend + refresh. */
.header-bottom {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.header-bottom .property-legend {
  flex: 1 1 auto;
  min-width: 0;
  padding-top: 6px;
}

/* Fixed-color legend for each property (matches grid lanes). */
.property-legend {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.property-legend-item {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 8px;
  color: #374151;
}

.property-legend-swatch {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  background: var(--legend-color, #6b7280);
  flex-shrink: 0;
}

.property-legend-swatch.is-light {
  border: 1px solid #d1d5db;
}

.property-legend-name {
  font-size: 16px;
  font-weight: 700;
  color: #111827;
}

.property-legend-times {
  display: flex;
  flex-direction: column;
  gap: 3px;
  color: #4b5563;
  font-size: 13px;
  line-height: 1.4;
}

.property-legend-note {
  font-size: 12px;
  line-height: 1.4;
  color: #6b7280;
}

.refresh-section {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  flex: 0 0 auto;
  max-width: 140px;
}

.refresh-btn {
  background: transparent;
  color: #007bff;
  border: 1px solid #e5e7eb;
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.refresh-btn:hover:not(:disabled) {
  background: #f3f4f6;
  border-color: #d1d5db;
}

.refresh-btn:disabled {
  color: #9ca3af;
  cursor: not-allowed;
}

.refresh-btn.is-refreshing {
  color: #007bff;
}

.refresh-btn.is-refreshing .refresh-icon {
  animation: refresh-spin 0.9s linear infinite;
}

@keyframes refresh-spin {
  to {
    transform: rotate(360deg);
  }
}

.refresh-status {
  font-size: 11px;
  color: #6b7280;
  line-height: 1.3;
  text-align: right;
  word-break: break-word;
}

/* Cleaning palette ---------------------------------------------------------
   Three semantic states drive both the calendar grid date circles and the
   "Upcoming cleanings" widget rows so the two views stay in sync visually.
   - cleaning   : green   = cleaning day, no cross-property conflict
   - conflict   : red     = cleaning day with another property cleaning too
   - today fill : gray    = "you are here" pill when today has no cleaning */
:root {
  --c-cleaning: #16a34a;
  --c-cleaning-strong: #15803d;
  --c-cleaning-surface: #f0fdf4;
  --c-cleaning-surface-hover: #dcfce7;
  --c-cleaning-border: #bbf7d0;

  --c-conflict: #dc2626;
  --c-conflict-strong: #991b1b;
  --c-conflict-surface: #fef2f2;
  --c-conflict-surface-hover: #fee2e2;
  --c-conflict-border: #fecaca;

  --c-today-fill: #9ca3af;
}

/* Upcoming cleanings widget shell ------------------------------------------
   Container + title + list scaffolding around .info-card rows. */
.upcoming-cleanings {
  background: white;
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 12px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  width: 100%;
  box-sizing: border-box;
}

.upcoming-cleanings-title {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #6b7280;
  margin: 0 0 8px;
}

.upcoming-cleanings-empty {
  font-size: 13px;
  color: #6b7280;
  margin: 0;
}

.upcoming-cleanings-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Expanded list becomes a viewport-bounded scroll area so the collapse
   button (rendered below this <ul>) is always reachable without chasing
   the page. dvh keeps the cap honest on iOS Safari where the URL bar
   inflates plain vh. The fallback to vh covers older browsers. */
.upcoming-cleanings-list.is-expanded {
  max-height: 55vh;
  max-height: 55dvh;
  overflow-y: auto;
  /* Tiny inner padding so the scrollbar (and the focus ring on rows)
     doesn't crowd the content. */
  padding-right: 2px;
  -webkit-overflow-scrolling: touch;
  scrollbar-gutter: stable;
}

.upcoming-cleanings-toggle {
  margin-top: 12px;
  width: 100%;
  padding: 8px 10px;
  border: none;
  background: transparent;
  color: #2563eb;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border-radius: 4px;
}

.upcoming-cleanings-toggle:hover {
  background: #f3f4f6;
}

.upcoming-cleanings-toggle:focus-visible {
  outline: 2px solid rgba(37, 99, 235, 0.4);
  outline-offset: 2px;
}

/* Screen-reader-only copy (same-day turnover context in conflict rows). */
.upcoming-cleaning-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* One property row inside a merged conflict-day card: primary line + jump. */
.upcoming-cleaning-conflict-line {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
}

.upcoming-cleaning-conflict-block {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
}

.upcoming-cleaning-conflict-line-primary {
  font-size: 13px;
  color: #111827;
  text-align: left;
}

/* Continuation of the checkout line above: arrow icon + badge (no repeated name). */
.upcoming-cleaning-conflict-sub {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 8px;
  padding-left: 5px;
  width: 100%;
  box-sizing: border-box;
}

.upcoming-cleaning-conflict-sub-arrow {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  color: #9ca3af;
}

.upcoming-cleaning-conflict-sub .info-card-badge {
  flex-shrink: 0;
}

button.upcoming-cleaning-jump {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
  margin: -4px -4px -4px 0;
  border: none;
  background: transparent;
  color: inherit;
  cursor: pointer;
  border-radius: 6px;
}

button.upcoming-cleaning-jump:hover {
  background: rgba(0, 0, 0, 0.06);
}

button.upcoming-cleaning-jump:focus-visible {
  outline: 2px solid rgba(37, 99, 235, 0.45);
  outline-offset: 1px;
}

/* InfoCard primitive --------------------------------------------------------
   Shared row/card used by both the "Upcoming cleanings" widget rows and the
   reservation list cards. The stripe / surface / border are driven by CSS
   custom properties so callers can theme without overriding rules:
   - .is-clean    : green themed surface (cleaning widget, no conflict)
   - .is-conflict : red themed surface (cleaning widget + reservation cards
                    whose checkout day overlaps another property)
   - .is-neutral  : white surface; callers set --card-stripe inline for the
                    per-property color on a reservation card. */
.info-card {
  --card-stripe: #d1d5db;
  --card-surface: white;
  --card-border: #e5e7eb;

  position: relative;
  padding: 10px 12px 10px 14px;
  border: 1px solid var(--card-border);
  border-radius: 6px;
  background: var(--card-surface);
  outline: none;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.info-card::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: var(--card-stripe);
  border-top-left-radius: 6px;
  border-bottom-left-radius: 6px;
}

.info-card.is-clean {
  --card-stripe: var(--c-cleaning);
  --card-surface: var(--c-cleaning-surface);
  --card-border: var(--c-cleaning-border);
}

.info-card.is-conflict {
  --card-stripe: var(--c-conflict);
  --card-surface: var(--c-conflict-surface);
  --card-border: var(--c-conflict-border);
}

.info-card.is-clickable {
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.info-card.is-clean.is-clickable:hover {
  background: var(--c-cleaning-surface-hover);
  border-color: var(--c-cleaning);
}

.info-card.is-conflict.is-clickable:hover {
  background: var(--c-conflict-surface-hover);
  border-color: var(--c-conflict);
}

.info-card.is-neutral.is-clickable:hover {
  background: #f9fafb;
  border-color: #d1d5db;
}

.info-card.is-clickable:focus-visible {
  box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.25);
}

.info-card-main {
  flex: 1 1 auto;
  min-width: 0;
}

.info-card-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}

.info-card-title {
  font-weight: 600;
  color: #111827;
  font-size: 14px;
}

.info-card-meta {
  font-size: 12px;
  color: #6b7280;
  flex: 0 0 auto;
  white-space: nowrap;
}

.info-card-body {
  margin-top: 4px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
}

.info-card-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
}

.info-card-row-label {
  flex: 0 0 70px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #6b7280;
  font-weight: 600;
}

.info-card-row-value {
  flex: 1 1 auto;
  color: #111827;
  min-width: 0;
}

/* Full-width body rows (merged conflict lines with jump buttons) */
.info-card-body .info-card-row:has(.upcoming-cleaning-conflict-line) {
  width: 100%;
  flex-wrap: nowrap;
}

.info-card-badges {
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.info-card-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  padding: 2px 6px;
  border-radius: 4px;
  color: #374151;
  background: #f3f4f6;
}

.info-card-badge.is-conflict {
  color: var(--c-conflict-strong);
  background: var(--c-conflict-surface-hover);
}

.info-card-badge.is-same-day {
  color: #92400e;
  background: #fde68a;
}

.info-card-badge.is-rbd {
  color: #1f2937;
  background: #e5e7eb;
}

/* Trailing elements (rendered to the right of .info-card-main). */
.info-card-chevron {
  flex: 0 0 auto;
  align-self: center;
  color: #9ca3af;
  transition: transform 0.15s ease, color 0.15s ease;
}

.info-card.is-clean.is-clickable:hover .info-card-chevron,
.info-card.is-clean.is-clickable:focus-visible .info-card-chevron {
  color: var(--c-cleaning-strong);
  transform: translateX(2px);
}

.info-card.is-conflict.is-clickable:hover .info-card-chevron,
.info-card.is-conflict.is-clickable:focus-visible .info-card-chevron {
  color: var(--c-conflict-strong);
  transform: translateX(2px);
}

.info-card-month-hint {
  flex: 0 0 auto;
  align-self: center;
  font-size: 11px;
  color: #9ca3af;
  font-style: italic;
  white-space: nowrap;
}

/* Calendar Styles */
.calendar-container {
  background: white;
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 12px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  width: 100%;
  box-sizing: border-box;
  overflow: hidden;
}

.month-navigation {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.month-title {
  font-size: 18px;
  font-weight: 600;
  color: #222;
}

.nav-btn {
  background: #f0f0f0;
  border: none;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 16px;
  cursor: pointer;
  transition: background 0.2s;
}

.nav-btn:hover {
  background: #e0e0e0;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 0;
  width: 100%;
  box-sizing: border-box;
  border: 1px solid #e0e0e0;
  border-radius: 3px;
  overflow: hidden;
}

.calendar-day-header {
  text-align: center;
  font-size: 16px;
  font-weight: 600;
  color: #666;
  padding: 8px 2px;
  text-transform: uppercase;
}

.calendar-day {
  border-right: 1px solid #e0e0e0;
  border-bottom: 1px solid #e0e0e0;
  border-radius: 0;
  padding: 4px 2px 6px;
  position: relative;
  background: white;
  min-width: 50px;
  min-height: 108px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-sizing: border-box;
}

/* Remove right border from last column */
.calendar-day:nth-child(7n) {
  border-right: none;
}

/* Remove bottom border from last row */
.calendar-day:nth-child(n+36) {
  border-bottom: none;
}

.calendar-day.other-month {
  background: #f9f9f9;
  color: #999;
}

.calendar-day.today {
  background: #ffffff;
}

/* "Today, no cleaning" — neutral gray pill so today is still findable. */
.calendar-day.today:not(.has-cleaning) .day-number {
  background-color: var(--c-today-fill);
  color: white;
}


.day-header {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 35px;
}

.day-number {
  font-size: 18px;
  font-weight: 500;
  margin-bottom: 0;
  line-height: 1.2;
  padding: 5px;
  flex-shrink: 0;
  min-width: 33px;
  text-align: center;
  border: 2px solid transparent;
  border-radius: 50%;
}

/* Cleaning day (active property): colored ring only. The fill is reserved for
   today's date so the current day remains visually distinct. */
.calendar-day.has-cleaning .day-number {
  border-color: var(--c-cleaning);
  color: var(--c-cleaning-strong);
}

/* Cleaning + cross-property conflict: red ring only unless it is today. */
.calendar-day.has-cleaning.has-conflict .day-number {
  border-color: var(--c-conflict);
  color: var(--c-conflict-strong);
}

/* Today + cleaning: fill only the current date with the matching state color. */
.calendar-day.today.has-cleaning .day-number {
  background-color: var(--c-cleaning);
  border-color: var(--c-cleaning-strong);
  color: white;
}

.calendar-day.today.has-cleaning.has-conflict .day-number {
  background-color: var(--c-conflict);
  border-color: var(--c-conflict-strong);
  color: white;
}

/* Two property lanes per day — fixed grid rows keep each property on its slot. */
.property-lanes {
  display: grid;
  gap: 2px;
  width: 100%;
  flex: 1;
  min-height: 0;
  align-content: start;
}

.property-lane {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  min-height: 18px;
}

.reservation-side-by-side {
  display: flex;
  flex-direction: row;
  gap: 0;
  width: 100%;
  margin-top: 2px;
  flex: 1;
  min-height: 18px;
  align-items: stretch;
}

.reservation-block {
  color: white;
  font-size: 8px;
  padding: 1px 2px;
  border-radius: 0;
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
  flex: 1;
  min-height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1.2;
  position: relative;
  background-color: var(--reservation-color);
}

.reservation-block.rbd-block {
  background-color: #ffffff !important;
  color: #111827 !important;
  opacity: 1;
  background-image: none;
  border: 1px dotted #6b7280;
}

.reservation-block.is-light-fill {
  border: 1px solid #d1d5db;
}

.reservation-block.start {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  padding: 1px;
  border-top-left-radius: 100px;
  border-bottom-left-radius: 100px;
}

.reservation-side-by-side .reservation-block {
  margin-top: 0;
  padding: 1px 2px;
  font-size: 7px;
  flex: 0 0 auto;
  align-self: stretch;
}

.reservation-block.middle {
  margin-top: 2px;
  border-radius: 0;
}

.reservation-side-by-side .reservation-block.start {
  font-size: 12px;
  font-weight: 800;
}

.reservation-side-by-side .reservation-block.side-by-side {
  min-width: 0;
}

.reservation-block.end {
  border-top-right-radius: 100px;
  border-bottom-right-radius: 100px;
  flex: 0 0 auto;
  align-self: stretch;
}

.reservation-block.single {
  border-radius: 100px;
}

/* Reservations List Styles */
.reservations-list {
  background: white;
  border-radius: 8px;
  padding: 14px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  width: 100%;
  box-sizing: border-box;
}

.list-title {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 12px;
  color: #222;
}

/* Reservation list item ----------------------------------------------------
   Outer wrapper that frames a single reservation. The header + date area is
   rendered as an .info-card primitive; the wrapper just provides structural
   chrome and hosts the (optional) "Happening today" banner and the comments
   thread below the card. */
.reservation-item {
  --accent-color: var(--c-conflict);
  display: flex;
  flex-direction: column;
  padding: 14px 12px;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  background: #fff;
  margin-bottom: 12px;
}

.reservation-item:last-child {
  margin-bottom: 0;
}

.reservation-item.is-rbd {
  border-style: dotted;
  border-color: #6b7280;
}

/* Comments module gets appended inside .reservation-item, sitting below the
   info-card with a thin divider. */
.reservation-item .comments-container {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid #e9ecef;
}

/* Two-class selector wins specificity over the .reservation-item border
   shorthand. The 2px box-shadow ring gives a visibly thicker frame with no
   layout shift when the class toggles. */
.reservation-item.reservation-item-highlight {
  border-color: var(--accent-color);
  box-shadow: 0 0 0 2px var(--accent-color);
}

/* "Happening today" banner: negative margins bleed to card edges. Tint from
   --accent-color (set inline on .reservation-item). */
.reservation-item-today {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: -14px -12px 12px;
  padding: 6px 12px;
  background: color-mix(in srgb, var(--accent-color) 18%, white);
  color: color-mix(in srgb, var(--accent-color) 55%, black);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border-top-left-radius: 11px;
  border-top-right-radius: 11px;
}

.reservation-item-today-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-color);
  animation: reservation-today-pulse 1.8s ease-out infinite;
}

@keyframes reservation-today-pulse {
  0% {
    box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent-color) 55%, transparent);
  }
  70% {
    box-shadow: 0 0 0 8px transparent;
  }
  100% {
    box-shadow: 0 0 0 0 transparent;
  }
}

@media (prefers-reduced-motion: reduce) {
  .reservation-item-today-dot {
    animation: none;
  }
}

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: #999;
}

.empty-state-icon {
  font-size: 48px;
  margin-bottom: 12px;
}

@media (max-width: 767px) {
  .calendar-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .calendar-day {
    min-width: auto;
  }
}

/* Responsive Styles */
@media (min-width: 768px) {
  body {
    padding: 24px;
  }

  .container {
    max-width: 1200px;
  }

  .header {
    padding: 16px;
  }

  .calendar-container {
    padding: 16px;
  }

  .month-title {
    font-size: 20px;
  }

  .calendar-day-header {
    font-size: 18px;
    padding: 10px 4px;
  }

  .calendar-day {
    padding: 6px 2px 8px;
    min-width: 80px;
    min-height: 130px;
  }

  .day-number {
    font-size: 20px;
  }

  .reservation-block {
    font-size: 9px;
    padding: 2px 4px;
    min-height: 20px;
  }

  .reservation-side-by-side {
    min-height: 20px;
  }

  .reservation-side-by-side .reservation-block {
    font-size: 8px;
  }

  .reservation-block.start,
  .reservation-side-by-side .reservation-block.start {
    font-size: 14px;
    font-weight: 800;
  }

  .reservations-list {
    padding: 18px;
  }

  .list-title {
    font-size: 20px;
  }

  .reservation-item {
    padding: 16px 14px;
  }
}

#calendarOrphanedCommentsContainer {
  display: none;
}

/* Initial page loader shown while config + reservations load. Sized to match
   the rough vertical footprint of the calendar so the page doesn't jump when
   the real content arrives. Reuses the refresh-spin keyframes. */
.calendar-loader {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 96px 20px;
  color: #6b7280;
}

.calendar-loader-spinner {
  color: #007bff;
  animation: refresh-spin 0.8s linear infinite;
}

.calendar-loader-text {
  font-size: 13px;
}

@media (prefers-reduced-motion: reduce) {
  .calendar-loader-spinner {
    animation: none;
  }
}

/* Floating "back to calendar" button. iOS-style frosted glass: translucent
   dark background + backdrop blur. Browsers without backdrop-filter fall
   back to the semi-opaque background, which still reads cleanly. */
.scroll-to-calendar {
  position: fixed;
  bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  right: calc(20px + env(safe-area-inset-right, 0px));
  width: 48px;
  height: 48px;
  border: none;
  border-radius: 50%;
  background: rgba(17, 24, 39, 0.55);
  -webkit-backdrop-filter: blur(12px) saturate(180%);
  backdrop-filter: blur(12px) saturate(180%);
  color: #ffffff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.18);
  opacity: 0;
  visibility: hidden;
  transform: translateY(8px);
  transition: opacity 180ms ease, transform 180ms ease, visibility 180ms, background 180ms ease;
  z-index: 50;
  -webkit-tap-highlight-color: transparent;
}

.scroll-to-calendar.is-visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.scroll-to-calendar:hover {
  background: rgba(17, 24, 39, 0.7);
}

.scroll-to-calendar:focus-visible {
  outline: 2px solid #ffffff;
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  .scroll-to-calendar {
    transition: opacity 0ms, visibility 0ms;
    transform: none;
  }
}

