/* Modern Premium Calendar - Apple Style */

.calendar {
  background: #ffffff;
  border-radius: 20px;
  box-shadow: 0 20px 40px -10px rgba(15, 23, 42, 0.06);
  padding: clamp(1.5rem, 3vw, 2.5rem);
  width: 100%;
  max-width: none;
  margin: 0;
  border: 1px solid rgba(15, 23, 42, 0.06);
  font-family: "SF Pro Text", "SF Pro Display", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  box-sizing: border-box;
  position: relative;
  overflow: hidden;
}

.calendar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.75rem;
  gap: 1.25rem;
  flex-wrap: nowrap;
  border-bottom: 1px solid rgba(15, 23, 42, 0.08);
  padding-bottom: 1rem;
}

.calendar-nav-btn {
  background: transparent;
  border: 1px solid rgba(15, 23, 42, 0.1);
  border-radius: 10px;
  width: 38px;
  height: 38px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #111827;
  transition: all 0.2s ease;
  flex-shrink: 0;
  min-width: 38px;
}

.calendar-nav-btn:hover {
  background: rgba(15, 23, 42, 0.04);
  border-color: rgba(15, 23, 42, 0.2);
}

.calendar-nav-btn:active {
  transform: scale(0.93);
}

.calendar-header-content {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
  flex-wrap: nowrap;
  min-width: 0;
}

/* Inline dropdown selects */
.calendar-header-select {
  padding: 0.5rem 0.8rem;
  border: 1px solid rgba(15, 23, 42, 0.1);
  border-radius: 10px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  background: white;
  color: #111827;
  transition: all 0.2s ease;
  font-family: inherit;
  flex: 0 1 auto;
  min-width: 0;
}

.calendar-header-select:hover {
  border-color: rgba(10, 102, 255, 0.4);
  background: rgba(10, 102, 255, 0.06);
}

.calendar-header-select:focus {
  outline: none;
  border-color: #0a66ff;
  box-shadow: 0 0 0 3px rgba(10, 102, 255, 0.12);
}

.view-toggle {
  display: inline-flex;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  overflow: hidden;
  height: 32px;
}

.view-btn {
  background: transparent;
  border: none;
  border-right: 1px solid #e5e7eb;
  padding: 0.4rem 0.85rem;
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  color: #6b7280;
  transition: all 0.15s ease;
  line-height: 1;
  display: flex;
  align-items: center;
}

.view-btn:last-child {
  border-right: none;
}

.view-label-short {
  display: none;
}

.view-btn.active {
  background: #2b8cff;
  color: #ffffff;
  font-weight: 600;
}

.view-btn:hover:not(.active) {
  background: #f9fafb;
  color: #374151;
}

.calendar-title {
  margin: 0;
  font-size: clamp(1.35rem, 2vw, 1.75rem);
  font-weight: 700;
  color: #111827;
  cursor: pointer;
  padding: 0.4rem 0.9rem;
  border-radius: 12px;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  white-space: nowrap;
  flex-shrink: 1;
  min-width: 0;
}

.calendar-title:hover {
  background: rgba(15, 23, 42, 0.04);
}

.calendar-title .year {
  font-weight: 400;
  opacity: 0.65;
  flex-shrink: 0;
}

.calendar-title-caret {
  font-size: 0.9rem;
  opacity: 0.45;
  transform: translateY(1px);
}

.today-btn {
  background: #2b8cff;
  border: none;
  border-radius: 10px;
  color: #ffffff;
  padding: 0.5rem 1.1rem;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(43, 140, 255, 0.2);
}

.today-btn:hover {
  background: #1f73d8;
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(43, 140, 255, 0.3);
}

.today-btn:active {
  transform: translateY(0);
}

.calendar-grid {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.year-view {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  width: 100%;
  max-width: 100%;
  overflow: hidden;
}

.month-card {
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 14px;
  padding: 1.25rem;
  cursor: pointer;
  transition: all 0.2s ease;
  background: #fbfbfd;
  min-width: 0;
}

.month-card:hover {
  border-color: rgba(10, 102, 255, 0.4);
  background: rgba(10, 102, 255, 0.06);
  transform: translateY(-2px);
}

.month-card-header {
  font-size: 0.8rem;
  font-weight: 600;
  color: #6b7280;
  margin-bottom: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.month-card-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 0.3rem;
}

.month-card-day {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  border-radius: 7px;
  background: transparent;
  color: #9ca3af;
  overflow: hidden;
  padding: 0.2rem;
}

.month-card-day:not(:empty) {
  background: white;
}

.month-card-day.booked {
  background: #ffebee;
  color: #c62828;
  font-weight: 600;
}

.month-card-day.turnover {
  background: linear-gradient(45deg, #ffcdd2 50%, #ffebee 50%);
  color: #1a1a1a;
}

.month-card-day.half-day {
  background: linear-gradient(90deg, #ffffff 50%, #ffebee 50%);
  color: #1a1a1a;
}

.month-card-day.half-day-checkout {
  background: linear-gradient(45deg, #ffffff 50%, #ffebee 50%);
}

.month-card-day.half-day-checkin {
  background: linear-gradient(45deg, #ffebee 50%, #ffffff 50%);
}

.month-card-day.today {
  border: 2px solid #0a66ff;
}

.calendar-grid {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.calendar-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: clamp(0.25rem, 1vw, 0.7rem);
  margin-bottom: 0.6rem;
}

.weekday {
  text-align: center;
  font-weight: 600;
  color: #9ca3af;
  font-size: 0.75rem;
  padding: 0.75rem 0.35rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.calendar-days {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: clamp(0.25rem, 1vw, 0.7rem);
}

.day {
  aspect-ratio: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: 14px;
  border: none;
  background: transparent;
  font-weight: 600;
  cursor: default;
  transition: all 0.2s ease;
  font-size: clamp(0.85rem, 1.6vw, 1rem);
  color: #111827;
  position: relative;
  min-height: clamp(2.2rem, 5vw, 3.4rem);
  gap: 0.15rem;
  padding: 0.25rem;
}

.day .day-number {
  font-size: clamp(0.85rem, 1.6vw, 1rem);
  font-weight: 600;
}

.day .day-price {
  font-size: clamp(0.65rem, 1.2vw, 0.75rem);
  font-weight: 400;
  color: #6b7280;
  line-height: 1;
  display: inline !important;
}

.day.check-in .day-price,
.day.check-out .day-price,
.day.in-range .day-price {
  color: #2b8cff !important;
  font-weight: 500 !important;
  display: inline !important;
  visibility: visible !important;
  opacity: 1 !important;
}

.day:not(.empty):not(.past):not(.booked) {
  cursor: pointer;
}

.day.booked {
  cursor: not-allowed;
}

.day:not(.empty):not(.past):not(.booked):not(.turnover):not(.check-in):not(.check-out):hover {
  background: rgba(43, 140, 255, 0.08);
  border: 1px solid rgba(43, 140, 255, 0.2);
  transform: translateY(-1px);
}

.day.empty {
  background: transparent;
  border: none;
}

.day.past {
  color: #d1d5db;
  background: transparent;
  font-weight: 500;
}

.day.booked {
  background: #ffebee;
  border: none;
  color: #E67E22;
  font-weight: 600;
  position: relative;
}

.day.booked .day-number {
  text-decoration: line-through;
  opacity: 0.6;
}

.day.half-day .day-number {
  text-decoration: none !important;
  opacity: 1 !important;
}

  opacity: 1 !important;
}


.day.turnover .day-number {
  text-decoration: none !important;
  opacity: 1 !important;
}

.day.turnover {
  background: linear-gradient(45deg, #ffcdd2 50%, #ffebee 50%);
  border: none;
  color: #1a1a1a;
  font-weight: 600;
}

.day.half-day {
  background: linear-gradient(90deg, #ffffff 50%, #ffebee 50%);
  border: none;
  color: #1a1a1a;
  font-weight: 600;
  position: relative;
}

/* Checkout day: red left (guest leaving), white right (available for new arrival) */
.day.half-day-checkout {
  background: linear-gradient(45deg, #ffebee 50%, #ffffff 50%);
}

/* Checkin day: white left (available for departure), red right (guest arriving) */
.day.half-day-checkin {
  background: linear-gradient(45deg, #ffffff 50%, #ffebee 50%);
}

.day.half-day::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: none;
  border-radius: 12px;
  pointer-events: none;
}

.day.booked:not(.past):not(.selectable) {
  cursor: not-allowed;
}

.day.today {
  background: #ffffff;
  border: 2px solid rgba(10, 102, 255, 0.6);
  color: #0a66ff;
  font-weight: 700;
}

/* Date range selection styles */
.day.selectable {
  cursor: pointer;
}

.day.selectable:hover:not(.booked):not(.past):not(.check-in):not(.check-out) {
  background: rgba(43, 140, 255, 0.08);
  border: 1px solid rgba(43, 140, 255, 0.2);
  transform: scale(1.05);
}

.day.check-in,
.day.check-out {
  background: #2b8cff;
  color: #ffffff;
  font-weight: 700;
  border-color: #2b8cff;
}

.day.check-in .day-number,
.day.check-out .day-number {
  color: #ffffff;
}

.day.check-in .day-price,
.day.check-out .day-price {
  color: #ffffff !important;
  opacity: 1 !important;
  visibility: visible !important;
}

.day.check-in:hover,
.day.check-out:hover {
  background: #2b8cff;
  color: #ffffff;
}

/* In-range selection - higher specificity to override booked/half-day states */
.day.in-range,
.day.booked.in-range,
.day.half-day.in-range {
  background: rgba(43, 140, 255, 0.12);
  border: 1px solid rgba(43, 140, 255, 0.15);
  color: #1a1a1a;
}

.day.in-range:hover,
.day.booked.in-range:hover,
.day.half-day.in-range:hover {
  background: rgba(43, 140, 255, 0.16);
  border: 1px solid rgba(43, 140, 255, 0.25);
}

.day.in-range .day-number,
.day.booked.in-range .day-number,
.day.half-day.in-range .day-number {
  color: #1a1a1a;
  text-decoration: none;
}

.day.in-range .day-price,
.day.booked.in-range .day-price,
.day.half-day.in-range .day-price {
  color: #2b8cff;
}

/* Dim non-selected dates when a range is active */
.calendar-days.has-selection .day:not(.check-in):not(.check-out):not(.in-range) {
  opacity: 0.4;
  transition: opacity 0.2s ease;
}

.calendar-days.has-selection .day:not(.check-in):not(.check-out):not(.in-range):hover {
  opacity: 0.7;
}

.calendar-loading {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  background: rgba(255, 255, 255, 0.85);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.calendar.is-loading .calendar-loading {
  opacity: 1;
  pointer-events: auto;
}

.calendar-spinner {
  width: 32px;
  height: 32px;
  border-radius: 999px;
  border: 3px solid rgba(10, 102, 255, 0.2);
  border-top-color: #0a66ff;
  animation: calendar-spin 0.8s linear infinite;
}

.calendar-loading-text {
  font-size: 0.9rem;
  font-weight: 600;
  color: #6b7280;
}

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

/* Date Picker Modal */

.calendar-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fadeIn 0.2s ease;
  backdrop-filter: blur(4px);
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.calendar-modal {
  background: white;
  border-radius: 18px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
  max-width: 380px;
  width: 90%;
  animation: slideUp 0.3s ease;
  overflow: hidden;
}

@keyframes slideUp {
  from {
    transform: translateY(30px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.5rem;
  border-bottom: 1px solid rgba(15, 23, 42, 0.06);
  background: #f9fafb;
}

.modal-header h3 {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
  color: #111827;
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: #9ca3af;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: all 0.2s ease;
}

.modal-close:hover {
  background: rgba(15, 23, 42, 0.06);
  color: #111827;
}

.modal-content {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.year-selector,
.month-selector {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.year-selector label,
.month-selector label {
  font-weight: 500;
  color: #6b7280;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.year-selector input,
.month-selector select {
  padding: 0.7rem 1rem;
  border: 1px solid rgba(15, 23, 42, 0.1);
  border-radius: 10px;
  font-size: 0.95rem;
  font-family: inherit;
  transition: all 0.2s ease;
  background: #f9fafb;
}

.year-selector input:focus,
.month-selector select:focus {
  outline: none;
  background: #fff;
  border-color: #0a66ff;
  box-shadow: 0 0 0 3px rgba(10, 102, 255, 0.12);
}

.modal-submit {
  padding: 0.85rem 1.2rem;
  background: #0a66ff;
  color: white;
  border: none;
  border-radius: 10px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  margin-top: 0.5rem;
}

.modal-submit:hover {
  background: #084ecc;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(10, 102, 255, 0.3);
}

.modal-submit:active {
  transform: translateY(0);
}

/* Responsive */
@media (max-width: 1024px) {
  .calendar {
    margin: 0;
    padding: 1.5rem;
  }
  
  .year-view {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 768px) {
  .calendar {
    padding: 1.25rem;
    border-radius: 18px;
  }

  .calendar-header {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-bottom: 1.2rem;
    flex-wrap: nowrap;
  }

  .calendar-header-content {
    gap: 0.5rem;
  }

  .calendar-header-select {
    padding: 0.35rem 0.5rem;
    font-size: 0.82rem;
  }

  .today-btn {
    padding: 0.35rem 0.6rem;
    font-size: 0.82rem;
    white-space: nowrap;
    height: 30px;
    line-height: 1;
  }

  .year-view {
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
  }

  .month-card {
    padding: 1rem;
  }

  .month-card-header {
    font-size: 0.85rem;
    margin-bottom: 0.75rem;
  }

  .weekday {
    font-size: 0.7rem;
    padding: 0.6rem 0.25rem;
  }

  .day {
    font-size: 0.85rem;
  }

  .calendar-modal {
    width: 90%;
    max-width: 340px;
  }
}

@media (max-width: 600px) {
  /* Hide navigation arrows on mobile - use swipe gestures instead */
  .calendar-nav-btn {
    display: none !important;
  }

  /* Utilize full width when arrows are hidden */
  .calendar-header {
    justify-content: center !important;
  }

  .calendar-header-content {
    flex: 1 !important;
    max-width: 100% !important;
    justify-content: space-evenly !important;
    gap: 0.85rem !important;
  }

  .calendar-header-select {
    padding: 0.5rem 0.75rem !important;
    font-size: 0.9rem !important;
    flex: 1 1 auto !important;
    min-width: 0 !important;
  }

  .today-btn {
    padding: 0.5rem 1rem !important;
    font-size: 0.88rem !important;
    flex: 0 1 auto !important;
  }
}

@media (max-width: 480px) {
  .calendar {
    padding: 1rem;
    margin: 0;
    border-radius: 14px;
    overflow: visible;
  }

  .calendar-header {
    gap: 0.5rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
  }
  
  .calendar-header-content {
    gap: 0.4rem;
  }

  .calendar-header-select {
    min-width: 0;
    padding: 0.3rem 0.45rem;
    font-size: 0.78rem;
  }
  
  .view-btn {
    padding: 0.3rem 0.6rem;
    font-size: 0.74rem;
    white-space: nowrap;
  }
  
  .today-btn {
    padding: 0.3rem 0.55rem;
    font-size: 0.78rem;
    height: 28px;
    white-space: nowrap;
  }
  
  .year-view {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }
  
  .weekday {
    font-size: 0.65rem;
    padding: 0.45rem 0.2rem;
  }
  
  .day {
    font-size: 0.7rem;
    padding: 0;
    overflow: hidden;
  }
  
  /* Modal responsive */
  .calendar-modal {
    max-width: 95vw;
    width: calc(100vw - 1rem);
    max-height: 90vh;
    overflow-y: auto;
  }
  
  .modal-content {
    padding: 1.2rem;
    gap: 1.2rem;
  }
}

@media (max-width: 576px) {
  .view-label-long {
    display: none;
  }

  .view-label-short {
    display: inline;
  }
}
