/* iOS PWA Touch Fixes - حل مشکل دکمه‌های غیرفعال در iOS PWA */

/* Fix for touch events on iOS */
* {
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
}

/* Allow text selection in input fields and text areas */
input,
textarea,
[contenteditable] {
  -webkit-user-select: auto;
  user-select: auto;
  touch-action: auto;
}

/* Fix for buttons and clickable elements */
button,
a,
[role="button"],
[onclick],
.flutter-button,
.MaterialButton,
.ElevatedButton,
.OutlinedButton,
.TextButton {
  touch-action: manipulation;
  cursor: pointer;
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
  -webkit-touch-callout: none;
}

/* Fix for Flutter widgets */
.flutter-view,
.flutter-container {
  touch-action: manipulation;
}

/* Prevent 300ms delay on iOS */
html {
  touch-action: manipulation;
}

body {
  touch-action: manipulation;
  -webkit-overflow-scrolling: touch;
}

/* Fix for overlay elements that might block touches */
.overlay,
.modal,
.dialog,
.bottom-sheet {
  touch-action: manipulation;
  pointer-events: auto;
}

/* Fix for scrollable areas */
.scrollable,
.list-view,
.scroll-view {
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
}

/* Fix for interactive elements */
input[type="button"],
input[type="submit"],
input[type="reset"],
input[type="checkbox"],
input[type="radio"],
select {
  touch-action: manipulation;
  cursor: pointer;
}

/* Ensure all clickable elements work */
[data-clickable="true"],
.clickable {
  touch-action: manipulation;
  cursor: pointer;
  pointer-events: auto;
}

/* Fix for Material Design buttons */
.mdc-button,
.mat-button,
.mat-raised-button,
.mat-flat-button,
.mat-stroked-button {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

/* Prevent text selection on buttons - but allow pointer events for better touch */
button *,
a *,
[role="button"] * {
  -webkit-user-select: none;
  user-select: none;
  pointer-events: auto; /* Changed from none to auto for better touch handling */
}

/* Fix for GestureDetector and InkWell in Flutter */
.gesture-detector,
.ink-well {
  touch-action: manipulation;
}

/* Fix for disabled state */
button:disabled,
a:disabled,
[disabled] {
  touch-action: none;
  pointer-events: none;
  opacity: 0.6;
}

/* Critical fixes for iOS PWA standalone mode - CanvasKit/Skwasm compatible */
@media (display-mode: standalone) {
  /* Ensure all Flutter canvas elements are touchable */
  canvas {
    touch-action: manipulation !important;
    pointer-events: auto !important;
    -webkit-tap-highlight-color: transparent !important;
    -webkit-touch-callout: none !important;
    -webkit-user-select: none !important;
    user-select: none !important;
    position: relative !important;
    z-index: 1 !important;
    cursor: pointer !important;
    -webkit-touch-action: manipulation !important;
  }
  
  /* Fix for Flutter view containers (Skwasm/CanvasKit) */
  flt-scene-host,
  flt-glass-pane,
  flt-semantics-host,
  flt-semantics,
  .flutter-view,
  .flutter-container,
  [class*="flutter"],
  [id*="flutter"],
  [data-flutter-view] {
    touch-action: manipulation !important;
    pointer-events: auto !important;
    -webkit-tap-highlight-color: transparent !important;
    -webkit-touch-action: manipulation !important;
    cursor: pointer !important;
  }
  
  /* Ensure buttons work even with nested elements */
  button,
  a,
  [role="button"],
  [onclick] {
    touch-action: manipulation !important;
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1) !important;
    position: relative !important;
    z-index: 1 !important;
    -webkit-touch-action: manipulation !important;
    cursor: pointer !important;
  }
  
  /* Fix for nested clickable content */
  button > *,
  a > *,
  [role="button"] > *,
  [onclick] > * {
    pointer-events: auto !important;
    touch-action: manipulation !important;
    -webkit-touch-action: manipulation !important;
  }
  
  /* Fix for Skwasm renderer specific elements */
  [data-flutter-view],
  [data-flutter-renderer] {
    touch-action: manipulation !important;
    pointer-events: auto !important;
    -webkit-touch-action: manipulation !important;
  }
  
  /* Force touch handling on all interactive Flutter elements */
  canvas,
  flt-scene-host,
  flt-glass-pane {
    -webkit-user-select: none !important;
    user-select: none !important;
    -webkit-touch-callout: none !important;
  }
}

