/* ===============================
   Lodge Date Range Picker styles
   =============================== */
.ldr {
  position: relative;
  max-width: 520px;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
}

/* Ensure calendar container starts at top on mobile */
@media (max-width: 640px) {
  .ldr {
    display: flex;
    flex-direction: column;
  }
  
  .ldr--inline {
    margin-top: 0;
  }
}

/* Responsive width mode - adapts to container */
.ldr--responsive {
  max-width: 100%;
  width: 100%;
}

.ldr__fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  align-items: end;
}

.ldr__field span {
  display: block;
  font-size: 12px;
  opacity: 0.8;
  margin: 0 0 6px;
}

.ldr__input {
  width: 100%;
  padding: 12px 12px;
  border: 1px solid rgba(0, 0, 0, 0.18);
  border-radius: 12px;
  background: #fff;
  cursor: pointer;
  font-size: 14px;
}

/* Inline mode - hide input fields and labels, keep meta and hidden fields */
.ldr--inline .ldr__field {
  display: none;
}

/* Show meta message above calendar in inline mode */
.ldr--inline .ldr__meta {
  display: block !important;
  margin-bottom: 16px;
  padding: 12px 0;
  font-size: 14px;
  font-weight: 500;
  border-bottom: 1px solid rgba(0, 0, 0, 0.1);
  grid-column: 1 / -1;
}

/* Adjust fields container in inline mode */
.ldr--inline .ldr__fields {
  margin-bottom: 0;
  padding-bottom: 0;
}

.ldr__input:focus {
  outline: none;
  border-color: rgba(0, 0, 0, 0.35);
  box-shadow: 0 0 0 4px rgba(0, 0, 0, 0.06);
}

.ldr__input:focus-visible {
  outline: 2px solid rgba(0, 0, 0, 0.5);
  outline-offset: 2px;
}

.ldr__meta {
  grid-column: 1 / -1;
  font-size: 13px;
  opacity: 0.85;
  min-height: 18px;
  padding-left: 2px;
}

.ldr__panel {
  position: absolute;
  left: 0;
  top: calc(100% + 10px);
  z-index: 9999;
  width: min(720px, calc(100vw - 24px));
  max-width: calc(100vw - 24px);
  border: 1px solid rgba(0, 0, 0, 0.16);
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.18);
  padding: 12px;
}

/* Inline mode - always visible, relative positioning for edge nav buttons */
.ldr--inline .ldr__panel {
  position: relative;
  margin-top: 20px;
  width: 100%;
  max-width: 100%;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* Mobile adjustments for inline mode */
@media (max-width: 640px) {
  .ldr--inline .ldr__panel {
    margin-top: 0;
    padding: 8px;
  }
  
  .ldr--inline .ldr__calwrap {
    padding: 4px;
    gap: 8px;
  }
  
  /* Ensure calendar starts at top of container on mobile */
  .ldr--inline {
    margin-top: 0;
    padding-top: 0;
  }
  
  .ldr--inline .ldr__meta {
    margin-bottom: 8px;
    padding: 8px 0;
    margin-top: 0;
  }
  
  /* Remove any top spacing from panel header on mobile */
  .ldr--inline .ldr__header {
    padding-top: 4px;
    margin-top: 0;
  }
}

/* Responsive width in inline mode */
.ldr--inline.ldr--responsive .ldr__panel {
  width: 100%;
}

/* Responsive width in popup mode */
.ldr--responsive .ldr__panel {
  width: min(720px, 100%);
  max-width: 100%;
}

/* Reposition panel on small screens or when near viewport edges */
@media (max-width: 720px) {
  /* Only apply to popup mode, not inline */
  .ldr--popup .ldr__panel {
    left: 50%;
    transform: translateX(-50%);
    width: calc(100vw - 24px);
    max-width: calc(100vw - 24px);
  }
}

/* Adjust panel if it would overflow right edge */
.ldr__panel[data-position="right"] {
  left: auto;
  right: 0;
}

@media (max-width: 720px) {
  .ldr__panel[data-position="right"] {
    left: 50%;
    right: auto;
    transform: translateX(-50%);
  }
}

/* Adjust panel if it would overflow bottom edge */
.ldr__panel[data-position="top"] {
  top: auto;
  bottom: calc(100% + 10px);
}

/* Adjust panel if it would overflow both right and bottom */
.ldr__panel[data-position="right-top"] {
  left: auto;
  right: 0;
  top: auto;
  bottom: calc(100% + 10px);
}

@media (max-width: 720px) {
  .ldr__panel[data-position="right-top"] {
    left: 50%;
    right: auto;
    transform: translateX(-50%);
  }
}

.ldr__header {
  display: none; /* Hide header - using per-month titles instead */
}

.ldr__title {
  display: none; /* Hide main title - using per-month titles instead */
}

.ldr__nav {
  display: none; /* Hide old navigation - using per-month navigation instead */
}

.ldr__calwrap {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  padding: 6px;
}

/* Flexible month layout for inline mode */
.ldr--inline .ldr__calwrap {
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

/* Support 1, 2, or 3 months based on data attribute */
.ldr--inline .ldr__calwrap[data-months="1"] {
  grid-template-columns: 1fr;
}

.ldr--inline .ldr__calwrap[data-months="2"] {
  grid-template-columns: 1fr 1fr;
}

.ldr--inline .ldr__calwrap[data-months="3"] {
  grid-template-columns: repeat(3, 1fr);
}

/* Responsive calendar layout */
@media (max-width: 640px) {
  .ldr__calwrap {
    grid-template-columns: 1fr;
  }
  
  .ldr--inline .ldr__calwrap[data-months="3"],
  .ldr--inline .ldr__calwrap[data-months="2"] {
    grid-template-columns: 1fr;
  }
}

/* Responsive width mode - adapt calendar to available space */
.ldr--responsive .ldr__calwrap {
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

@media (max-width: 640px) {
  .ldr--responsive .ldr__calwrap {
    grid-template-columns: 1fr;
  }
}

/* Medium screens - show 2 months max */
@media (min-width: 641px) and (max-width: 900px) {
  .ldr--inline .ldr__calwrap[data-months="3"] {
    grid-template-columns: 1fr 1fr;
  }
}

.ldr__month {
  border: none;
  padding: 10px;
}

.ldr__monthTitle {
  font-size: 13px;
  font-weight: 650;
  opacity: 0.85;
  text-align: center;
  margin: 0 0 8px;
}

/* Navigation buttons at widget edges - aligned with month titles */
.ldr__edgeNav {
  position: absolute;
  top: 12px; /* Align with month titles (matches panel padding) */
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 1px solid rgba(0, 0, 0, 0.14);
  background: #fff;
  cursor: pointer;
  font-size: 22px;
  font-weight: 700; /* Bolder */
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  color: rgba(0, 0, 0, 0.8);
  z-index: 10;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.ldr__edgeNav:hover:not(:disabled) {
  background: rgba(0, 0, 0, 0.05);
  border-color: rgba(0, 0, 0, 0.2);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15);
}

.ldr__edgeNav:focus-visible {
  outline: 2px solid rgba(0, 0, 0, 0.5);
  outline-offset: 2px;
}

.ldr__edgeNav:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.ldr__edgeNav--prev {
  left: 8px;
}

.ldr__edgeNav--next {
  right: 8px;
}

.ldr__dow {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  margin-bottom: 6px;
}

.ldr__dow div {
  font-size: 11px;
  opacity: 0.55;
  text-align: center;
  padding: 4px 0;
}

.ldr__grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  /* Allow grid to wrap naturally without requiring 7 columns */
  grid-auto-flow: row;
}

.ldr__day {
  height: 38px;
  border-radius: 12px;
  border: 1px solid transparent;
  background: transparent;
  cursor: pointer;
  font-size: 13px;
  font-weight: 700; /* Bold day numbers */
  position: relative;
}

.ldr__day:hover:not([disabled]) {
  background: rgba(0, 0, 0, 0.04);
}

.ldr__day:focus-visible:not([disabled]) {
  outline: 2px solid rgba(0, 0, 0, 0.5);
  outline-offset: 2px;
}

.ldr__day[disabled] {
  cursor: not-allowed;
  opacity: 0.35;
}

.ldr__day--mute {
  opacity: 0.35;
}

.ldr__day--today {
  border-color: rgba(0, 0, 0, 0.18);
}

/* Ribbon effect for selected date range - continuous highlight */
.ldr__day--start {
  background: rgba(0, 0, 0, 0.85);
  color: #fff;
  border-radius: 12px 0 0 12px;
  margin-right: -2px; /* Remove gap between days */
  border: 1px solid rgba(0, 0, 0, 0.85); /* Match background */
  z-index: 1;
}

.ldr__day--end {
  background: rgba(0, 0, 0, 0.85);
  color: #fff;
  border-radius: 0 12px 12px 0;
  margin-left: -2px; /* Remove gap between days */
  border: 1px solid rgba(0, 0, 0, 0.85); /* Match background */
  z-index: 1;
}

.ldr__day--inrange {
  background: #eee; /* Much lighter middle section */
  color: #333; /* Dark text for light background */
  border-radius: 0;
  margin-left: -2px; /* Remove gap between days */
  margin-right: -2px;
  border: 1px solid #eee; /* Match background */
  z-index: 0;
}

/* Single day selection (start = end) */
.ldr__day--start.ldr__day--end {
  border-radius: 12px;
  margin: 0; /* Reset margins for single day */
  border: 1px solid rgba(0, 0, 0, 0.85);
}

/* Tooltip styling */
.ldr__day--tooltip {
  position: relative;
}

.ldr__day--tooltip::before {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.9);
  color: #fff;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 12px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s ease 0.3s, transform 0.15s ease 0.3s;
  transform: translateX(-50%) translateY(-4px);
  z-index: 10000;
  font-weight: 500;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  max-width: 200px;
  white-space: normal;
  text-align: center;
  line-height: 1.4;
}

.ldr__day--tooltip::after {
  content: "";
  position: absolute;
  bottom: calc(100% + 2px);
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: rgba(0, 0, 0, 0.9);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s ease 0.3s;
  z-index: 10001;
}

.ldr__day--tooltip:hover:not([disabled])::before,
.ldr__day--tooltip:hover:not([disabled])::after {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
  transition-delay: 0s;
}

.ldr__day--tooltip:hover:not([disabled])::after {
  transform: translateX(-50%);
  transition-delay: 0s;
}

/* Show tooltip on focus for keyboard navigation */
.ldr__day--tooltip:focus-visible:not([disabled])::before,
.ldr__day--tooltip:focus-visible:not([disabled])::after {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
  transition-delay: 0s;
}

.ldr__day--tooltip:focus-visible:not([disabled])::after {
  transform: translateX(-50%);
  transition-delay: 0s;
}

/* Adjust tooltip position for dates near edges to prevent overflow */
.ldr__day--tooltip:nth-child(7n)::before,
.ldr__day--tooltip:nth-child(7n-1)::before {
  left: auto;
  right: 0;
  transform: translateX(0) translateY(-4px);
}

.ldr__day--tooltip:nth-child(7n):hover:not([disabled])::before,
.ldr__day--tooltip:nth-child(7n-1):hover:not([disabled])::before,
.ldr__day--tooltip:nth-child(7n):focus-visible:not([disabled])::before,
.ldr__day--tooltip:nth-child(7n-1):focus-visible:not([disabled])::before {
  transform: translateX(0) translateY(0);
}

.ldr__day--tooltip:nth-child(7n)::after,
.ldr__day--tooltip:nth-child(7n-1)::after {
  left: auto;
  right: 10px;
  transform: translateX(0);
}

.ldr__day--tooltip:nth-child(7n+1)::before,
.ldr__day--tooltip:nth-child(7n+2)::before {
  left: 0;
  transform: translateX(0) translateY(-4px);
}

.ldr__day--tooltip:nth-child(7n+1):hover:not([disabled])::before,
.ldr__day--tooltip:nth-child(7n+2):hover:not([disabled])::before,
.ldr__day--tooltip:nth-child(7n+1):focus-visible:not([disabled])::before,
.ldr__day--tooltip:nth-child(7n+2):focus-visible:not([disabled])::before {
  transform: translateX(0) translateY(0);
}

.ldr__day--tooltip:nth-child(7n+1)::after,
.ldr__day--tooltip:nth-child(7n+2)::after {
  left: 10px;
  transform: translateX(0);
}

.ldr__badge {
  position: absolute;
  right: 6px;
  bottom: 5px;
  font-size: 9px;
  opacity: 0.75;
}

/* Blocked label badge */
.ldr__badge--blocked {
  left: 6px;
  right: auto;
  bottom: 6px;
  padding: 2px 6px;
  border-radius: 999px;
  border: 1px solid rgba(0, 0, 0, 0.18);
  background: rgba(0, 0, 0, 0.06);
  font-size: 10px;
  line-height: 1;
  max-width: calc(100% - 12px);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  opacity: 0.9;
}

.ldr__actions {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 6px 4px;
}

.ldr__btn {
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(0, 0, 0, 0.14);
  background: rgba(0, 0, 0, 0.88);
  color: #fff;
  cursor: pointer;
  font-size: 13px;
  font-weight: 650;
}

.ldr__btn:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.8);
  outline-offset: 2px;
}

.ldr__btn--ghost {
  background: #fff;
  color: #111;
}

.ldr__btn--ghost:focus-visible {
  outline: 2px solid rgba(0, 0, 0, 0.5);
  outline-offset: 2px;
}

/* Hide Done button in inline mode */
.ldr--inline .ldr__btn[data-ldr-close] {
  display: none;
}
