/*
 * Native App Styles - Enhancements for Capacitor/Native Apps
 * These styles add native-like behaviors WITHOUT overriding existing styles
 */

/* ========================================
   SYSTEM FONTS FALLBACK (When offline)
   Only applies if Google Fonts fail to load
   ======================================== */

/* Fonts are now self-hosted via /fonts/fonts.css — no CDN fallback needed */

/* ========================================
   NATIVE APP BEHAVIOR ENHANCEMENTS
   ======================================== */

/* Prevent text selection (native feel) - only for native app */
.is-native-app {
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

/* Allow text selection in input fields */
.is-native-app input,
.is-native-app textarea,
.is-native-app [contenteditable="true"] {
  -webkit-user-select: text;
  -moz-user-select: text;
  -ms-user-select: text;
  user-select: text;
}

/* Prevent pull-to-refresh on body (let app control it) */
.is-native-app body {
  overscroll-behavior-y: contain;
}

/* Remove tap highlight */
.is-native-app * {
  -webkit-tap-highlight-color: transparent;
}

/* Smooth scrolling */
.is-native-app {
  -webkit-overflow-scrolling: touch;
}

/* ========================================
   NATIVE-LIKE TOUCH INTERACTIONS
   ======================================== */

/* Button press effect - subtle */
.is-native-app button:active:not(:disabled),
.is-native-app [role="button"]:active {
  opacity: 0.85;
  transition: opacity 0.1s ease;
}

/* ========================================
   NATIVE SCROLLBAR STYLING
   ======================================== */

/* Hide scrollbars on native (like native apps) */
.is-native-app ::-webkit-scrollbar {
  width: 0;
  height: 0;
  display: none;
}

.is-native-app * {
  scrollbar-width: none;
  -ms-overflow-style: none;
}

/* ========================================
   NATIVE INPUT STYLING
   ======================================== */

/* Prevent iOS zoom on input focus */
.is-native-app input,
.is-native-app textarea,
.is-native-app select {
  font-size: 16px !important;
}

/* ========================================
   SMOOTH PAGE TRANSITIONS
   ======================================== */

.is-native-app .page-transition-enter {
  opacity: 0;
  transform: translateX(20px);
}

.is-native-app .page-transition-enter-active {
  opacity: 1;
  transform: translateX(0);
  transition: opacity 200ms ease-out, transform 200ms ease-out;
}

.is-native-app .page-transition-exit {
  opacity: 1;
  transform: translateX(0);
}

.is-native-app .page-transition-exit-active {
  opacity: 0;
  transform: translateX(-20px);
  transition: opacity 150ms ease-in, transform 150ms ease-in;
}

/* ========================================
   NATIVE MODAL ANIMATIONS
   ======================================== */

.is-native-app .modal-slide-up {
  animation: modalSlideUp 300ms cubic-bezier(0.32, 0.72, 0, 1);
}

.is-native-app .modal-slide-down {
  animation: modalSlideDown 250ms cubic-bezier(0.32, 0.72, 0, 1);
}

@keyframes modalSlideUp {
  from {
    transform: translateY(100%);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@keyframes modalSlideDown {
  from {
    transform: translateY(0);
    opacity: 1;
  }
  to {
    transform: translateY(100%);
    opacity: 0;
  }
}

/* ========================================
   NATIVE BOTTOM SHEET STYLING
   ======================================== */

.is-native-app .bottom-sheet {
  border-radius: 24px 24px 0 0;
  box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.2);
}

.is-native-app .bottom-sheet-handle {
  width: 36px;
  height: 5px;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 3px;
  margin: 8px auto 16px;
}

/* ========================================
   NATIVE CARD STYLING
   ======================================== */

.is-native-app .card-elevated {
  box-shadow: 
    0 1px 3px rgba(0, 0, 0, 0.08),
    0 4px 12px rgba(0, 0, 0, 0.05);
}

/* ========================================
   OFFLINE INDICATOR
   ======================================== */

.is-native-app .offline-banner {
  position: fixed;
  top: env(safe-area-inset-top, 0);
  left: 0;
  right: 0;
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  color: white;
  padding: 8px 16px;
  text-align: center;
  font-size: 14px;
  font-weight: 600;
  z-index: 9999;
}

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

/* Skeleton shimmer effect */
.is-native-app .skeleton-shimmer {
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0) 0%,
    rgba(255, 255, 255, 0.3) 50%,
    rgba(255, 255, 255, 0) 100%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Native loading spinner */
.is-native-app .native-spinner {
  width: 24px;
  height: 24px;
  border: 2px solid rgba(255, 106, 0, 0.2);
  border-top-color: #FF6A00;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* ========================================
   PERFORMANCE OPTIMIZATIONS
   ======================================== */

/* Hardware acceleration for animated elements */
.is-native-app [class*="animate"],
.is-native-app [class*="transition"] {
  will-change: transform, opacity;
  backface-visibility: hidden;
}

/* Reduce motion for accessibility */
@media (prefers-reduced-motion: reduce) {
  .is-native-app *,
  .is-native-app *::before,
  .is-native-app *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ========================================
   IMAGE HANDLING
   ======================================== */

/* Prevent image dragging */
.is-native-app img {
  -webkit-user-drag: none;
  user-drag: none;
}

/* ========================================
   TYPOGRAPHY ENHANCEMENTS
   ======================================== */

/* Better text rendering */
.is-native-app {
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Prevent font size adjustment on orientation change */
.is-native-app {
  -webkit-text-size-adjust: 100%;
  -moz-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

/* ========================================
   RIPPLE EFFECT (Android-style)
   ======================================== */

.is-native-app .ripple {
  position: relative;
  overflow: hidden;
}

.is-native-app .ripple::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  background: rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  opacity: 0;
}

.is-native-app .ripple:active::after {
  width: 200%;
  height: 200%;
  opacity: 1;
  transition: width 0.3s ease-out, height 0.3s ease-out, opacity 0.3s ease-out;
}

/* ========================================
   SAFE AREA UTILITIES
   ======================================== */

.is-native-app .safe-area-top {
  padding-top: env(safe-area-inset-top, 0);
}

.is-native-app .safe-area-bottom {
  padding-bottom: env(safe-area-inset-bottom, 0);
}

.is-native-app .safe-area-left {
  padding-left: env(safe-area-inset-left, 0);
}

.is-native-app .safe-area-right {
  padding-right: env(safe-area-inset-right, 0);
}
