/* Mobile-Friendly Reusable Modal System - Base Styles */

:root {
  --z-modal-backdrop: 2000;
  --z-modal-panel: 2001;
  --transition-fast: 0.2s;
  --transition-normal: 0.3s;
  --transition-slow: 0.4s;
  --ease-soft: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-smooth: cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

@media (prefers-reduced-motion: reduce) {
  :root {
    --transition-fast: 0.1s;
    --transition-normal: 0.15s;
    --transition-slow: 0.2s;
  }
}

/* ============================================
   Base Modal Backdrop - Apple Liquid Glass Effect
   ============================================ */
.ose-modal-backdrop {
  position: fixed !important;
  inset: 0 !important;
  background: rgba(0, 0, 0, 0.4) !important;
  backdrop-filter: blur(20px) saturate(180%) !important;
  -webkit-backdrop-filter: blur(20px) saturate(180%) !important;
  display: none !important;
  align-items: center !important;
  justify-content: center !important;
  z-index: var(--z-modal-backdrop) !important;
  opacity: 0;
  transition: opacity var(--transition-normal) var(--ease-soft) !important;
  /* CRITICAL: Allow vertical panning on backdrop for drag-to-close */
  /* Content area has touch-action: pan-y for scrolling, backdrop allows panning for dragging */
  touch-action: pan-y;
  /* Ensure it's always on top and visible when open */
  visibility: hidden;
}

.ose-modal-backdrop.open,
.ose-modal-backdrop[aria-hidden="false"].open {
  display: flex !important;
  visibility: visible !important;
  opacity: 0; /* Start at 0, will animate to 1 */
}

.ose-modal-backdrop.open.animating,
.ose-modal-backdrop[aria-hidden="false"].open.animating {
  opacity: 1 !important; /* Animate to fully visible */
  visibility: visible !important;
}

/* Mobile-specific: Ensure backdrop is immediately visible on mobile */
@media (max-width: 767px) {
  .ose-modal-backdrop.open,
  .ose-modal-backdrop[aria-hidden="false"].open {
    opacity: 1 !important; /* Immediately visible on mobile for better UX */
  }
}

/* ============================================
   Desktop: Centered Modal Panel - Apple Liquid Glass
   ============================================ */
.ose-modal-panel {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%) scale(0.1);
  width: min(95vw, 1200px);
  max-width: 1200px;
  max-height: calc(100vh - 64px);
  overflow: hidden;
  background: rgba(255, 252, 245, 0.98) !important;
  backdrop-filter: blur(40px) saturate(180%) !important;
  -webkit-backdrop-filter: blur(40px) saturate(180%) !important;
  border: 1px solid rgba(242, 230, 218, 0.6) !important;
  border-radius: 1.25rem;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12), 
              0 2px 8px rgba(0, 0, 0, 0.08),
              0 0 0 1px rgba(255, 255, 255, 0.5) inset,
              inset 0 1px 0 rgba(255, 255, 255, 0.6) !important;
  transition: transform var(--transition-normal) var(--ease-spring), 
              opacity var(--transition-normal) var(--ease-soft) !important;
  opacity: 0;
  z-index: var(--z-modal-panel);
  transform-origin: center center;
  visibility: hidden;
  display: flex;
  flex-direction: column;
  /* Ensure rounded edges on all corners */
  overflow: hidden;
  /* Ensure modal panel receives touch events */
  pointer-events: auto;
  /* Allow normal touch handling on panel - content will have touch-action: pan-y for scrolling */
  touch-action: auto;
}

/* CRITICAL: When backdrop is open, panel must be visible */
.ose-modal-backdrop.open .ose-modal-panel {
  visibility: visible !important;
  display: flex !important;
}

/* CRITICAL: Desktop centered panels - immediate visibility */
.ose-modal-backdrop.open .ose-modal-panel.centered {
  opacity: 1 !important;
  visibility: visible !important;
  transform: translate(-50%, -50%) scale(1) !important;
  display: flex !important;
}

/* Ensure bottom-sheet is visible when backdrop opens (even before animating) */
.ose-modal-backdrop.open .ose-modal-panel.bottom-sheet {
  visibility: visible !important;
  opacity: 0; /* Start invisible, will animate to 1 */
}

.ose-modal-backdrop.open.animating .ose-modal-panel {
  transform: translate(-50%, -50%) scale(1);
  opacity: 1 !important;
  visibility: visible !important;
}

/* Explicit rule for centered panels to ensure scale(1) applies with highest specificity */
.ose-modal-backdrop.open.animating .ose-modal-panel.centered {
  transform: translate(-50%, -50%) scale(1) !important;
  opacity: 1 !important;
  visibility: visible !important;
}

/* ============================================
   Mobile: Bottom Sheet (default for forms)
   ============================================ */
@media (max-width: 767px) {
  .ose-modal-panel.bottom-sheet {
    position: fixed !important;
    left: 0 !important;
    top: auto !important;
    bottom: 0 !important;
    right: 0 !important;
    transform: translateY(100%) !important;
    width: 100% !important;
    max-width: 100% !important;
    /* CRITICAL: Panel needs constrained height for flex scrolling to work */
    /* Use max-height to limit panel size, but ensure it has a height for flex calculations */
    max-height: 90dvh !important;
    max-height: 90vh !important; /* Fallback for browsers that don't support dvh */
    /* Set height to max-height to ensure flex layout can calculate content scroll area */
    /* Content will scroll when it exceeds this height */
    height: 90dvh !important;
    height: 90vh !important; /* Fallback */
    min-height: 0 !important;
    border-radius: 1.5rem 1.5rem 0 0 !important;
    border-left: none !important;
    border-right: none !important;
    border-bottom: none !important;
    transform-origin: bottom center !important;
    box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.15),
                0 -2px 8px rgba(0, 0, 0, 0.1),
                0 0 0 1px rgba(255, 255, 255, 0.5) inset !important;
    /* Safe area support for notched devices */
    padding-bottom: env(safe-area-inset-bottom, 0) !important;
    opacity: 0 !important;
    visibility: visible !important; /* Always visible, just off-screen initially */
    display: flex !important;
    flex-direction: column !important; /* Ensure vertical layout */
    z-index: calc(var(--z-modal-panel) + 1) !important; /* Ensure panel is above backdrop */
    overflow: hidden !important; /* Panel container doesn't scroll, content does */
    /* CRITICAL: Ensure panel receives touch events on mobile */
    pointer-events: auto !important;
    touch-action: auto !important; /* Allow normal touch - content has pan-y for scrolling */
  }
  
  /* Ensure content area is scrollable on mobile bottom-sheet */
  .ose-modal-panel.bottom-sheet .ose-modal-content {
    /* CRITICAL: Flex properties for scrolling in constrained container */
    /* Use flex: 1 1 0% to force flex to calculate height based on available space */
    flex: 1 1 0% !important;
    min-height: 0 !important; /* Critical: allows flex item to shrink below content size */
    /* Don't set height explicitly - let flex calculate it */
    /* max-height ensures content doesn't exceed parent, but flex handles the actual height */
    max-height: 100% !important;
    /* Enable scrolling when content exceeds available space */
    overflow-y: auto !important;
    overflow-x: hidden !important;
    /* iOS-specific: Enable momentum scrolling for smooth native-like scrolling */
    -webkit-overflow-scrolling: touch !important;
    /* Prevent scroll chaining - when scrolling reaches top/bottom, don't scroll background */
    overscroll-behavior: contain !important;
    overscroll-behavior-y: contain !important;
    /* CRITICAL: Allow vertical panning for scrolling, prevent other gestures */
    /* This MUST be set to allow native iOS scrolling */
    touch-action: pan-y pinch-zoom !important;
    /* Optimize for smooth scrolling */
    will-change: scroll-position !important;
    /* Ensure proper box model for scrolling */
    box-sizing: border-box !important;
    /* Ensure content creates its own stacking context */
    position: relative !important;
    isolation: isolate !important;
    /* CRITICAL: Ensure content area is always scrollable and receives touch events */
    pointer-events: auto !important;
    /* Ensure content has proper z-index to receive touches above other elements */
    z-index: 10 !important;
    /* Ensure content can receive all touch events */
    -webkit-tap-highlight-color: transparent !important;
  }
  
  /* Make bottom-sheet visible when backdrop opens - use animation for reliable iOS behavior */
  /* CRITICAL: High specificity to ensure these rules override any conflicting styles */
  .ose-modal-backdrop.open .ose-modal-panel.bottom-sheet:not(.closing),
  .ose-modal-backdrop[aria-hidden="false"].open .ose-modal-panel.bottom-sheet:not(.closing) {
    visibility: visible !important;
    display: flex !important;
    opacity: 1 !important;
    z-index: 10000 !important; /* High z-index to ensure it's above backdrop */
    /* Use CSS animation to slide up - works reliably on iOS */
    animation: slideUpBottomSheet 0.4s cubic-bezier(0.32, 0.72, 0, 1) forwards !important;
    /* Immediate fallback: ensure transform is set even if animation doesn't trigger */
    transform: translateY(0) !important;
  }
  
  @keyframes slideUpBottomSheet {
    from {
      transform: translateY(100%);
    }
    to {
      transform: translateY(0);
    }
  }
  
  /* When animating class is added, ensure panel is at final position */
  /* CRITICAL: Even higher specificity for animating state */
  .ose-modal-backdrop.open.animating .ose-modal-panel.bottom-sheet,
  .ose-modal-backdrop[aria-hidden="false"].open.animating .ose-modal-panel.bottom-sheet {
    transform: translateY(0) !important;
    opacity: 1 !important;
    visibility: visible !important;
    display: flex !important;
    z-index: 10000 !important;
    /* Force animation to complete state immediately if needed */
    animation: slideUpBottomSheet 0.4s cubic-bezier(0.32, 0.72, 0, 1) forwards !important;
  }
  
  /* Emergency fallback: If modal is open but panel is still invisible after 100ms, force visibility */
  /* This handles cases where CSS animations fail or are blocked */
  .ose-modal-backdrop.open .ose-modal-panel.bottom-sheet[style*="display: flex"],
  .ose-modal-backdrop.open .ose-modal-panel.bottom-sheet[style*="display:flex"] {
    transform: translateY(0) !important;
    opacity: 1 !important;
    visibility: visible !important;
  }

  /* Swipe indicator handle - Glass style */
  .ose-modal-panel.bottom-sheet::before {
    content: '';
    position: absolute;
    top: 12px;
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 4px;
    background: rgba(229, 229, 229, 0.8);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-radius: 2px;
    z-index: 1;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
  }
}

/* ============================================
   Mobile: Full-Screen Modal
   ============================================ */
@media (max-width: 767px) {
  .ose-modal-panel.full-screen {
    position: fixed !important;
    left: 0 !important;
    top: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    transform: translateY(100%) !important;
    width: 100% !important;
    height: 100% !important;
    max-width: 100% !important;
    max-height: 100dvh !important;
    max-height: 100vh !important; /* Fallback */
    border-radius: 0 !important;
    border: none !important;
    margin: 0 !important;
    padding-top: env(safe-area-inset-top, 0) !important;
    padding-bottom: env(safe-area-inset-bottom, 0) !important;
    padding-left: env(safe-area-inset-left, 0) !important;
    padding-right: env(safe-area-inset-right, 0) !important;
    transform-origin: bottom center !important;
    opacity: 0 !important;
    visibility: visible !important; /* Always visible, just animated */
    display: flex !important;
    z-index: calc(var(--z-modal-panel) + 1) !important; /* Ensure panel is above backdrop */
    /* CRITICAL: Ensure panel receives touch events on mobile */
    pointer-events: auto !important;
    touch-action: auto !important; /* Allow normal touch - content has pan-y for scrolling */
  }

  /* Make panel visible when backdrop is open - use animation for reliable iOS behavior */
  .ose-modal-backdrop.open .ose-modal-panel.full-screen:not(.closing) {
    visibility: visible !important;
    display: flex !important;
    opacity: 1 !important;
    z-index: 10000 !important; /* High z-index to ensure it's above backdrop */
    /* Use CSS animation to slide up - works reliably on iOS */
    animation: slideUpFullScreen 0.4s cubic-bezier(0.32, 0.72, 0, 1) forwards !important;
  }
  
  @keyframes slideUpFullScreen {
    from {
      transform: translateY(100%);
    }
    to {
      transform: translateY(0);
    }
  }
  
  /* When animating class is added, ensure panel is at final position */
  .ose-modal-backdrop.open.animating .ose-modal-panel.full-screen {
    transform: translateY(0) !important;
    opacity: 1 !important;
    visibility: visible !important;
    display: flex !important;
    z-index: 10000 !important;
  }
  
  /* Ensure content area is scrollable on mobile full-screen modal */
  .ose-modal-panel.full-screen .ose-modal-content {
    /* CRITICAL: Flex properties for scrolling in constrained container */
    /* Use flex: 1 1 0% to force flex to calculate height based on available space */
    flex: 1 1 0% !important;
    min-height: 0 !important; /* Critical: allows flex item to shrink below content size */
    /* Don't set height explicitly - let flex calculate it */
    /* max-height ensures content doesn't exceed parent, but flex handles the actual height */
    max-height: 100% !important;
    /* Enable scrolling when content exceeds available space */
    overflow-y: auto !important;
    overflow-x: hidden !important;
    /* iOS-specific: Enable momentum scrolling for smooth native-like scrolling */
    -webkit-overflow-scrolling: touch !important;
    /* Prevent scroll chaining - when scrolling reaches top/bottom, don't scroll background */
    overscroll-behavior: contain !important;
    overscroll-behavior-y: contain !important;
    /* CRITICAL: Allow vertical panning for scrolling, prevent other gestures */
    touch-action: pan-y pinch-zoom !important;
    /* Optimize for smooth scrolling */
    will-change: scroll-position !important;
    /* Ensure proper box model for scrolling */
    box-sizing: border-box !important;
    /* Ensure content creates its own stacking context */
    position: relative !important;
    isolation: isolate !important;
  }

  /* Ensure backdrop is visible on mobile */
  .ose-modal-backdrop.open {
    display: flex !important;
    visibility: visible !important;
    justify-content: center !important;
  }

  /* Full-screen backdrop stretches to fill screen */
  .ose-modal-backdrop.open.full-screen-backdrop {
    align-items: stretch !important;
  }
  
  /* Override any potential display:none from other styles */
  .ose-modal-backdrop.open,
  .ose-modal-backdrop.open.animating {
    display: flex !important;
    visibility: visible !important;
    opacity: 1 !important;
  }
}

/* ============================================
   Modal Header - Apple Liquid Glass
   ============================================ */
.ose-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem;
  padding-top: 1.5rem;
  border-bottom: 1px solid rgba(242, 230, 218, 0.4);
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.75) !important;
  backdrop-filter: blur(30px) saturate(180%) !important;
  -webkit-backdrop-filter: blur(30px) saturate(180%) !important;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.5) inset, 
              0 -1px 8px rgba(0, 0, 0, 0.05),
              inset 0 1px 0 rgba(255, 255, 255, 0.6) !important;
  min-height: 44px; /* Touch target */
  /* CRITICAL: Allow vertical panning on header for drag-to-close */
  /* Content area has touch-action: pan-y for scrolling, header allows panning for dragging */
  touch-action: pan-y;
}

@media (max-width: 767px) {
  .ose-modal-header {
    padding-top: 2rem; /* Extra space for swipe handle */
  }

  .ose-modal-panel.full-screen .ose-modal-header {
    padding-top: 1rem;
  }
}

.ose-modal-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: #2f2925;
  margin: 0;
}

.ose-modal-subtitle {
  font-size: 0.875rem;
  color: #6b7280;
  margin: 0.25rem 0 0 0;
}

.ose-modal-close {
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(234, 221, 214, 0.6);
  border-radius: 50%;
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1.5rem;
  font-weight: 700;
  color: #5b504a;
  transition: all var(--transition-fast) var(--ease-soft);
  flex-shrink: 0;
  touch-action: manipulation;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08), 
              0 1px 2px rgba(0, 0, 0, 0.05);
}

.ose-modal-close:hover {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-color: rgba(229, 213, 200, 0.8);
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12), 
              0 2px 4px rgba(0, 0, 0, 0.08);
}

.ose-modal-close:active {
  transform: scale(0.95);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
}

/* ============================================
   Modal Content - Apple Liquid Glass Background
   ============================================ */
.ose-modal-content {
  flex: 1 1 auto;
  min-height: 0; /* Critical for flex scrolling - allows item to shrink below content size */
  overflow-y: auto !important;
  overflow-x: hidden !important;
  padding: 1rem;
  /* iOS-specific: Enable momentum scrolling for smooth native-like scrolling */
  -webkit-overflow-scrolling: touch !important;
  /* Prevent scroll chaining - when content scrolls to top/bottom, don't scroll background */
  overscroll-behavior: contain !important;
  overscroll-behavior-y: contain !important;
  background: transparent;
  /* Ensure smooth scrolling on all devices */
  will-change: scroll-position;
  box-sizing: border-box;
  /* CRITICAL: Allow vertical scrolling and pinch zoom - this enables native iOS scrolling */
  touch-action: pan-y pinch-zoom !important;
  /* Ensure content receives touch events */
  pointer-events: auto !important;
  /* Ensure content is positioned correctly for scrolling */
  position: relative;
  z-index: 1;
}

/* Smooth scrolling on mobile */
@supports (-webkit-overflow-scrolling: touch) {
  .ose-modal-content {
    -webkit-overflow-scrolling: touch;
  }
}

/* Desktop: Ensure content can scroll when modal is constrained */
@media (min-width: 768px) {
  .ose-modal-content {
    /* On desktop, content should scroll when it exceeds modal height */
    max-height: 100%;
  }
}

/* ============================================
   Modal Footer - Apple Liquid Glass
   ============================================ */
.ose-modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
  padding: 1rem;
  border-top: 1px solid rgba(242, 230, 218, 0.4);
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.75) !important;
  backdrop-filter: blur(30px) saturate(180%) !important;
  -webkit-backdrop-filter: blur(30px) saturate(180%) !important;
  box-shadow: 0 -1px 0 rgba(255, 255, 255, 0.5) inset, 
              0 1px 8px rgba(0, 0, 0, 0.05),
              inset 0 -1px 0 rgba(255, 255, 255, 0.6) !important;
}

@media (max-width: 767px) {
  .ose-modal-footer {
    padding-bottom: calc(1rem + env(safe-area-inset-bottom, 0));
  }
}

/* ============================================
   Touch-Friendly Buttons
   ============================================ */
.ose-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.25rem;
  min-height: 44px;
  border-radius: 0.875rem;
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  border: none;
  transition: all var(--transition-fast) var(--ease-soft);
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.ose-btn:active {
  transform: scale(0.97);
}

.ose-btn-primary {
  background: rgba(227, 77, 46, 0.9);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: #fff;
  border: 1px solid rgba(227, 77, 46, 0.6);
  box-shadow: 0 4px 12px rgba(227, 77, 46, 0.25), 
              0 2px 4px rgba(0, 0, 0, 0.1);
}

.ose-btn-primary:hover {
  background: rgba(227, 77, 46, 1);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(227, 77, 46, 0.35), 
              0 2px 6px rgba(0, 0, 0, 0.12);
}

.ose-btn-ghost {
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: #5b504a;
  border: 1px solid rgba(234, 221, 214, 0.5);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08), 
              0 1px 2px rgba(0, 0, 0, 0.05);
}

.ose-btn-ghost:hover {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-color: rgba(234, 221, 214, 0.8);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1), 
              0 2px 4px rgba(0, 0, 0, 0.06);
}

/* ============================================
   Form Elements (Mobile Optimized)
   ============================================ */
.ose-field {
  margin-bottom: 1.25rem;
}

.ose-field label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  color: #5b504a;
  margin-bottom: 0.5rem;
}

.ose-input,
.ose-textarea,
.ose-select {
  width: 100%;
  padding: 0.75rem;
  min-height: 44px;
  border: 1px solid rgba(234, 221, 214, 0.5);
  border-radius: 0.875rem;
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  font-size: 1rem; /* Prevents zoom on iOS */
  transition: all var(--transition-fast) var(--ease-soft);
  -webkit-appearance: none;
  appearance: none;
  touch-action: manipulation;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.04), 
              0 1px 2px rgba(0, 0, 0, 0.02);
}

.ose-input:focus,
.ose-textarea:focus,
.ose-select:focus {
  outline: none;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-color: rgba(227, 77, 46, 0.5);
  box-shadow: 0 0 0 3px rgba(227, 77, 46, 0.1), 
              0 4px 12px rgba(0, 0, 0, 0.08),
              0 2px 4px rgba(0, 0, 0, 0.04);
}

.ose-textarea {
  resize: vertical;
  min-height: 120px;
  font-family: inherit;
}

/* ============================================
   Swipe Gesture Indicator
   ============================================ */
.ose-swipe-indicator {
  position: absolute;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  width: 40px;
  height: 4px;
  background: #d1d5db;
  border-radius: 2px;
  z-index: 10;
  transition: background var(--transition-fast) var(--ease-soft);
}

.ose-modal-panel.swiping {
  transition: none !important;
  cursor: grabbing;
  /* Ensure smooth dragging performance */
  will-change: transform;
  /* CRITICAL: Do NOT set touch-action: none on panel - it blocks content scrolling */
  /* The content area needs touch-action: pan-y to allow scrolling */
}

/* CRITICAL: Content area must ALWAYS allow scrolling, even when panel is swiping */
.ose-modal-panel.swiping .ose-modal-content {
  /* Ensure content can still scroll even when panel is being dragged */
  touch-action: pan-y pinch-zoom !important;
  /* Override any parent touch-action restrictions */
  pointer-events: auto !important;
}

.ose-modal-panel.swiping .ose-swipe-indicator {
  background: #9ca3af;
  transition: background 0.2s ease;
}

/* ============================================
   Body Scroll Lock - iOS-Safe Method
   ============================================ */
/* CRITICAL: Do NOT use position:fixed on body - it breaks modal scrolling on iOS */
/* Use overflow:hidden only, which prevents background scroll while allowing modal scroll */
body.ose-modal-open,
html.ose-modal-open {
  overflow: hidden !important;
  /* Do NOT use position: fixed - it prevents scrolling inside modals on iOS */
  /* JavaScript handles scroll position storage/restoration */
}

/* Mobile-specific: Ensure overflow hidden works on all mobile browsers */
@media (max-width: 767px) {
  body.ose-modal-open,
  html.ose-modal-open {
    overflow: hidden !important;
    /* Height constraint to prevent scrolling on mobile */
    height: 100% !important;
    /* Do NOT use touch-action: none on body - it blocks all touches */
    /* Overflow hidden is sufficient to prevent background scroll */
  }
}

/* ============================================
   Loading State
   ============================================ */
.ose-modal-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 3rem;
  color: #6b7280;
}

/* ============================================
   Accessibility
   ============================================ */
.ose-modal-backdrop[aria-hidden="true"] {
  display: none;
}

.ose-modal-backdrop[aria-hidden="false"] {
  display: flex !important;
}

/* Focus trap - visible focus indicators */
.ose-modal-panel *:focus-visible {
  outline: 2px solid #E34D2E;
  outline-offset: 2px;
}

/* ============================================
   Animation States
   ============================================ */
.ose-modal-panel.closing {
  pointer-events: none;
}

@media (max-width: 767px) {
  .ose-modal-panel.bottom-sheet.closing {
    transform: translateY(100%);
  }

  .ose-modal-panel.full-screen.closing {
    transform: translateY(100%);
  }
}

@media (min-width: 768px) {
  .ose-modal-panel.closing {
    transform: translate(-50%, -50%) scale(0.1) !important;
    opacity: 0 !important;
    transition: transform var(--transition-normal) var(--ease-spring), 
                opacity var(--transition-normal) var(--ease-soft) !important;
  }
}

/* ============================================
   Prevent Content Shift When Modal Opens
   ============================================ */
/* When modal is open, body should not shift horizontally */
body.ose-modal-open {
  /* Padding compensation is applied via JavaScript */
  /* This CSS ensures smooth transitions */
  transition: padding-right 0.2s ease, margin-right 0.2s ease;
}

html.ose-modal-open,
body.ose-modal-open {
  /* Prevent horizontal scrollbar from appearing */
  overflow-x: hidden;
  /* Vertical scroll is locked by JavaScript */
  overflow-y: hidden;
}

/* Ensure main content doesn't shift */
body.ose-modal-open > * {
  /* Prevent any layout shifts */
  position: relative;
}

