/* HTMX Calendar Styles */

/* Calendar wrapper */
.calendar-wrapper {
  position: relative;
  width: 100%;
}

#calendar-wrapper{
  width: 100%;
}

/* Date selector */
.date-selector {
  position: relative;
  z-index: 10;
}

/* Calendar states */
.calendar-open {
  background-color: #F0F2EF !important;
}

.dates-selected-container {
  background-color: RGBA(230, 233, 229, 0.8) !important;
}

.dates-selected {
  background-color: var(--color-green) !important;
}


.dates-selected svg {
  fill: white !important;
}

/* Calendar popup */
.calendar-popup {
  position: absolute;
  top: calc(100% + 10px);
  left: 0;
  width: 100%;
  min-height: 300px;
  padding: 15px;
  background: white;
  border-radius: 8px;
  box-shadow: 0 0 10pt 0 rgba(153, 155, 168, 0.75);
  z-index: 1000;
  display: none;
}

.calendar-popup.calendar-visible {
  display: block;
}

@media (max-width: 60em) {
  .calendar-popup {
    width: 100%;
    max-width: 404px;
  }
}

/* Loading indicator */
.calendar-loader {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(255, 255, 255, 0.8);
  z-index: 1001;
  display: none;
  justify-content: center;
  align-items: center;
  border-radius: 8px;
}

.calendar-loader.htmx-request {
  display: flex !important;
}

.calendar-loader .spinner {
  width: 40px;
  height: 40px;
  border: 4px solid #f3f3f3;
  border-top: 4px solid var(--color-green);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Calendar header */
.calendar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
  padding: 0 10px;
}

.calendar-month-title {
  font: normal normal bold 16px/24px Barlow;
  letter-spacing: 0;
  color: #484d42;
  margin: 0;
  flex: 1;
  text-align: center;
}

.calendar-nav-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 4px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.2s;
}

.calendar-nav-btn:hover {
  background-color: var(--color-gray-border);
}

.calendar-nav-btn svg {
  fill: #484d42;
}

/* Calendar table */
.calendar-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.calendar-weekdays {
  font: normal normal bold 16px/24px Barlow;
  letter-spacing: 0;
  color: #484d42;
}

.calendar-weekdays th {
  height: 32px;
  width: calc(100% / 7);
  text-align: center;
  padding: 8px 0;
}

.calendar-week {
  /* Don't use flex - let table layout handle it */
}

/* Date cells */
.calendar-date {
  height: 32px;
  width: calc(100% / 7);
  text-align: center;
  font: normal normal normal 14px/21px Barlow;
  letter-spacing: -0.1px;
  color: #484d42;
  position: relative;
  cursor: default;
  padding: 0;
}

.calendar-date .day-number {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 32px;
  width: 32px;
  margin: 0 auto;
  border-radius: 50%;
  transition: all 0.2s ease;
}

/* Available dates */
.calendar-date.available {
  cursor: pointer;
}

.calendar-date.available:hover .day-number {
  background-color: var(--color-green);
  color: white;
}

/* Disabled dates */
.calendar-date.disabled {
  opacity: 0.3;
  cursor: not-allowed;
  position: relative;
}

.calendar-date.disabled::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 40%;
  height: 1px;
  background-color: #9B9B9B;
  transform: translate(-50%, -50%) rotate(45deg);
}

.calendar-date.disabled .day-number {
  color: #9B9B9B;
}

/* Other month dates */
.calendar-date.other-month {
  opacity: 0.4;
}

.calendar-date.other-month.disabled {
  visibility: hidden;
}

/* Selected dates - prominent round circles */
.calendar-date.selected-checkin .day-number,
.calendar-date.selected-checkout .day-number {
  background-color: var(--color-green) !important;
  color: white !important;
  border-radius: 50% !important;
  font-weight: 500;
  position: relative;
  z-index: 2;
}

/* Start date - light green only on right half */
.calendar-date.selected-checkin::before {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 50%;
  height: 100%;
  background-color: rgba(99, 180, 103, 0.2);
  z-index: 1;
}

/* End date - light green only on left half */
.calendar-date.selected-checkout::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 50%;
  height: 100%;
  background-color: rgba(99, 180, 103, 0.2);
  z-index: 1;
}

/* Date range - connected without gaps */
.calendar-date.in-range {
  background-color: rgba(99, 180, 103, 0.2) !important;
  position: relative;
  z-index: 1;
}

.calendar-date.in-range .day-number {
  background-color: transparent;
  position: relative;
  z-index: 2;
}

/* Hover preview range (check-in selected, hovering potential check-out) */
.calendar-date.hover-in-range {
  background-color: rgba(99, 180, 103, 0.2) !important;
  z-index: 1;
}

.calendar-date.hover-in-range .day-number {
  background-color: transparent;
}

.calendar-date.hover-checkout {
  background-color: transparent !important; /* prevent full-cell fill */
  position: relative;
}

.calendar-date.hover-checkout::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 50%;
  height: 100%;
  background-color: rgba(99, 180, 103, 0.2);
  z-index: 1;
}

.calendar-date.hover-checkout .day-number {
  position: relative;
  z-index: 2; /* keep number above the half-fill */
}

/* Today indicator */
.calendar-date.today .day-number {
  font-weight: bold;
  position: relative;
}

.calendar-date.today .day-number::after {
  content: '';
  position: absolute;
  bottom: 2px;
  left: 50%;
  transform: translateX(-50%);
  width: 4px;
  height: 4px;
  background-color: var(--color-green);
  border-radius: 50%;
}

.calendar-date.today.selected-checkin .day-number::after,
.calendar-date.today.selected-checkout .day-number::after {
  background-color: white;
}

/* Past dates */
.calendar-date.past {
  opacity: 0.5;
}

/* Unit availability count (property pages) */
.calendar-date .unit-count {
  position: absolute;
  bottom: 2px;
  right: 4px;
  font-size: 10px;
  font-weight: bold;
  color: var(--color-green);
  background-color: rgba(255, 255, 255, 0.9);
  border-radius: 8px;
  padding: 0 4px;
  line-height: 14px;
  z-index: 3;
}

.calendar-date.selected-checkin .unit-count,
.calendar-date.selected-checkout .unit-count {
  color: white;
  background-color: rgba(0, 0, 0, 0.3);
}

.calendar-date.disabled .unit-count {
  opacity: 0.5;
}

/* Focus styles for accessibility */
.calendar-date.available:focus-visible {
  outline: 2px solid var(--color-green);
  outline-offset: 2px;
}

.calendar-nav-btn:focus-visible {
  outline: 2px solid var(--color-green);
  outline-offset: 2px;
}

/* Responsive adjustments */
@media (max-width: 60em) {
  .calendar-popup {
    left: 50%;
    transform: translateX(-50%);
  }

  .date-selection-mobile {
    width: 100% !important;
  }
}

/* Animation for calendar appearance */


@keyframes fadeInSlideDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Mobile scroll adjustments */
@media (max-width: 60em) {
  html {
    scroll-behavior: smooth;
  }
}


#calendar-disabled-date-manual{
  opacity: 0.3;
  cursor: not-allowed;
  position: relative;
  pointer-events: none;
}

#calendar-disabled-date-manual::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 40%;
  height: 1px;
  background-color: #9B9B9B;
  transform: translate(-50%, -50%) rotate(45deg);
}
