/**
 * Custom Calendar Widget Styles
 * Green theme matching site design (#4caf50)
 */

/* ==========================================================================
   Base Calendar Container
   ========================================================================== */

.custom-calendar {
  max-width: 100%;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
  overflow: hidden;
  font-family: inherit;
  line-height: 1.5;
}

/* ==========================================================================
   Calendar Header
   ========================================================================== */

.calendar__header {
  background: linear-gradient(135deg, #4caf50 0%, #388e3c 100%);
  color: white;
  padding: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 15px;
}

.calendar__title h3 {
  margin: 0 0 5px 0;
  font-size: 1.2em;
  font-weight: 600;
}

.calendar__current-month {
  font-size: 0.95em;
  opacity: 0.9;
  font-weight: 400;
}

.calendar__navigation {
  display: flex;
  align-items: center;
  gap: 10px;
}

.calendar__nav-btn {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.2s ease, transform 0.1s ease;
  font-size: 18px;
}

.calendar__nav-btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.3);
  transform: scale(1.05);
}

.calendar__nav-btn:active:not(:disabled) {
  transform: scale(0.95);
}

.calendar__nav-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.calendar__nav-btn:focus {
  outline: 2px solid rgba(255, 255, 255, 0.5);
  outline-offset: 2px;
}

.calendar__month-selector {
  border-radius: 20px !important;
  width: auto !important;
  padding: 0 15px;
  height: 36px;
}

/* Simple arrow navigation buttons */
.calendar__nav-arrow {
  background: none;
  border: none;
  color: white;
  font-size: 28px;
  font-weight: bold;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  transition: background-color 0.2s ease, opacity 0.2s ease;
  line-height: 1;
  min-width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.calendar__nav-arrow:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.2);
}

.calendar__nav-arrow:active:not(:disabled) {
  background: rgba(255, 255, 255, 0.3);
}

.calendar__nav-arrow:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.calendar__nav-arrow:focus {
  outline: 2px solid rgba(255, 255, 255, 0.6);
  outline-offset: 2px;
}

/* ==========================================================================
   Calendar Grid Container
   ========================================================================== */

.calendar__grid-container {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0;
  background: #fafafa;
}

/* Desktop: Two months side by side */
@media (min-width: 768px) {
  .calendar__grid-container {
    grid-template-columns: 1fr 1fr;
  }
}

/* ==========================================================================
   Month Grid
   ========================================================================== */

.calendar__month {
  background: white;
  border-right: 1px solid #e0e0e0;
}

.calendar__month:last-child {
  border-right: none;
}

.calendar__month-header {
  padding: 20px 20px 15px;
  border-bottom: 1px solid #f0f0f0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.calendar__month-title {
  margin: 0;
  font-size: 1.1em;
  font-weight: 600;
  color: #333;
}

.calendar__legend {
  display: flex;
  gap: 15px;
  font-size: 0.85em;
}

.calendar__legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  color: #666;
}

.calendar__legend-color {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  flex-shrink: 0;
}

.calendar__legend-color--available {
  background: #4caf50;
}

.calendar__legend-color--unavailable {
  background: #e0e0e0;
}

/* ==========================================================================
   Day Names Header
   ========================================================================== */

.calendar__day-names {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  background: #f8f9fa;
  border-bottom: 1px solid #e0e0e0;
}

.calendar__day-name {
  padding: 12px 8px;
  text-align: center;
  font-size: 0.85em;
  font-weight: 600;
  color: #666;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ==========================================================================
   Calendar Days Grid
   ========================================================================== */

.calendar__days {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0;
}

.calendar__week {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  border-bottom: 1px solid #f0f0f0;
}

.calendar__week:last-child {
  border-bottom: none;
}

/* ==========================================================================
   Individual Day Cells
   ========================================================================== */

.calendar__day {
  position: relative;
  min-height: 48px;
  border-right: 1px solid #f0f0f0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  background: white;
}

.calendar__day:last-child {
  border-right: none;
}

.calendar__day-number {
  position: relative;
  z-index: 2;
  font-weight: 500;
  font-size: 0.9em;
}

/* Empty day cells */
.calendar__day--empty {
  cursor: default;
  background: #fafafa;
}

/* Past dates */
.calendar__day--past {
  background: #f8f8f8;
  color: #bbb;
  cursor: not-allowed;
}

.calendar__day--past .calendar__day-number {
  text-decoration: line-through;
}

/* Today */
.calendar__day--today {
  background: white;
  color: #333;
  font-weight: 600;
  border: 2px dotted #f57c00;
  box-shadow: none;
}

.calendar__day--today::before {
  content: 'TODAY';
  position: absolute;
  top: 2px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 8px;
  font-weight: 600;
  letter-spacing: 0.3px;
  color: #f57c00;
}

/* Available dates */
.calendar__day--available {
  background: white;
  color: #333;
}

.calendar__day--available:hover {
  background: #e8f5e8;
  transform: scale(1.02);
  box-shadow: 0 2px 8px rgba(76, 175, 80, 0.2);
}

.calendar__day--available:focus {
  outline: 2px solid #4caf50;
  outline-offset: -2px;
  z-index: 10;
}

/* Unavailable/booked dates */
.calendar__day--unavailable {
  background: #f5f5f5;
  color: #999;
  cursor: not-allowed;
}

.calendar__day--unavailable::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 20px;
  height: 2px;
  background: #ccc;
  border-radius: 1px;
}

/* Unknown availability */
.calendar__day--unknown {
  background: #fefefe;
  color: #777;
  cursor: not-allowed;
}

.calendar__day--unknown::before {
  content: '?';
  position: absolute;
  top: 2px;
  right: 4px;
  font-size: 10px;
  color: #bbb;
}

/* ==========================================================================
   Date Range Selection States
   ========================================================================== */

/* Hovered date (during selection) */
.calendar__day--hovered.calendar__day--available {
  background: #c8e6c9;
  transform: scale(1.05);
}

/* Range start date */
.calendar__day--range-start {
  background: #4caf50 !important;
  color: white !important;
  font-weight: 600;
}

.calendar__day--range-start::before {
  content: 'IN';
  position: absolute;
  top: 2px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 8px;
  font-weight: 600;
  letter-spacing: 0.5px;
}

/* Range end date */
.calendar__day--range-end {
  background: #388e3c !important;
  color: white !important;
  font-weight: 600;
}

.calendar__day--range-end::before {
  content: 'OUT';
  position: absolute;
  top: 2px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 8px;
  font-weight: 600;
  letter-spacing: 0.5px;
}

/* Dates in selected range */
.calendar__day--in-range {
  background: #e8f5e8 !important;
  color: #2e7d32 !important;
}

.calendar__day--in-range:hover {
  background: #c8e6c9 !important;
}

/* Range styling continuity */
.calendar__day--range-start.calendar__day--range-end {
  background: #4caf50 !important;
}

.calendar__day--range-start.calendar__day--range-end::before {
  content: '1N';
  font-size: 8px;
}

/* ==========================================================================
   Selection Summary
   ========================================================================== */

.calendar__selection {
  padding: 20px;
  border-bottom: 1px solid #e0e0e0;
  background: #fafafa;
}

.calendar__instructions {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #666;
  font-size: 0.9em;
}

.calendar__instructions .mdi {
  color: #4caf50;
  font-size: 1.2em;
}

.calendar__selection-details {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 15px;
}

.calendar__selection-dates {
  display: flex;
  gap: 25px;
  flex-wrap: wrap;
  align-items: center;
}

.calendar__selection-date {
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: flex-start;
}

.calendar__selection-label {
  font-size: 0.8em;
  color: #666;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.calendar__selection-value {
  font-size: 0.95em;
  color: #333;
  font-weight: 500;
}

.calendar__selection-nights {
  color: #4caf50;
  font-size: 1.1em;
  font-weight: 600;
}

.calendar__clear-btn {
  background: none;
  border: 1px solid #ccc;
  border-radius: 20px;
  padding: 6px 12px;
  color: #666;
  font-size: 0.85em;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.2s ease;
  min-height: 32px;
}

.calendar__clear-btn:hover {
  border-color: #999;
  color: #333;
  background: #f0f0f0;
}

.calendar__clear-btn:focus {
  outline: 2px solid #4caf50;
  outline-offset: 2px;
}

/* ==========================================================================
   Booking Controls
   ========================================================================== */

.calendar__booking {
  padding: 20px;
  text-align: center;
  background: white;
}

.calendar__book-btn {
  background: #e0e0e0;
  color: #999;
  border: none;
  border-radius: 25px;
  padding: 12px 30px;
  font-size: 1em;
  font-weight: 600;
  cursor: not-allowed;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: all 0.3s ease;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  min-height: 48px;
}

.calendar__book-btn--active {
  background: linear-gradient(135deg, #4caf50 0%, #388e3c 100%);
  color: white;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(76, 175, 80, 0.3);
}

.calendar__book-btn--active .mdi {
  color: white !important;
}

.calendar__book-btn--active:hover {
  background: linear-gradient(135deg, #66bb6a 0%, #4caf50 100%);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(76, 175, 80, 0.4);
}

.calendar__book-btn--active:active {
  transform: translateY(0);
}

.calendar__book-btn:focus {
  outline: 2px solid #4caf50;
  outline-offset: 2px;
}

/* ==========================================================================
   Loading States
   ========================================================================== */

.calendar__loading {
  padding: 60px 20px;
  text-align: center;
  color: #666;
}

.calendar__spinner {
  width: 40px;
  height: 40px;
  margin: 0 auto 20px;
  border: 3px solid #e0e0e0;
  border-top: 3px solid #4caf50;
  border-radius: 50%;
  animation: calendar-spin 1s linear infinite;
}

@keyframes calendar-spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* ==========================================================================
   Error States
   ========================================================================== */

.calendar__error {
  padding: 40px 20px;
  text-align: center;
  color: #666;
}

.calendar__error .mdi {
  font-size: 3em;
  color: #f44336;
  margin-bottom: 15px;
}

.calendar__retry-btn {
  background: #4caf50;
  color: white;
  border: none;
  border-radius: 20px;
  padding: 10px 20px;
  margin-top: 15px;
  cursor: pointer;
  font-weight: 600;
}

.calendar__retry-btn:hover {
  background: #388e3c;
}

/* ==========================================================================
   Responsive Design
   ========================================================================== */

/* Mobile Optimizations */
@media (max-width: 767px) {
  .custom-calendar {
    margin: 0;
    border-radius: 0;
    box-shadow: none;
    border-top: 1px solid #e0e0e0;
    border-bottom: 1px solid #e0e0e0;
  }

  .calendar__header {
    padding: 15px;
    flex-direction: column;
    text-align: center;
    gap: 10px;
  }

  .calendar__month-header {
    padding: 15px;
    flex-direction: column;
    text-align: center;
    gap: 8px;
  }

  .calendar__legend {
    justify-content: center;
  }

  .calendar__day {
    min-height: 44px; /* Touch-friendly size */
    font-size: 0.95em;
  }

  .calendar__day-names {
    font-size: 0.8em;
  }

  .calendar__day-name {
    padding: 8px 4px;
  }

  .calendar__selection {
    padding: 15px;
  }

  .calendar__selection-dates {
    flex-direction: column;
    gap: 10px;
    text-align: center;
  }

  .calendar__selection-details {
    flex-direction: column;
    gap: 15px;
  }

  .calendar__booking {
    padding: 15px;
  }

  .calendar__book-btn {
    width: 100%;
    padding: 15px 20px;
  }
}

/* Tablet Adjustments */
@media (min-width: 768px) and (max-width: 1023px) {
  .calendar__header {
    padding: 18px;
  }

  .calendar__day {
    min-height: 46px;
  }

  .calendar__month-header {
    padding: 18px;
  }
}

/* Large Desktop */
@media (min-width: 1200px) {
  .calendar__day {
    min-height: 52px;
  }

  .calendar__day-number {
    font-size: 1em;
  }
}

/* ==========================================================================
   High Contrast / Accessibility Improvements
   ========================================================================== */

@media (prefers-contrast: high) {
  .calendar__day--available {
    border: 1px solid #333;
  }

  .calendar__day--unavailable {
    background: #000;
    color: #fff;
  }

  .calendar__day--in-range {
    background: #000 !important;
    color: #fff !important;
  }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
  .calendar__day,
  .calendar__nav-btn,
  .calendar__book-btn,
  .calendar__clear-btn {
    transition: none;
  }

  .calendar__day:hover {
    transform: none;
  }

  .calendar__book-btn--active:hover {
    transform: none;
  }

  .calendar__spinner {
    animation: none;
    border-top-color: transparent;
  }
}

/* Focus Indicators for Keyboard Users */
@media (prefers-reduced-motion: no-preference) {
  .calendar__day:focus {
    animation: focus-pulse 2s infinite;
  }
}

@keyframes focus-pulse {
  0%, 100% { outline-color: #4caf50; }
  50% { outline-color: #66bb6a; }
}

/* Screen Reader Only Content */
.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;
}

/* ==========================================================================
   Print Styles
   ========================================================================== */

@media print {
  .custom-calendar {
    box-shadow: none;
    border: 1px solid #000;
  }

  .calendar__header {
    background: white !important;
    color: black !important;
    border-bottom: 1px solid #000;
  }

  .calendar__nav-btn,
  .calendar__booking,
  .calendar__clear-btn {
    display: none;
  }

  .calendar__day--available {
    background: white;
  }

  .calendar__day--unavailable {
    background: #ddd;
  }

  .calendar__day--range-start,
  .calendar__day--range-end,
  .calendar__day--in-range {
    background: #ccc !important;
    color: black !important;
  }
}