/**
 * Luxury Booking Widget Styles
 * Version: 1.2.4 (mobile picker interaction fixes)
 */

/* CSS Variables - Theme color is injected inline */
:root {
  --lbw-white: #FFFFFF;
  --lbw-deep-charcoal: #2C2A29;
  --lbw-charcoal-medium: #4A4947;
  --lbw-light-gray: #F4F4F4;
  --lbw-border-gray: #E0E0E0;
  --lbw-text-gray: #5A5856;
  --lbw-red-primary: var(--lbw-primary-color, #8B0F05);
  --lbw-red-hover: color-mix(in srgb, var(--lbw-red-primary) 85%, black);
  --lbw-sticky-top: 56px;
  --lbw-mobile-picker-z-backdrop: 999950;
  --lbw-mobile-picker-z-panel: 999960;
  --lbw-mobile-picker-z-controls: 999970;
}

/* Widget Container */
.booking-widget-sticky {
  position: relative;
  display: block;
  width: auto;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", sans-serif;
  text-align: right;
}

/* Toggle Button */
.sticky-toggle-btn {
  display: inline-block;
  height: 36px;
  padding: 0 1.25rem;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--lbw-white);
  background-color: var(--lbw-red-primary);
  border: none;
  border-radius: 4px;
  cursor: pointer;
  white-space: nowrap;
  line-height: 1;
  transition:
    box-shadow 0.25s ease,
    opacity 0.25s ease,
    transform 0.12s ease,
    background-color 0.25s ease;
  position: relative;
  overflow: hidden;
}

.sticky-toggle-btn .btn-text {
  display: inline-block;
  opacity: 1;
  transform: translateY(0) scale(1);
  transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1),
              transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Collapsed state - text animates in from below with bounce */
.booking-widget-sticky.collapsed .sticky-toggle-btn .btn-text {
  animation: lbwSlideUpBounce 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes lbwSlideUpBounce {
  0% {
    opacity: 0;
    transform: translateY(10px) scale(0.95);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.sticky-toggle-btn .btn-icon {
  position: absolute;
  width: 20px;
  height: 20px;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0) rotate(-180deg);
  opacity: 0;
  transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1),
              transform 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.sticky-toggle-btn .btn-icon circle {
  stroke-dasharray: 63;
  stroke-dashoffset: 63;
  transition: stroke-dashoffset 0.4s cubic-bezier(0.4, 0, 0.2, 1) 0.1s;
}

.sticky-toggle-btn .btn-icon path {
  stroke-dasharray: 17;
  stroke-dashoffset: 17;
  transition: stroke-dashoffset 0.3s cubic-bezier(0.4, 0, 0.2, 1) 0.2s;
}

.sticky-toggle-btn:hover {
  opacity: 0.95;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.sticky-toggle-btn:active {
  transform: scale(0.97);
}

.booking-widget-sticky.expanded .sticky-toggle-btn {
  background-color: transparent;
  color: var(--lbw-white);
  box-shadow: none;
}

.booking-widget-sticky.expanded .sticky-toggle-btn .btn-text {
  opacity: 0;
  transform: translateY(-8px) scale(0.9);
}

.booking-widget-sticky.expanded .sticky-toggle-btn .btn-icon {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1) rotate(0deg);
  stroke: var(--lbw-red-primary);
}

.booking-widget-sticky.expanded .sticky-toggle-btn .btn-icon circle {
  stroke-dashoffset: 0;
}

.booking-widget-sticky.expanded .sticky-toggle-btn .btn-icon path {
  stroke-dashoffset: 0;
}

.booking-widget-sticky.expanded .sticky-toggle-btn:hover {
  background-color: transparent;
}

.booking-widget-sticky.expanded .sticky-toggle-btn:hover .btn-icon {
  transform: translate(-50%, -50%) scale(1.15) rotate(90deg);
}

/* Drawer Container (animated open/close) */
.sticky-form-wrapper {
  position: absolute;
  top: calc(100% + 0.75rem);
  right: 0;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px);
  pointer-events: none;
  transition:
    opacity 0.25s ease,
    transform 0.25s ease,
    visibility 0.25s ease;
}

.booking-widget-sticky.expanded .sticky-form-wrapper {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  pointer-events: auto;
}

/* Card Container */
.sticky-form-wrapper .widget-box {
  width: min(1000px, calc(100vw - 32px));
  padding: 1.25rem 1.5rem 1.5rem 1.5rem;
  background: #f9f9f9;
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
  box-sizing: border-box;
}

/* FORM LAYOUT – DESKTOP & TABLET (default single row) */
.booking-form {
  display: grid;
  grid-template-columns: 2fr 0.9fr 0.9fr 1.1fr auto auto;
  column-gap: 0.75rem;
  row-gap: 0.5rem;
  align-items: end;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.form-label {
  font-size: 0.65rem;
  font-weight: 400;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #333333;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.form-label svg {
  display: none;
}

.form-input {
  width: 100%;
  height: 36px;
  padding: 0 0.75rem;
  font-size: 0.875rem;
  border: 1px solid var(--lbw-border-gray);
  border-radius: 4px;
  background: var(--lbw-white);
  color: var(--lbw-deep-charcoal);
  outline: none;
  transition:
    border-color 0.2s ease,
    box-shadow 0.2s ease,
    background-color 0.2s ease;
  line-height: 1.4;
}

.form-input:read-only {
  cursor: pointer;
}

.form-input:hover {
  border-color: #333333;
}

.form-input:focus {
  border-color: var(--lbw-red-primary);
  box-shadow: 0 0 0 2px rgba(139, 15, 5, 0.15);
  background-color: #fff;
}

.date-range-picker-wrapper {
  position: relative;
}

/* Number Pickers */
.number-picker {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 36px;
  padding: 0 0.5rem;
  border: 1px solid var(--lbw-border-gray);
  border-radius: 4px;
  background: var(--lbw-white);
  transition: border-color 0.2s ease;
}

.number-picker:hover {
  border-color: var(--lbw-charcoal-medium);
}

.adults-group,
.children-group {
  max-width: 110px;
}

.picker-control {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 1px solid var(--lbw-border-gray);
  background: var(--lbw-white);
  color: var(--lbw-charcoal-medium);
  font-size: 0.875rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.2s ease;
}

.picker-control:hover:not(:disabled) {
  border-color: var(--lbw-charcoal-medium);
  background: var(--lbw-light-gray);
}

.picker-control:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  background: var(--lbw-light-gray);
}

.adults-val,
.children-val {
  font-size: 0.875rem;
  min-width: 20px;
  text-align: center;
  font-weight: 500;
  color: var(--lbw-deep-charcoal);
}

/* Buttons */
.form-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  justify-content: flex-end;
  white-space: nowrap;
}

.btn-primary,
.btn-casino {
  height: 36px;
  padding: 0 1.25rem;
  font-size: 0.8125rem;
  font-weight: 600;
  border-radius: 4px;
  border: 1px solid transparent;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  transition:
    background-color 0.2s ease,
    border-color 0.2s ease,
    color 0.2s ease,
    transform 0.1s ease,
    box-shadow 0.2s ease;
}

.btn-primary {
  background: var(--lbw-red-primary);
  color: var(--lbw-white);
  border-color: var(--lbw-red-primary);
}

.btn-primary:hover {
  background: var(--lbw-red-hover);
  border-color: var(--lbw-red-hover);
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
}

.btn-casino {
  background: var(--lbw-white);
  color: var(--lbw-red-primary);
  border-color: var(--lbw-red-primary);
}

.btn-casino:hover {
  background: var(--lbw-red-primary);
  color: var(--lbw-white);
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
}

/* Desktop Date Picker Popover */
.date-picker-desktop {
  position: absolute;
  background: var(--lbw-white);
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
  padding: 1.5rem;
  z-index: 1100;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px);
  transition: opacity 0.25s ease, visibility 0.25s ease, transform 0.25s ease;
  min-width: 640px;
  top: calc(100% + 0.5rem);
  left: 0;
  pointer-events: none;
}

.date-picker-desktop.open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  pointer-events: all;
}

.date-picker-desktop.open.open-above {
  top: auto;
  bottom: calc(100% + 0.5rem);
}

.calendars-container {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 2rem;
  margin-bottom: 1.5rem;
}

.calendar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.calendar-month-title {
  font-size: 1rem;
  font-weight: 600;
  flex: 1;
  text-align: center;
}

.desktop-nav-prev,
.desktop-nav-next {
  width: 32px;
  height: 32px;
  background: none;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 1.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.desktop-nav-prev:hover:not(:disabled),
.desktop-nav-next:hover:not(:disabled) {
  background: var(--lbw-light-gray);
}

.desktop-nav-prev:disabled,
.desktop-nav-next:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.calendar-weekdays,
.calendar-days {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 0.25rem;
}

.calendar-weekday {
  text-align: center;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--lbw-charcoal-medium);
  padding: 0.5rem 0;
}

.calendar-day {
  aspect-ratio: 1;
  border: none;
  background: none;
  border-radius: 8px;
  font-size: 0.9375rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.calendar-day:hover:not(:disabled):not(.in-range):not(.range-start):not(.range-end) {
  background: var(--lbw-light-gray);
}

.calendar-day:disabled {
  color: #c0c0c0;
  opacity: 0.5;
  cursor: not-allowed;
}

.calendar-day.other-month {
  color: #c0c0c0;
}

.calendar-day.today {
  background: color-mix(in srgb, var(--lbw-red-primary) 10%, transparent);
}

.calendar-day.range-start,
.calendar-day.range-end {
  background: var(--lbw-red-primary);
  color: var(--lbw-white);
  font-weight: 600;
}

.calendar-day.in-range {
  background: var(--lbw-red-primary);
  color: var(--lbw-white);
  border-radius: 0;
}

.calendar-day.range-start {
  border-radius: 8px 0 0 8px;
}

.calendar-day.range-end {
  border-radius: 0 8px 8px 0;
}

.calendar-day.range-start.range-end {
  border-radius: 8px;
}

.picker-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  padding-top: 1rem;
  border-top: 1px solid var(--lbw-border-gray);
}

.picker-btn {
  padding: 0.625rem 1.5rem;
  border-radius: 8px;
  font-size: 0.9375rem;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid var(--lbw-border-gray);
  background: var(--lbw-white);
  color: var(--lbw-deep-charcoal);
  transition: all 0.2s ease;
}

.picker-btn:hover:not(:disabled) {
  background: var(--lbw-light-gray);
}

.picker-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  background: var(--lbw-light-gray);
}

.picker-btn.primary {
  background: var(--lbw-red-primary);
  color: var(--lbw-white);
  border-color: var(--lbw-red-primary);
}

.picker-btn.primary:hover:not(:disabled) {
  background: var(--lbw-red-hover);
}

.picker-btn.primary:disabled {
  background: var(--lbw-border-gray);
  border-color: var(--lbw-border-gray);
  opacity: 0.5;
}

/* MOBILE FULLSCREEN DATE PICKER OVERLAY */
.date-picker-mobile-backdrop {
  display: block;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: var(--lbw-mobile-picker-z-backdrop);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}

.date-picker-mobile-backdrop.open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.date-picker-mobile {
  display: flex;
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  background: var(--lbw-white);
  z-index: var(--lbw-mobile-picker-z-panel, 999960);
  flex-direction: column;
  transform: translateY(100%);
  transition: transform 0.25s ease;
  overflow: hidden;
  pointer-events: none;
}

.date-picker-mobile.open {
  transform: translateY(0);
  pointer-events: auto;
}

.picker-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  width: 44px;
  height: 44px;
  background: var(--lbw-white);
  border: 1px solid var(--lbw-border-gray);
  border-radius: 50%;
  font-size: 1.75rem;
  line-height: 1;
  cursor: pointer;
  z-index: var(--lbw-mobile-picker-z-controls, 999970);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.date-picker-mobile .calendars-container {
  flex: 1;
  overflow-y: auto;
  padding: 4.5rem 1.25rem 6.5rem;
  display: flex;
  flex-direction: column;
  gap: 2rem;
  min-height: 0;
}

.date-picker-mobile .calendar {
  width: 100%;
  max-width: 100%;
}

.date-picker-mobile .calendar-nav {
  display: none;
}

.date-picker-mobile .calendar-header {
  justify-content: center;
}

.date-picker-mobile .calendar-day {
  min-height: 44px;
  font-size: 1rem;
}

.date-picker-mobile .calendar-month-title {
  font-size: 1.125rem;
  font-weight: 600;
}

.date-picker-mobile .calendar-weekday {
  font-size: 0.875rem;
  padding: 0.75rem 0;
}

.date-picker-mobile .picker-footer {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  background: var(--lbw-white);
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--lbw-border-gray);
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.1);
  z-index: var(--lbw-mobile-picker-z-controls, 999970);
}

.picker-nav {
  display: flex;
  gap: 0.75rem;
}

.nav-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--lbw-charcoal-medium);
  background: var(--lbw-white);
  font-size: 1.25rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.nav-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
  background: var(--lbw-light-gray);
}

.picker-actions {
  display: flex;
  gap: 0.75rem;
}

/* Loading Spinner on Buttons */
.loading {
  position: relative;
  color: transparent !important;
}

.loading::after {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  top: 50%;
  left: 50%;
  margin: -9px 0 0 -9px;
  border: 2px solid var(--lbw-white);
  border-radius: 50%;
  border-top-color: transparent;
  animation: lbwSpin 0.6s linear infinite;
}

@keyframes lbwSpin {
  to {
    transform: rotate(360deg);
  }
}

/* ----------------------------------------------------------
 * TABLET + MOBILE: full-width drawer using fixed positioning
 * -------------------------------------------------------- */
@media (max-width: 1030px) {
  .sticky-form-wrapper {
    position: fixed;
    left: 0;
    right: 0;
    top: var(--lbw-sticky-top);
    margin: 0;
    padding: 0;
  }

  .sticky-form-wrapper .widget-box {
    width: 100%;
    max-width: 100%;
    margin: 0 auto;
    border-radius: 0;
    padding: 1.25rem 1rem 1.25rem 1rem;
  }
}

/* MOBILE LAYOUT – 3 ROWS + hide desktop picker */
@media (max-width: 640px) {
  .sticky-form-wrapper .booking-form {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    grid-template-rows: auto auto auto;
    gap: 1rem;
  }

  /* Row 1: dates full width */
  .sticky-form-wrapper .booking-form > .date-range-picker-wrapper {
    grid-row: 1;
    grid-column: 1 / -1;
  }

  /* Row 2: adults / children / promo */
  .sticky-form-wrapper .booking-form > .adults-group {
    grid-row: 2;
    grid-column: 1;
  }

  .sticky-form-wrapper .booking-form > .children-group {
    grid-row: 2;
    grid-column: 2;
  }

  .sticky-form-wrapper .booking-form > .form-group:nth-of-type(4) {
    grid-row: 2;
    grid-column: 3;
  }

  /* Row 3: buttons full width */
  .sticky-form-wrapper .booking-form > .form-actions {
    grid-row: 3;
    grid-column: 1 / -1;
    width: 100%;
    justify-content: stretch;
  }

  .sticky-form-wrapper .btn-primary,
  .sticky-form-wrapper .btn-casino {
    flex: 1;
  }

  /* On mobile we only want the fullscreen picker, hide desktop popover */
  .date-picker-desktop {
    display: none !important;
  }
}

@media (min-width: 641px) {
  .date-picker-mobile,
  .date-picker-mobile-backdrop,
  .picker-close {
    display: none !important;
  }
}

/* ----------------------------------------------------------
 * HEADER POSITIONING (Divi / site header usage)
 * Positions the toggle button itself inside #main-header.
 * -------------------------------------------------------- */

/* Ensure header can be the positioning context */
#main-header {
  position: relative;
}

/* Default / Desktop (≥ 1076px): button on right side of header */
#main-header #lbwWidget {
  position: absolute;
  top: 22px;
  right: 40px;
  margin: 0;
  z-index: 1200;
}

/* Tablet (1075px – 981px): keep right side but pull in slightly */
@media (max-width: 1075px) and (min-width: 981px) {
  #main-header #lbwWidget {
    top: 22px;
    right: 16px;
  }
}

/* Mobile (≤ 980px): keep button inside the header bar on the left */
@media (max-width: 980px) {
  #main-header #lbwWidget {
    position: absolute;
    top: 10px;   /* move up into the white header bar */
    left: 16px;  /* left edge spacing */
    right: auto;
    margin: 0;
  }
}


/* ----------------------------------------------------------
 * Additional small-screen refinements
 * -------------------------------------------------------- */

/* Very small screens (< 360px) - prevent overflow and cramping */
@media (max-width: 359px) {
  .sticky-toggle-btn {
    font-size: 0.75rem;
    padding: 0 1rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
  }

  .sticky-form-wrapper .widget-box {
    padding: 1rem;
  }

  .form-input,
  .picker-control {
    font-size: 0.8125rem;
  }
}

/* Landscape orientation on mobile - adjust mobile picker to prevent cutoff */
@media (max-width: 979px) and (orientation: landscape) {
  .date-picker-mobile .calendars-container {
    padding: 3rem 1rem 6rem;
  }

  .date-picker-mobile .calendar-day {
    min-height: 36px;
    font-size: 0.875rem;
  }
}

/* Very large screens (> 1400px) - ensure widget doesn't disappear off screen */
@media (min-width: 1400px) {
  .sticky-form-wrapper .widget-box {
    max-width: 1200px;
  }
}
