/* 📱 MOBILE BOOKING & CHATBOT OPTIMIZATIONS
   Maison Dalí Dubai - P1-10 Mobile Widget Fixes
   Author: GenSpark AI
   Version: 1.0.0
   Date: 2026-02-18
*/

/* ==========================================
   MOBILE VIEWPORT FIXES
   ========================================== */

/* Prevent iOS zoom on input focus */
@media screen and (max-width: 768px) {
  input[type="text"],
  input[type="email"],
  input[type="tel"],
  input[type="number"],
  input[type="date"],
  input[type="time"],
  select,
  textarea {
    font-size: 16px !important; /* iOS won't zoom if >= 16px */
  }
}

/* Fix for iOS bottom bar overlap */
@supports (-webkit-touch-callout: none) {
  .mdali-glass-container {
    height: calc(65vh - env(safe-area-inset-bottom)) !important;
  }
}

/* ==========================================
   BOOKING FORM - PROGRESSIVE DISCLOSURE
   ========================================== */

/* Hide advanced fields initially on mobile */
@media (max-width: 768px) {
  .booking-form-step-2,
  .booking-form-step-3,
  .booking-form-step-4 {
    display: none;
  }
  
  .booking-form-step-2.visible,
  .booking-form-step-3.visible,
  .booking-form-step-4.visible {
    display: block;
    animation: slideDown 0.3s ease-out;
  }
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ==========================================
   TOUCH TARGET OPTIMIZATION
   ========================================== */

@media (max-width: 768px) {
  /* All interactive elements must be >= 44x44px */
  button,
  .btn,
  .mdali-glass-option-btn,
  .mdali-glass-send-btn,
  .mdali-glass-trigger,
  a.button,
  input[type="submit"],
  input[type="button"] {
    min-height: 44px !important;
    min-width: 44px !important;
    padding: 12px 20px !important;
  }
  
  /* Form inputs - larger touch targets */
  input[type="text"],
  input[type="email"],
  input[type="tel"],
  input[type="number"],
  input[type="date"],
  input[type="time"],
  select,
  textarea {
    min-height: 48px !important;
    padding: 12px 16px !important;
  }
  
  /* Checkbox and radio - larger clickable area */
  input[type="checkbox"],
  input[type="radio"] {
    width: 24px !important;
    height: 24px !important;
  }
  
  /* Labels clickable */
  label {
    cursor: pointer;
    padding: 8px;
  }
}

/* ==========================================
   KEYBOARD HANDLING
   ========================================== */

/* When keyboard is open, add padding to prevent content hiding */
@media (max-width: 768px) {
  .booking-form,
  .mdali-glass-messages {
    padding-bottom: 300px !important; /* Space for keyboard */
  }
  
  /* Scroll container to keep active input visible */
  .booking-form.keyboard-visible,
  .mdali-glass-messages.keyboard-visible {
    scroll-behavior: smooth;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
}

/* ==========================================
   NATIVE DATE/TIME PICKERS
   ========================================== */

/* Use native HTML5 inputs for better mobile experience */
@media (max-width: 768px) {
  input[type="date"],
  input[type="time"] {
    -webkit-appearance: none;
    appearance: none;
    min-height: 48px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.05);
    color: white;
    padding: 12px 16px;
  }
  
  /* Date/time picker icon spacing */
  input[type="date"]::-webkit-calendar-picker-indicator,
  input[type="time"]::-webkit-calendar-picker-indicator {
    filter: invert(1);
    cursor: pointer;
    padding: 8px;
  }
}

/* ==========================================
   INLINE VALIDATION
   ========================================== */

@media (max-width: 768px) {
  /* Error messages */
  .form-error {
    display: block;
    color: #ef4444;
    font-size: 14px;
    margin-top: 4px;
    padding-left: 16px;
    animation: shake 0.3s ease-in-out;
  }
  
  /* Success indicators */
  .form-success {
    display: block;
    color: #10b981;
    font-size: 14px;
    margin-top: 4px;
    padding-left: 16px;
  }
  
  /* Invalid field styling */
  input.invalid,
  select.invalid,
  textarea.invalid {
    border-color: #ef4444 !important;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
  }
  
  /* Valid field styling */
  input.valid,
  select.valid,
  textarea.valid {
    border-color: #10b981 !important;
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
  }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

/* ==========================================
   MOBILE CHATBOT WIDGET SPECIFIC
   ========================================== */

@media (max-width: 768px) {
  /* Full screen overlay when open */
  .mdali-glass-container.open {
    width: 100% !important;
    height: 100vh !important;
    top: 0 !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    border-radius: 0 !important;
    z-index: 999999 !important;
  }
  
  /* Trigger button positioning */
  .mdali-glass-trigger {
    bottom: 20px !important;
    right: 20px !important;
    z-index: 999998 !important;
  }
  
  /* Prevent body scroll when chatbot is open */
  body.chatbot-open {
    overflow: hidden !important;
    position: fixed !important;
    width: 100% !important;
  }
}

/* ==========================================
   LOADING STATES
   ========================================== */

@media (max-width: 768px) {
  .loading-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-top-color: rgba(255, 255, 255, 0.8);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
  }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ==========================================
   MOBILE PERFORMANCE
   ========================================== */

@media (max-width: 768px) {
  /* GPU acceleration for smooth animations */
  .mdali-glass-container,
  .mdali-glass-trigger,
  .mdali-glass-option-btn {
    will-change: transform;
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
  }
  
  /* Reduce motion for users who prefer it */
  @media (prefers-reduced-motion: reduce) {
    * {
      animation-duration: 0.01ms !important;
      animation-iteration-count: 1 !important;
      transition-duration: 0.01ms !important;
    }
  }
}

/* ==========================================
   TABLET RESPONSIVE (768px - 1024px)
   ========================================== */

@media (min-width: 769px) and (max-width: 1024px) {
  .mdali-glass-container {
    width: 420px !important;
    height: 680px !important;
  }
}

/* ==========================================
   LANDSCAPE MODE ADJUSTMENTS
   ========================================== */

@media (max-width: 768px) and (orientation: landscape) {
  .mdali-glass-container {
    height: 90vh !important;
  }
  
  .mdali-glass-messages {
    max-height: calc(90vh - 180px) !important;
  }
}

/* ==========================================
   ACCESSIBILITY ENHANCEMENTS
   ========================================== */

@media (max-width: 768px) {
  /* High contrast mode */
  @media (prefers-contrast: high) {
    .mdali-glass-container {
      border: 2px solid white !important;
    }
    
    button,
    .mdali-glass-option-btn {
      border: 2px solid currentColor !important;
    }
  }
  
  /* Focus indicators */
  *:focus-visible {
    outline: 3px solid rgba(139, 0, 0, 0.8);
    outline-offset: 2px;
  }
  
  /* Screen reader only */
  .sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
  }
}

/* ==========================================
   MOBILE-SPECIFIC UTILITIES
   ========================================== */

@media (max-width: 768px) {
  /* Hide on mobile */
  .hidden-mobile {
    display: none !important;
  }
  
  /* Show only on mobile */
  .visible-mobile {
    display: block !important;
  }
  
  /* Full width on mobile */
  .mobile-full-width {
    width: 100% !important;
  }
  
  /* Responsive text sizes */
  .text-mobile-sm { font-size: 14px !important; }
  .text-mobile-base { font-size: 16px !important; }
  .text-mobile-lg { font-size: 18px !important; }
  .text-mobile-xl { font-size: 20px !important; }
}
