/**
 * Mobile-optimized date/time picker styles
 * Enhanced for better cross-device compatibility and touch interaction
 * Supports iOS, Android, and desktop browsers with consistent experience
 */

:root {
  --tap-highlight-color: rgba(0, 0, 0, 0.1);
  --primary-color: #6b6f24;
  --primary-color-hover: #565a1d;
  --primary-color-light: rgba(107, 111, 36, 0.25);
  --border-color: #dee2e6;
  --focus-shadow: 0 0 0 3px rgba(107, 111, 36, 0.25);
}

/* Ensure date and time inputs look good on all devices */
input[type="date"],
input[type="time"] {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  width: 100%;
  padding: 12px 15px;
  font-size: 16px; /* At least 16px to prevent iOS zoom */
  border: 1px solid var(--border-color);
  border-radius: 4px;
  background-color: #fff;
  cursor: pointer;
  transition: border-color 0.3s, box-shadow 0.3s;
  color: #333;
}

input[type="date"]:focus,
input[type="time"]:focus {
  border-color: var(--primary-color);
  outline: none;
  box-shadow: var(--focus-shadow);
}

/* Remove default browser styling */
input::-webkit-calendar-picker-indicator {
  opacity: 0;
  position: absolute;
  right: 0;
  top: 0;
  width: 100%;
  height: 100%;
  cursor: pointer;
}

/* Visual feedback for touch devices */
.mobile-friendly-input {
  -webkit-tap-highlight-color: var(--tap-highlight-color);
  tap-highlight-color: var(--tap-highlight-color);
}

.input-focus {
  border-color: var(--primary-color) !important;
  box-shadow: var(--focus-shadow) !important;
}

/* Enhanced input wrappers */
.input-wrapper {
  position: relative;
  margin-bottom: 10px;
}

.input-wrapper:after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  border-radius: 4px;
  transition: background-color 0.2s;
}

.input-wrapper:active:after {
  background-color: rgba(0, 0, 0, 0.05);
}

/* Make date and time icons interactive */
.date-icon {
  cursor: pointer;
  transition: opacity 0.2s;
}

.date-icon:hover {
  opacity: 0.8;
}

.date-icon:active {
  opacity: 0.6;
}

/* Mobile-specific enhancements */
@media (max-width: 767px) {
  .input-wrapper {
    margin-bottom: 15px;
  }
  
  input[type="date"],
  input[type="time"] {
    height: 48px;
    font-size: 16px;
    padding-right: 40px; /* Space for the icon */
  }
  
  .date-icon {
    width: 24px;
    height: 24px;
    right: 12px !important;
  }
  
  /* Make form elements in the reservation form more finger-friendly */
  #reservation-form select,
  #reservation-form input {
    height: 48px;
    font-size: 16px;
  }
  
  #reservation-form .form-group {
    margin-bottom: 20px;
  }
  
  #reservation-form .btn,
  #reservation-form button[type="submit"] {
    padding: 15px;
    font-size: 18px;
    height: auto;
    min-height: 50px;
  }
  
  /* Make radio buttons and checkboxes easier to tap */
  .custom-radio-btn {
    padding: 15px 10px;
    min-height: 48px;
  }
  
  /* Larger tap area for checkboxes */
  input[type="checkbox"] {
    height: 24px;
    width: 24px;
  }
  
  /* Enhance labels for better readability */
  #reservation-form label {
    font-size: 16px;
    margin-bottom: 8px;
  }
  
  /* Custom bottom sheet styles for date/time selectors on mobile */
  /* This gives a more native app-like feel on touch devices */
  @supports (-webkit-touch-callout: none) {
    input[type="date"],
    input[type="time"] {
      background-color: #f9f9f9;
    }
    
    /* iOS-specific optimizations */
    input[type="date"]::-webkit-datetime-edit, 
    input[type="time"]::-webkit-datetime-edit {
      font-size: 16px;
      line-height: 1.4;
    }
    
    input[type="date"]::-webkit-datetime-edit-fields-wrapper, 
    input[type="time"]::-webkit-datetime-edit-fields-wrapper {
      color: #000;
    }
    
    input[type="date"]::-webkit-datetime-edit-text, 
    input[type="time"]::-webkit-datetime-edit-text {
      color: #555;
      padding: 0 2px;
    }
    
    input[type="date"]::-webkit-datetime-edit-day-field,
    input[type="date"]::-webkit-datetime-edit-month-field, 
    input[type="date"]::-webkit-datetime-edit-year-field,
    input[type="time"]::-webkit-datetime-edit-hour-field, 
    input[type="time"]::-webkit-datetime-edit-minute-field {
      color: #000;
      font-weight: 500;
    }
    
    input[type="date"]::-webkit-inner-spin-button, 
    input[type="time"]::-webkit-inner-spin-button {
      display: none;
    }
  }
  
  /* Android-specific optimizations */
  @supports (not (-webkit-touch-callout: none)) {
    input[type="date"],
    input[type="time"] {
      background-color: #fff;
      text-align: left;
    }
  }
}

/* Validation error state */
.validation-error {
  border-color: #dc3545 !important;
  box-shadow: 0 0 0 3px rgba(220, 53, 69, 0.25) !important;
  animation: shake 0.5s cubic-bezier(.36,.07,.19,.97) both;
}

@keyframes shake {
  10%, 90% { transform: translateX(-1px); }
  20%, 80% { transform: translateX(2px); }
  30%, 50%, 70% { transform: translateX(-2px); }
  40%, 60% { transform: translateX(2px); }
}

/* Interactive icon styles */
.interactive-icon {
  transition: transform 0.2s, opacity 0.2s;
}

.interactive-icon:active {
  transform: scale(0.9);
  opacity: 0.7;
}

/* Active touch state */
.touch-active {
  background-color: rgba(107, 111, 36, 0.05) !important;
}

/* Screen reader only class */
.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;
}

/* Special enhancements for very small screens */
@media (max-width: 480px) {
  .col-xs-6 {
    width: 100%; /* Stack date and time inputs on very small screens */
    float: none;
  }
  
  input[type="date"],
  input[type="time"] {
    font-size: 18px; /* Even larger font size on smallest screens */
    padding: 14px 15px;
    height: 54px;
  }
  
  /* Make the date and time inputs stand out better */
  .input-wrapper {
    margin-bottom: 18px;
  }
  
  /* Larger tap targets on smallest screens */
  .date-icon {
    width: 28px;
    height: 28px;
  }
  
  /* Higher contrast for clearer visibility */
  #reservation-form label {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 10px;
  }
  
  /* Larger submit button for easier tapping */
  #reservation-form button[type="submit"] {
    padding: 16px;
    font-size: 20px;
    min-height: 56px;
  }
  
  /* Enhanced validation message for smaller screens */
  #datetime-validation-message {
    padding: 12px 24px !important;
    font-size: 18px !important;
    bottom: 30px !important;
  }
  
  /* Improve radio button layout on small screens */
  .wpp-radio-wrap {
    display: flex;
    flex-direction: column;
  }
  
  .wpp-radio-wrap .wpp-radio {
    margin-bottom: 10px;
    width: 100%;
  }
  
  /* Make airport selection easier to use on small screens */
  #pickup_airport_select,
  #destination_airport_select {
    font-size: 18px;
    height: 54px;
  }
  
  /* Make "Other airport" field larger and more visible */
  #pickup_other_airport,
  #destination_other_airport {
    height: 54px;
    font-size: 18px;
    padding: 14px 15px;
  }
  
  /* Fix any potential overflow issues in airport selection */
  #pickup_airport_section,
  #destination_airport_section {
    overflow: visible;
  }
}