/* Base styles */
body,
html {
  height: auto;
  min-height: 100%;
}

/* Calendar Grid Layout */
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 1px;
  background: #ddd;
}

.month-container {
  margin-bottom: 2rem;
}

/* Calendar Day Cells */
.calendar-day {
  position: relative;
  overflow: hidden;
  min-height: 100px;
  background-color: white;
  transition: background-color 0.2s ease;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  cursor: default;
}

.day-number {
  position: absolute;
  top: 2px;
  right: 4px;
  padding: 0;
  font-size: 1.2rem;
  font-weight: bold;
  z-index: 2; /* Ensure day numbers are always on top */
}


.weekday-label {
  text-align: center;
  padding: 0.5rem;
  background: #e5e7eb;
  border: none;
  font-weight: bold;
}

/* State Styles */
.today-highlight {
  background-color: rgba(219, 234, 254);
}

.drag-highlight {
  background-color: rgb(224 231 255);
}

.selection-count {
  position: absolute;
  bottom: 0;
  left: 0;
  padding: 0.5rem;
  font-size: 1.1rem;
  font-weight: bold;
  color: rgb(136, 96, 156);
}

/* Range Labels */
.day-labels {
  position: absolute;
  top: 30px;
  left: 4px;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 2px;
  pointer-events: none;
  max-height: calc(100% - 35px); /* Leave space for day number */
  overflow-y: auto; /* Allow scrolling if many labels */
}

.range-label {
  font-size: 1.1rem;
  font-weight: bold;
  color: rgb(95, 95, 95);
  padding: 3px 6px;
  border-radius: 3px;
  white-space: normal; /* Allow text to wrap */
  word-break: break-word; /* Break long words if needed */
  overflow: hidden;
  pointer-events: auto;
  position: relative;
  padding-right: 16px; /* Space for delete button */
  /*opacity: 0.8; /* Make the label slightly lighter */
  max-width: 100%; /* Ensure it stays within the cell */
  line-height: 1.2; /* Better spacing for wrapped text */
}

.delete-range {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: #666;
  cursor: pointer;
  font-size: 0.8rem;
  line-height: 1;
  padding: 0 2px;
}

.delete-range:hover {
  color: #000;
}

/* Small Month Modifications */
.small-month {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
}

.small-month .calendar-day {
  min-height: 50px;
  position: relative;
  overflow: visible;
}

.small-month .day-number {
  position: absolute;
  top: 2px;
  right: 4px;
  padding: 0 2px;
  border-radius: 2px;
  z-index: 2;
  font-size: 0.85rem;
}

.small-month .weekday-label {
  font-size: 0.75rem;
}

.small-month .day-labels {
  display: none;
}

/* Modal Styles */
.label-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.label-modal-content {
  background: white;
  padding: 20px;
  border-radius: 8px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  width: 300px;
}

.range-label-input {
  width: 100%;
  padding: 8px;
  margin: 10px 0;
  border: 1px solid #ddd;
  border-radius: 4px;
}

/* Button Styles */
.modal-buttons {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 15px;
}

.primary-button,
.secondary-button {
  padding: 8px 16px;
  border-radius: 4px;
  border: none;
  cursor: pointer;
}

.primary-button {
  background: #4f46e5;
  color: white;
}

.secondary-button {
  background: #e5e7eb;
  color: #374151;
}

.primary-button:hover {
  background: #4338ca;
}

.secondary-button:hover {
  background: #d1d5db;
}

#clearRangesButton {
  margin-right: 8px;
}

.range-start, .range-end {
  position: relative;
}

.range-continues-left::before {
  content: '';
  position: absolute;
  left: -1px;
  top: 50%;
  transform: translateY(-50%);
  width: 0;
  height: 0;
  border-top: 6px solid transparent;
  border-bottom: 6px solid transparent;
  border-right: 8px solid #666;
  opacity: 0.6;
}

.range-continues-right::after {
  content: '';
  position: absolute;
  right: -1px;
  top: 50%;
  transform: translateY(-50%);
  width: 0;
  height: 0;
  border-top: 6px solid transparent;
  border-bottom: 6px solid transparent;
  border-left: 8px solid #666;
  opacity: 0.6;
}

.range-start::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  border-top: 8px solid #666;
  border-right: 8px solid transparent;
  opacity: 0.6;
}

.range-end::after {
  content: '';
  position: absolute;
  bottom: 0;
  right: 0;
  border-bottom: 8px solid #666;
  border-left: 8px solid transparent;
  opacity: 0.6;
}

.date-controls {
  margin: 15px 0;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 20px;
}

.dates-container {
  flex: 1;
}

.date-row {
  display: flex;
  align-items: center;
  margin: 4px 0;
  gap: 4px; 
}

.date-label {
  width: 45px;
  font-weight: bold;
}

.date-value {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.duration-control {
  display: flex;
  align-items: center;
  gap: 8px;
  align-self: center;
}

.duration-input {
  width: 60px;
  padding: 4px;
  border: 1px solid #ddd;
  border-radius: 4px;
  text-align: center;
}

.label-modal-content {
  width: 400px;
}

/* Small Month Range Styles */
.small-month .range-start::before,
.small-month .range-end::after {
  border-width: 4px;
}

.small-month .range-continues-left::before,
.small-month .range-continues-right::after {
  border-width: 3px 4px;
}

.small-month-label {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 8px;
  padding: 2px 4px;
  border-radius: 3px;
  color: rgb(95, 95, 95);
  white-space: nowrap;
  text-overflow: ellipsis;
  max-width: 90%;
  text-align: center;
  opacity: 0.9;
  pointer-events: none;
}

.flex.justify-end.items-center.mb-4 {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.flex.gap-2:not(:first-child) {
  margin-left: 16px;
}

button {
  cursor: pointer;
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Add to your style.css */
#clearBtn {
  transition: color 0.2s ease;
}

#clearBtn:hover {
  color: rgb(185, 28, 28); /* Darker red on hover */
}

/* Optional: Add button focus styles */
button:focus {
  outline: 2px solid #4f46e5;
  outline-offset: 2px;
}

/* For better modal animation */
.fixed {
  animation: fadeIn 0.2s ease;
}

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