/* iOS-Specific Styles for LevoroFit PWA */
/* Safe Area Insets, Touch Optimizations, and iOS Safari Fixes */

/* ============================================
   Safe Area Insets (Notch Support)
   ============================================ */
@supports (-webkit-touch-callout: none) {
  /* iPhone X and later - Safe area support */
  body {
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
  }
  
  /* Header adjustments for notch */
  header, nav {
    padding-top: calc(1rem + env(safe-area-inset-top));
  }
  
  /* Footer adjustments */
  footer {
    padding-bottom: calc(1rem + env(safe-area-inset-bottom));
  }
  
  /* Full-screen elements */
  .fullscreen,
  .full-height {
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
  }
  
  /* Fixed position elements */
  .fixed-top {
    top: env(safe-area-inset-top);
  }
  
  .fixed-bottom {
    bottom: env(safe-area-inset-bottom);
  }
}

/* ============================================
   iOS Touch Optimizations
   ============================================ */
@supports (-webkit-touch-callout: none) {
  /* Improve touch responsiveness */
  * {
    -webkit-tap-highlight-color: rgba(22, 163, 74, 0.2);
    -webkit-touch-callout: none;
  }
  
  /* Smooth scrolling */
  html {
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
  }
  
  /* Prevent text selection on buttons */
  button, .btn, .clickable {
    -webkit-user-select: none;
    user-select: none;
    touch-action: manipulation;
  }
  
  /* Optimize touch interactions */
  a, button, .btn, .clickable {
    touch-action: manipulation;
    -webkit-tap-highlight-color: rgba(22, 163, 74, 0.2);
  }
}

/* ============================================
   iOS Viewport Fixes
   ============================================ */
@supports (-webkit-touch-callout: none) {
  /* Fix 100vh issue on iOS Safari */
  .full-height {
    height: -webkit-fill-available;
    min-height: 100vh;
  }
  
  /* Fix viewport height for modals */
  .modal, .modal-content {
    max-height: -webkit-fill-available;
  }
}

/* ============================================
   Prevent iOS Input Zoom
   ============================================ */
@supports (-webkit-touch-callout: none) {
  /* Minimum 16px font size prevents zoom on focus */
  input, textarea, select {
    font-size: 16px !important;
  }
  
  /* For smaller text inputs, use 16px minimum */
  input[type="text"],
  input[type="email"],
  input[type="password"],
  input[type="number"],
  input[type="tel"],
  input[type="url"],
  textarea {
    font-size: 16px;
  }
}

/* ============================================
   Prevent iOS Bounce Scroll (Optional)
   ============================================ */
/* Uncomment if you want to prevent bounce scroll */
/*
@supports (-webkit-touch-callout: none) {
  body {
    position: fixed;
    width: 100%;
    height: 100%;
    overflow: hidden;
  }
  
  .main-content {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
}
*/

/* ============================================
   iOS Status Bar Styling
   ============================================ */
@supports (-webkit-touch-callout: none) {
  /* Status bar area styling */
  .status-bar-area {
    background-color: #16a34a;
    height: env(safe-area-inset-top);
    width: 100%;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 9999;
  }
}

/* ============================================
   iOS Standalone Mode Styles
   ============================================ */
@media all and (display-mode: standalone) {
  /* Styles when app is in standalone mode (added to home screen) */
  body {
    /* Remove browser UI space */
    padding-top: env(safe-area-inset-top);
  }
  
  /* Hide browser chrome elements if any */
  .browser-only {
    display: none;
  }
}

/* ============================================
   iOS Safari Specific Fixes
   ============================================ */
@supports (-webkit-touch-callout: none) {
  /* Fix for iOS Safari address bar */
  .viewport-fix {
    min-height: 100vh;
    min-height: -webkit-fill-available;
  }
  
  /* Fix for iOS Safari bottom bar */
  .bottom-safe {
    padding-bottom: calc(1rem + env(safe-area-inset-bottom));
  }
  
  /* Fix for iOS Safari form elements */
  select {
    -webkit-appearance: none;
    appearance: none;
  }
  
  /* Fix for iOS Safari date inputs */
  input[type="date"],
  input[type="time"],
  input[type="datetime-local"] {
    -webkit-appearance: none;
    appearance: none;
  }
}

/* ============================================
   iOS Animation Optimizations
   ============================================ */
@supports (-webkit-touch-callout: none) {
  /* Optimize animations for iOS */
  * {
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
  }
  
  /* Smooth transitions */
  * {
    -webkit-transition: all 0.3s ease;
    transition: all 0.3s ease;
  }
}

/* ============================================
   iOS Keyboard Handling
   ============================================ */
@supports (-webkit-touch-callout: none) {
  /* Adjust layout when keyboard is visible */
  body.keyboard-open {
    padding-bottom: env(safe-area-inset-bottom);
  }
  
  /* Fix for input focus on iOS */
  input:focus,
  textarea:focus,
  select:focus {
    -webkit-appearance: none;
    appearance: none;
    outline: none;
  }
}

/* ============================================
   iOS Share Sheet Styling
   ============================================ */
@supports (-webkit-touch-callout: none) {
  /* Style for share buttons */
  .share-button {
    -webkit-tap-highlight-color: rgba(22, 163, 74, 0.3);
    touch-action: manipulation;
  }
}

/* ============================================
   iOS Loading States
   ============================================ */
@supports (-webkit-touch-callout: none) {
  /* Optimize loading indicators */
  .loading,
  .spinner {
    -webkit-animation: spin 1s linear infinite;
    animation: spin 1s linear infinite;
  }
  
  @keyframes spin {
    from {
      -webkit-transform: rotate(0deg);
      transform: rotate(0deg);
    }
    to {
      -webkit-transform: rotate(360deg);
      transform: rotate(360deg);
    }
  }
}

/* ============================================
   iOS Scrollbar Styling
   ============================================ */
@supports (-webkit-touch-callout: none) {
  /* Custom scrollbar for iOS */
  ::-webkit-scrollbar {
    width: 8px;
    height: 8px;
  }
  
  ::-webkit-scrollbar-track {
    background: #f1f1f1;
  }
  
  ::-webkit-scrollbar-thumb {
    background: #16a34a;
    border-radius: 4px;
  }
  
  ::-webkit-scrollbar-thumb:hover {
    background: #15803d;
  }
}

/* ============================================
   iOS PWA Install Prompt
   ============================================ */
.ios-install-prompt {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: white;
  border-top: 1px solid #e5e7eb;
  padding: 20px;
  padding-bottom: calc(20px + env(safe-area-inset-bottom));
  box-shadow: 0 -4px 6px rgba(0, 0, 0, 0.1);
  z-index: 1000;
  display: none;
}

.ios-install-prompt.show {
  display: block;
}

.ios-install-content h3 {
  margin: 0 0 10px 0;
  font-size: 18px;
  font-weight: 600;
  color: #1f2937;
}

.ios-install-steps {
  margin: 15px 0;
  font-size: 14px;
  color: #6b7280;
}

.ios-install-steps p {
  margin: 8px 0;
}

.share-icon {
  font-size: 18px;
  vertical-align: middle;
}

.ios-install-prompt button {
  margin-top: 15px;
  padding: 10px 20px;
  background-color: #16a34a;
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 16px;
  cursor: pointer;
  width: 100%;
}

.ios-install-prompt button:hover {
  background-color: #15803d;
}

