/**
 * rsrvbb Booking Form Styles
 * Version 2.0 - Modern, responsive design
 */

/* =============================================================================
   Form Container
   ========================================================================== */

.rsrvbb-form-container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0;
}

/* =============================================================================
   Booking Form
   ========================================================================== */

.rsrvbb-booking-form {
  background: transparent;
  padding: 0;
  margin: 0 0 30px 0;
}

.rsrvbb-form-row {
  display: flex;
  flex-wrap: wrap;
  gap: 15px;
  align-items: flex-start; /* Changed to flex-start for proper label alignment */
}

.rsrvbb-form-field {
  flex: 1 1 auto;
  min-width: 150px;
  display: flex;
  flex-direction: column;
  justify-content: flex-start; /* Ensures labels align at top */
}

.rsrvbb-form-field label {
  display: block;
  margin-bottom: 6px;
  font-size: 14px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.85);
  text-transform: none;
  min-height: 20px; /* Ensures consistent label height */
}

.rsrvbb-light-form .rsrvbb-form-field label {
  color: #333;
}

/* =============================================================================
   Form Inputs
   ========================================================================== */

.rsrvbb-datepicker,
.rsrvbb-select {
  width: 100%;
  height: 48px;
  padding: 12px 16px;
  font-size: 15px;
  line-height: 1.5;
  color: rgba(255, 255, 255, 0.9);
  background-color: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 4px;
  transition: all 0.2s ease;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
}

.rsrvbb-light-form .rsrvbb-datepicker,
.rsrvbb-light-form .rsrvbb-select {
  color: #333;
  background-color: #fff;
  border-color: #ddd;
}

.rsrvbb-datepicker:focus,
.rsrvbb-select:focus {
  outline: none;
  border-color: rgba(255, 255, 255, 0.5);
  background-color: rgba(255, 255, 255, 0.15);
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.1);
}

.rsrvbb-light-form .rsrvbb-datepicker:focus,
.rsrvbb-light-form .rsrvbb-select:focus {
  border-color: #4a90e2;
  background-color: #fff;
  box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.1);
}

.rsrvbb-datepicker::placeholder {
  color: rgba(255, 255, 255, 0.5);
}

.rsrvbb-light-form .rsrvbb-datepicker::placeholder {
  color: #999;
}

/* Custom Select Arrow */
.rsrvbb-select {
  background-image: url('data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%23FFFFFF%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.5-12.8z%22%2F%3E%3C%2Fsvg%3E');
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 12px;
  padding-right: 36px;
}

.rsrvbb-light-form .rsrvbb-select {
  background-image: url('data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%23333333%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.5-12.8z%22%2F%3E%3C%2Fsvg%3E');
}

/* =============================================================================
   Submit Button
   ========================================================================== */

.rsrvbb-form-submit {
  flex: 0 0 auto;
  min-width: 180px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end; /* Push button to bottom */
}

/* Add invisible label spacer to match other fields */
.rsrvbb-form-submit::before {
  content: '\00a0'; /* Non-breaking space */
  display: block;
  min-height: 26px; /* Height of label + margin */
  margin-bottom: 0;
}

.rsrvbb-submit-btn {
  width: 100%;
  height: 48px;
  padding: 12px 24px;
  font-size: 15px;
  font-weight: 600;
  color: #fff;
  background-color: #4a90e2;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s ease;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.rsrvbb-submit-btn:hover {
  background-color: #357abd;
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.rsrvbb-submit-btn:active {
  transform: translateY(0);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.rsrvbb-submit-btn:disabled {
  background-color: #999;
  cursor: not-allowed;
  transform: none;
}

.rsrvbb-btn-loading {
  display: none;
}

/* =============================================================================
   Validation Errors
   ========================================================================== */

.rsrvbb-datepicker.error,
.rsrvbb-select.error {
  border-color: #e74c3c;
  background-color: rgba(231, 76, 60, 0.1);
}

label.error {
  display: block;
  margin-top: 4px;
  font-size: 13px;
  color: #e74c3c;
  font-weight: 400;
}

.rsrvbb-light-form label.error {
  color: #e74c3c;
}

/* =============================================================================
   Results Container & Iframe
   ========================================================================== */

.rsrvbb-results-container {
  width: 100%;
  margin-top: 30px;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
  background: #fff;
}

.rsrvbb-results-header {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  padding: 8px 16px;
  background: transparent;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

.rsrvbb-results-title {
  display: none; /* Hide title to reduce redundancy */
}

.rsrvbb-open-tab-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  font-size: 12px;
  font-weight: 500;
  color: #666;
  text-decoration: none;
  border-radius: 3px;
  transition: all 0.2s ease;
}

.rsrvbb-open-tab-link:hover {
  background-color: rgba(74, 144, 226, 0.1);
  color: #4a90e2;
}

.rsrvbb-open-tab-icon {
  width: 12px;
  height: 12px;
  opacity: 0.7;
}

.rsrvbb-results-frame {
  width: 100%;
  min-height: 500px;
  max-height: 800px;
  border: none;
  display: block;
  transition: height 0.3s ease;
  overflow-y: auto; /* Make it scrollable */
}

/* Loading state for results container */
.rsrvbb-results-container.loading .rsrvbb-results-frame {
  opacity: 0.5;
}

.rsrvbb-results-container.loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 40px;
  height: 40px;
  border: 4px solid #f3f3f3;
  border-top: 4px solid #4a90e2;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: translate(-50%, -50%) rotate(0deg); }
  100% { transform: translate(-50%, -50%) rotate(360deg); }
}

/* =============================================================================
   Flatpickr Overrides
   ========================================================================== */

.flatpickr-calendar {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  border-radius: 4px;
  border: 1px solid rgba(0, 0, 0, 0.1);
}

.flatpickr-day.selected {
  background-color: #4a90e2;
  border-color: #4a90e2;
}

.flatpickr-day.selected:hover {
  background-color: #357abd;
  border-color: #357abd;
}

/* =============================================================================
   Responsive Design
   ========================================================================== */

@media (max-width: 768px) {
  .rsrvbb-form-container {
    width: 100%;
    padding: 0;
  }

  .rsrvbb-form-row {
    gap: 12px;
  }

  .rsrvbb-form-field {
    flex: 1 1 100%;
    min-width: 100%;
  }

  .rsrvbb-form-submit {
    min-width: 100%;
    margin-top: 8px;
  }

  /* Remove the invisible spacer on mobile */
  .rsrvbb-form-submit::before {
    display: none;
  }

  .rsrvbb-submit-btn {
    height: 52px;
    font-size: 16px;
  }

  .rsrvbb-datepicker,
  .rsrvbb-select {
    height: 52px;
    font-size: 16px;
  }

  .rsrvbb-results-container {
    margin-top: 20px;
    margin-left: -15px;
    margin-right: -15px;
    width: calc(100% + 30px);
    border-radius: 0;
  }

  .rsrvbb-results-header {
    padding: 6px 12px;
    justify-content: center;
  }

  .rsrvbb-open-tab-link {
    font-size: 11px;
    padding: 4px 8px;
  }

  .rsrvbb-results-frame {
    min-height: 400px;
  }
}

@media (max-width: 480px) {
  .rsrvbb-form-container {
    padding: 0;
  }

  .rsrvbb-form-field label {
    font-size: 13px;
  }

  .rsrvbb-results-title {
    font-size: 14px;
  }
}

/* =============================================================================
   Grid Layout for Tablets (2x2 + button)
   ========================================================================== */

@media (min-width: 481px) and (max-width: 768px) {
  .rsrvbb-form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-gap: 12px;
  }

  .rsrvbb-form-field:nth-child(1),
  .rsrvbb-form-field:nth-child(2) {
    grid-column: span 1;
  }

  .rsrvbb-form-field:nth-child(3),
  .rsrvbb-form-field:nth-child(4) {
    grid-column: span 1;
  }

  .rsrvbb-form-submit {
    grid-column: span 2;
    min-width: 100%;
  }
}

/* =============================================================================
   Accessibility
   ========================================================================== */

.rsrvbb-datepicker:focus-visible,
.rsrvbb-select:focus-visible,
.rsrvbb-submit-btn:focus-visible {
  outline: 2px solid #4a90e2;
  outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  .rsrvbb-datepicker,
  .rsrvbb-select {
    border-width: 2px;
  }
  
  .rsrvbb-submit-btn {
    border: 2px solid #fff;
  }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  .rsrvbb-datepicker,
  .rsrvbb-select,
  .rsrvbb-submit-btn,
  .rsrvbb-results-frame {
    transition: none;
  }
}

/* =============================================================================
   Dark Mode Support (Optional)
   ========================================================================== */

@media (prefers-color-scheme: dark) {
  .rsrvbb-light-form .rsrvbb-datepicker,
  .rsrvbb-light-form .rsrvbb-select {
    background-color: #2a2a2a;
    border-color: #444;
    color: #fff;
  }

  .rsrvbb-light-form .rsrvbb-form-field label {
    color: #e0e0e0;
  }
}
