/* Wayplot Dubai Trip Planner - Styles */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --z-map: 1;
  --z-map-controls: 10;
  --z-panels: 100;
  --z-header: 200;
  --z-nav: 300;
  --z-toast: 400;
  --z-modal-backdrop: 500;
  --z-modal: 600;
}

/* 
 * Mobile Browser URL Bar Strategy
 * 
 * On iOS Safari/Chrome, the URL bar collapses when the user scrolls DOWN.
 * Our app uses 100dvh with internal scrolling, so we need to:
 * 1. Make the page slightly taller than viewport (scrollable)
 * 2. Use dvh units so the app resizes when URL bar collapses
 * 3. Keep the app fixed at top while body is scrollable
 * 
 * The user's natural scroll gesture will collapse the URL bar.
 */

html {
  /* Don't set height - let it be natural */
  background: linear-gradient(145deg, #FEFDFB 0%, #FFFBEB 100%);
}

body {
  font-family: 'Inter', sans-serif;
  background: linear-gradient(145deg, #FEFDFB 0%, #FFFBEB 100%);
  color: #0C0A1F;
  -webkit-font-smoothing: antialiased;
  /* IMPORTANT: Don't set overflow:hidden - breaks URL bar collapse on iOS */
  margin: 0;
  padding: 0;
}

/* Mobile: Allow natural scrolling to trigger URL bar collapse */
@media (max-width: 767px) {
  body {
    /* Make body taller than viewport so it's scrollable */
    /* This allows the natural scroll gesture to collapse URL bar */
    min-height: calc(100vh + 1px);
    min-height: calc(100svh + 1px);
  }
  
  #root {
    /* App fills dynamic viewport and sticks to top */
    height: 100vh;
    height: 100dvh;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    /* When URL bar collapses, dvh grows and app expands */
  }
}

/* Desktop: standard fixed layout */
@media (min-width: 768px) {
  body {
    height: 100vh;
    overflow: hidden;
  }
  
  #root {
    height: 100vh;
    height: 100dvh;
  }
}

/* Ensure scrollable areas have smooth iOS scrolling */
.overflow-y-auto {
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
}

/* 
 * Prevent iOS Safari zoom on input focus
 * iOS zooms when input font-size is less than 16px
 */
@media screen and (-webkit-min-device-pixel-ratio: 0) and (max-width: 767px) {
  input[type="text"],
  input[type="search"],
  input[type="email"],
  input[type="tel"],
  input[type="number"],
  input[type="url"],
  textarea,
  select {
    font-size: 16px !important;
  }
}

/* Map Container - GPU accelerated */
.map-container {
  position: absolute;
  inset: 0;
  z-index: var(--z-map);
  /* Force GPU layer for smooth zooming */
  transform: translateZ(0);
  -webkit-transform: translateZ(0);
}

.map-container .leaflet-container {
  height: 100%;
  width: 100%;
  z-index: 1 !important;
  /* GPU acceleration for the map */
  transform: translateZ(0);
  -webkit-transform: translateZ(0);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

/* GPU accelerate the tile pane for smooth zoom */
.leaflet-tile-pane {
  transform: translateZ(0);
  -webkit-transform: translateZ(0);
}

.leaflet-marker-pane {
  transform: translateZ(0);
  -webkit-transform: translateZ(0);
}

/* GPU acceleration for marker icons */
.leaflet-marker-icon {
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

/* Keep tiles visible during zoom to prevent grey flash */
.leaflet-tile-container {
  will-change: transform, opacity;
}

.leaflet-tile {
  will-change: transform;
}

/* Smooth tile fade-in without hiding previous tiles */
.leaflet-fade-anim .leaflet-tile {
  transition: opacity 0.15s linear;
}

/* Fallback background matching CartoDB Voyager land color */
.leaflet-container {
  background: #f2efe9 !important;
}

.leaflet-top, .leaflet-bottom {
  z-index: var(--z-map-controls) !important;
}

.leaflet-control {
  z-index: var(--z-map-controls) !important;
}

/* Ensure zoom controls are always visible and properly styled */
.leaflet-control-zoom {
  border: 2px solid rgba(0,0,0,0.2) !important;
  border-radius: 4px !important;
  background: white !important;
  box-shadow: 0 2px 6px rgba(0,0,0,0.15) !important;
}

.leaflet-control-zoom a {
  width: 32px !important;
  height: 32px !important;
  line-height: 32px !important;
  font-size: 18px !important;
  color: #333 !important;
  background: white !important;
  text-decoration: none !important;
}

.leaflet-control-zoom a:hover {
  background: #f4f4f4 !important;
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-thumb {
  background: #D4C4A8;
  border-radius: 100px;
}

/* Animations */
@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(100%);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes slideInBottom {
  from {
    transform: translateY(100%);
  }
  to {
    transform: translateY(0);
  }
}

@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes glow {
  0%, 100% {
    box-shadow: 0 0 8px rgba(245, 158, 11, 0.4);
  }
  50% {
    box-shadow: 0 0 20px rgba(245, 158, 11, 0.7);
  }
}

.animate-slide-in-right {
  animation: slideInRight 0.3s ease-out forwards;
}

.animate-slide-in-bottom {
  animation: slideInBottom 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

.animate-scale-in {
  animation: scaleIn 0.3s ease-out forwards;
}

.animate-glow {
  animation: glow 2s ease-in-out infinite;
}

/* Glass Effect - using solid background for performance (backdrop-filter causes map lag) */
.glass-strong {
  background: rgba(255, 255, 255, 0.98);
}

/* Modal Root */
#modal-root {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  pointer-events: none;
  z-index: 99998;
}

#modal-root > * {
  pointer-events: auto;
}

/* Map Markers - optimized for performance */
.map-marker {
  width: 40px;
  height: 40px;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
  border: 3px solid white;
  cursor: pointer;
  /* Only transition transform on hover, not during map zoom */
  transition: transform 0.15s ease-out;
  /* Hint browser to optimize this element */
  will-change: transform;
  contain: layout style;
}

.map-marker:hover {
  transform: rotate(-45deg) scale(1.15);
}

/* Selected marker - subtle ring instead of animation for performance */
.map-marker.selected {
  box-shadow: 0 0 0 4px rgba(245, 158, 11, 0.5), 0 2px 6px rgba(0, 0, 0, 0.2);
}

.map-marker-emoji {
  transform: rotate(45deg);
  font-size: 16px;
}

.map-marker-home {
  width: 52px;
  height: 52px;
  background: linear-gradient(135deg, #FBBF24, #D97706);
  border: 4px solid white;
}

.map-marker-home .map-marker-emoji {
  font-size: 20px;
}

.marker-day-badge {
  position: absolute;
  top: -10px;
  right: -10px;
  min-width: 24px;
  height: 24px;
  padding: 0 6px;
  color: white;
  font-size: 11px;
  font-weight: 700;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  transform: rotate(45deg);
  border: 2px solid white;
}

/* Drop Zones */
.drop-zone {
  min-height: 12px;
  margin: 4px 0;
  border-radius: 8px;
  transition: all 0.2s;
}

.drop-zone.active {
  min-height: 48px;
  background: #FEF3C7;
  border: 2px dashed #F59E0B;
}

.drop-zone-empty {
  min-height: 80px;
  border: 2px dashed #D1D5DB;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.drop-zone-empty.active {
  background: #FEF3C7;
  border-color: #F59E0B;
}

/* Drag State */
.dragging {
  opacity: 0.5;
}

/* Safe Area Padding */
.pb-safe {
  padding-bottom: max(16px, env(safe-area-inset-bottom));
}

/* ========== LOCATION PICKER V2 ========== */
/* Stacked layout: compact map on top, content below */

.location-picker-v2 {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 350px;
  overflow: hidden;
}

/* Map container - fixed height on top */
.location-picker-v2-map-container {
  position: relative;
  height: 180px !important;
  min-height: 180px !important;
  max-height: 180px !important;
  flex: 0 0 180px !important;
  background: #E5E7EB;
  overflow: hidden;
}

.location-picker-v2-map {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
}

.location-picker-v2-map .leaflet-container {
  height: 100% !important;
  width: 100% !important;
  cursor: crosshair !important;
}

/* Leaflet zoom controls in location picker - just ensure visibility */
.location-picker-v2-map .leaflet-control-zoom {
  margin: 10px !important;
  border: none !important;
  border-radius: 4px !important;
  box-shadow: 0 2px 6px rgba(0,0,0,0.3) !important;
}

.location-picker-v2-map .leaflet-control-zoom a {
  width: 30px !important;
  height: 30px !important;
  line-height: 30px !important;
  background: white !important;
  color: #333 !important;
  font-size: 18px !important;
  font-weight: bold !important;
}

.location-picker-v2-map .leaflet-control-zoom a:hover {
  background: #f4f4f4 !important;
}

/* Map hint overlay */
.location-picker-v2-map-hint {
  position: absolute;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.6);
  color: white;
  padding: 5px 12px;
  border-radius: 12px;
  font-size: 12px;
  pointer-events: none;
  z-index: 10;
}

/* Selected location bar on map */
.location-picker-v2-map-selected {
  position: absolute;
  bottom: 8px;
  left: 8px;
  right: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: white;
  padding: 8px 12px;
  border-radius: 10px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  z-index: 10;
}

.location-picker-v2-map-selected-icon {
  font-size: 16px;
}

.location-picker-v2-map-selected-name {
  flex: 1;
  font-size: 13px;
  font-weight: 600;
  color: #111827;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.location-picker-v2-map-selected-clear {
  padding: 4px 10px;
  border: none;
  background: #F3F4F6;
  color: #6B7280;
  font-size: 12px;
  font-weight: 500;
  border-radius: 6px;
  cursor: pointer;
  transition: background-color 0.15s;
}

.location-picker-v2-map-selected-clear:hover {
  background: #E5E7EB;
  color: #374151;
}

/* Content area - scrollable, takes remaining space */
.location-picker-v2-content {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  overflow-y: auto;
  overflow-x: hidden;
  background: #FAFAFA;
  min-height: 150px;
  -webkit-overflow-scrolling: touch;
}

/* Search input */
.location-picker-v2-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.location-picker-v2-input-icon {
  position: absolute;
  left: 12px;
  width: 16px;
  height: 16px;
  color: #9CA3AF;
  pointer-events: none;
}

.location-picker-v2-input {
  width: 100%;
  padding: 12px 40px 12px 38px;
  font-size: 14px;
  border: 1px solid #D1D5DB;
  border-radius: 10px;
  background: white;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.location-picker-v2-input:focus {
  border-color: #F59E0B;
  box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.15);
}

.location-picker-v2-input::placeholder {
  color: #9CA3AF;
}

.location-picker-v2-spinner {
  position: absolute;
  right: 12px;
  color: #F59E0B;
}

.location-picker-v2-input-clear {
  position: absolute;
  right: 10px;
  padding: 4px;
  border: none;
  background: transparent;
  color: #9CA3AF;
  cursor: pointer;
  border-radius: 4px;
}

.location-picker-v2-input-clear:hover {
  color: #6B7280;
}

/* Status / Error messages */
.location-picker-v2-status {
  padding: 8px 12px;
  background: #FEF3C7;
  border-radius: 8px;
  font-size: 13px;
  color: #92400E;
}

.location-picker-v2-error {
  padding: 8px 12px;
  background: #FEE2E2;
  border-radius: 8px;
  font-size: 13px;
  color: #991B1B;
}

/* Search results */
.location-picker-v2-results {
  border: 1px solid #E5E7EB;
  border-radius: 10px;
  background: white;
  overflow: hidden;
  max-height: 200px;
  overflow-y: auto;
}

.location-picker-v2-result {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: none;
  background: transparent;
  text-align: left;
  cursor: pointer;
  transition: background-color 0.1s;
  border-bottom: 1px solid #F3F4F6;
}

.location-picker-v2-result:last-child {
  border-bottom: none;
}

.location-picker-v2-result:hover,
.location-picker-v2-result.highlighted {
  background: #FEF3C7;
}

.location-picker-v2-result-icon {
  font-size: 16px;
  flex-shrink: 0;
}

.location-picker-v2-result-text {
  flex: 1;
  min-width: 0;
}

.location-picker-v2-result-name {
  font-weight: 500;
  font-size: 13px;
  color: #111827;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.location-picker-v2-result-address {
  font-size: 11px;
  color: #6B7280;
  margin-top: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Popular Hotels */
.location-picker-v2-hotels {
  /* Spacing handled by parent gap */
}

.location-picker-v2-hotels-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #6B7280;
  margin-bottom: 8px;
}

.location-picker-v2-hotels-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.location-picker-v2-hotel {
  display: flex;
  flex-direction: column;
  padding: 10px 12px;
  border: 1px solid #E5E7EB;
  border-radius: 8px;
  background: white;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s, background-color 0.15s;
}

.location-picker-v2-hotel:hover {
  border-color: #F59E0B;
  background: #FFFBEB;
}

.location-picker-v2-hotel-name {
  font-size: 13px;
  font-weight: 500;
  color: #111827;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.location-picker-v2-hotel-area {
  font-size: 11px;
  color: #9CA3AF;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.location-picker-v2-hotel-city {
  font-weight: 500;
}

/* Hint text */
.location-picker-v2-hint {
  padding: 8px 12px;
  background: #F3F4F6;
  border-radius: 8px;
  font-size: 12px;
  color: #6B7280;
  text-align: center;
}

/* Legacy location picker map (for backwards compat) */
.location-picker-map {
  height: 200px;
  border-radius: 12px;
  overflow: hidden;
}

.location-picker-map .leaflet-container {
  height: 100%;
  cursor: crosshair !important;
}

/* ========== ACCESSIBILITY: Reduced Motion ========== */
/* WCAG 2.1 AA - 2.3.3 Animation from Interactions */
/* Respect user's motion preferences to prevent vestibular disorders */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }

  .animate-slide-in-right,
  .animate-slide-in-bottom,
  .animate-scale-in,
  .animate-glow {
    animation: none !important;
    opacity: 1 !important;
    transform: none !important;
  }

  .map-marker:hover {
    transform: rotate(-45deg) !important; /* No scale animation */
  }
}

/* ========== ACCESSIBILITY: Focus Visible ========== */
/* Enhanced focus indicators for keyboard users */
/* Works with :focus-visible for modern browsers, falls back to :focus */
@supports selector(:focus-visible) {
  /* Remove default focus ring, rely on :focus-visible */
  :focus:not(:focus-visible) {
    outline: none;
  }
}

/* High contrast mode support */
@media (forced-colors: active) {
  .map-marker {
    border: 3px solid CanvasText;
  }

  .map-marker.selected {
    outline: 3px solid Highlight;
  }

  button:focus,
  [role="button"]:focus {
    outline: 2px solid Highlight;
    outline-offset: 2px;
  }
}

/* ========== ACCESSIBILITY: Text Spacing ========== */
/* WCAG 2.1 AA - 1.4.12 Text Spacing - ensure content works with increased spacing */
/* Users can override with browser extensions; we ensure it doesn't break layout */
.line-clamp-2,
.truncate {
  /* Allow text to wrap if user increases spacing */
  overflow-wrap: break-word;
}

