/**
 * Mobile Swipe Gestures CSS
 * 
 * Visual feedback for edge swipe gestures on mobile
 */

/* ==========================================================================
   Swipe Feedback Edge Glow
   ========================================================================== */
.swipe-feedback {
  position: fixed;
  top: 0;
  bottom: 0;
  width: 100px;
  pointer-events: none;
  z-index: 9999;
  opacity: 0;
  transition: opacity 0.15s ease-out, width 0.15s ease-out;
}

.swipe-feedback[data-edge="left"] {
  left: 0;
  background: linear-gradient(to right, 
    rgba(59, 130, 246, 0.4) 0%, 
    rgba(59, 130, 246, 0.1) 50%,
    transparent 100%
  );
}

.swipe-feedback[data-edge="right"] {
  right: 0;
  background: linear-gradient(to left, 
    rgba(168, 85, 247, 0.4) 0%, 
    rgba(168, 85, 247, 0.1) 50%,
    transparent 100%
  );
}

/* ==========================================================================
   Swipe Hints (First-time user guidance)
   ========================================================================== */
.swipe-hint {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  padding: 12px 20px;
  background: rgba(10, 10, 10, 0.9);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  color: #fff;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.3px;
  border-radius: 12px;
  z-index: 10000;
  opacity: 0;
  transition: opacity 0.5s ease, transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: none;
  box-shadow: 
    0 8px 32px rgba(0, 0, 0, 0.4),
    0 2px 8px rgba(0, 0, 0, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.swipe-hint-left {
  left: 10px;
}

.swipe-hint-right {
  right: 10px;
}

.swipe-hint span {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ==========================================================================
   Edge Touch Zones (Visual debug - normally hidden)
   ========================================================================== */
.edge-touch-zone {
  position: fixed;
  top: 0;
  bottom: 0;
  width: 40px;
  background: transparent;
  z-index: 9990;
  pointer-events: none;
}

.edge-touch-zone.left {
  left: 0;
}

.edge-touch-zone.right {
  right: 0;
}

/* Debug mode - shows touch zones */
body.debug-swipe .edge-touch-zone {
  background: rgba(255, 0, 0, 0.1);
}

/* ==========================================================================
   Panel Transition Enhancements
   ========================================================================== */
@media (max-width: 768px) {
  /* Smoother sidebar animation on mobile */
  .sidebar {
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
  }
  
  .sidebar.open {
    transform: translateX(0) !important;
  }
  
  .sidebar:not(.open) {
    transform: translateX(-100%) !important;
  }
  
  /* Smoother generations panel animation on mobile */
  .generations-panel {
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
  }
  
  .generations-panel.open {
    transform: translateX(0) !important;
  }
  
  .generations-panel:not(.open) {
    transform: translateX(100%) !important;
  }
  
  /* Overlay animations */
  .sidebar-overlay,
  .generations-panel-backdrop {
    transition: opacity 0.3s ease !important;
  }
}

/* ==========================================================================
   Block Browser Back/Forward Navigation Gestures (Desktop + Mobile)
   ========================================================================== */

/* Desktop: Block trackpad swipe navigation */
html, body {
  overscroll-behavior-x: none;
  overscroll-behavior: none;
}

/* All main containers - block horizontal overscroll */
.main-content,
.editor-container,
.canvas-container,
.freeform-container,
.chat-container,
#mainContent,
#editorContainer,
#canvasContainer {
  overscroll-behavior-x: none;
  overscroll-behavior: none;
}

/* Critical: Drawing/Editor areas must block all navigation */
canvas,
.drawing-canvas,
.editor-canvas,
#drawingCanvas,
#editorCanvas,
.freeform-canvas,
.freeform-container canvas {
  touch-action: none;
  overscroll-behavior: none;
  /* Prevent any browser gestures while drawing */
  -webkit-user-select: none;
  user-select: none;
}

/* Mobile-specific adjustments */
@media (max-width: 768px) {
  html {
    overscroll-behavior-y: contain;
  }
  
  .chat-container,
  .main-content,
  .chat-messages,
  #chatMessagesV2,
  #mainContent {
    overscroll-behavior-y: contain;
    touch-action: pan-y pinch-zoom;
  }
}

/* iOS-specific fixes */
@supports (-webkit-touch-callout: none) {
  /* iOS Safari */
  html {
    /* Disable elastic overscroll which enables navigation gestures */
    overscroll-behavior: none;
    height: 100%;
  }
  
  body {
    overscroll-behavior: none;
    height: 100%;
    /* Fixed positioning helps prevent edge swipes */
    position: fixed;
    width: 100%;
    overflow: hidden;
  }
  
  .main-content {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: none;
  }
  
  /* Ensure chat container scrolls properly */
  .chat-container {
    height: 100%;
    overflow: hidden;
  }
  
  .chat-messages,
  #chatMessagesV2 {
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: contain;
    overscroll-behavior-x: none;
  }
}

/* ==========================================================================
   Reduced Motion Support
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
  .swipe-feedback,
  .swipe-hint {
    transition: opacity 0.1s ease;
  }
  
  .sidebar,
  .generations-panel {
    transition: transform 0.15s ease !important;
  }
}
