/* ============================================
   iOS Native Experience Styles
   ============================================ */

/* Prevent text selection and callouts */
* {
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

input, textarea {
  -webkit-user-select: auto;
  user-select: auto;
}

/* ============================================
   Base styles (all screen sizes)
   ============================================ */
html {
  background: #0a0a0b;
  touch-action: manipulation;
  -webkit-text-size-adjust: 100%;
}

body {
  background: #0a0a0b;
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* Safe area variables */
:root {
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --tab-bar-height: calc(50px + var(--safe-bottom));
}

/* ============================================
   Tab Bar - Fixed to absolute bottom
   ============================================ */
.ios-tab-bar {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: #141416;
  border-top: 0.5px solid rgba(255, 255, 255, 0.1);
  padding-bottom: var(--safe-bottom);
  z-index: 9999;
}

.ios-tab-bar-inner {
  display: flex;
  justify-content: space-evenly;
  align-items: flex-start;
  height: 50px;
  width: 100%;
}

.ios-tab-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 2px;
  padding: 8px 0 4px 0;
  text-decoration: none;
  color: #8e8e93;
  transition: color 0.15s;
  flex: 1;
  position: relative;
  touch-action: manipulation;
  cursor: pointer;
}

.ios-tab-item svg {
  width: 24px;
  height: 24px;
  stroke-width: 1.5;
}

.ios-tab-item.active {
  color: #ff4d4d;
}

.ios-tab-item.active svg {
  stroke-width: 2;
}

.ios-tab-label {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: -0.2px;
}

.ios-tab-badge {
  position: absolute;
  top: 4px;
  right: 50%;
  transform: translateX(14px);
  min-width: 18px;
  height: 18px;
  background: #ff3b30;
  border-radius: 9px;
  font-size: 11px;
  font-weight: 600;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
}

/* ============================================
   More Menu (Action Sheet)
   ============================================ */
.ios-more-menu {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10000;
}

.ios-more-menu.open {
  display: block;
}

.ios-more-menu-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
}

.ios-more-menu-sheet {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: #1c1c1e;
  border-radius: 12px 12px 0 0;
  padding-bottom: var(--safe-bottom);
}

.ios-more-menu-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 0.5px solid rgba(255, 255, 255, 0.1);
  font-weight: 600;
  font-size: 17px;
}

.ios-more-menu-header button {
  background: none;
  border: none;
  color: #ff4d4d;
  font-size: 17px;
  cursor: pointer;
}

.ios-more-menu-item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 20px;
  color: #fff;
  text-decoration: none;
  font-size: 17px;
  border-bottom: 0.5px solid rgba(255, 255, 255, 0.05);
}

.ios-more-menu-item svg {
  width: 24px;
  height: 24px;
  opacity: 0.7;
}

.ios-more-menu-item:active {
  background: rgba(255, 255, 255, 0.05);
}

.ios-more-menu-item-danger {
  color: #ff453a;
}

.ios-more-menu-divider {
  height: 8px;
  background: rgba(0, 0, 0, 0.3);
}

/* ============================================
   Pull to Refresh Spinner
   ============================================ */
#ptr-spinner {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  width: 28px;
  height: 28px;
  color: #ff4d4d;
  opacity: 0;
  z-index: 100;
  pointer-events: none;
  transition: opacity 0.15s;
}

#ptr-spinner svg {
  width: 100%;
  height: 100%;
}

/* ============================================
   Mobile Layout
   ============================================ */
@media (max-width: 768px) {
  /* CRITICAL: Prevent iOS overscroll gaps on mobile only */
  html {
    height: 100%;
    overflow: hidden;
  }
  
  body {
    height: 100%;
    overflow: hidden;
  }
  
  .ios-tab-bar {
    display: flex !important;
    flex-direction: column;
  }
  
  .sidebar {
    display: none !important;
  }
  
  .mobile-header,
  .mobile-nav,
  .mobile-nav-overlay {
    display: none !important;
  }
  
  /* Main content is the ONLY thing that scrolls */
  .main-content {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: var(--tab-bar-height) !important;
    margin: 0 !important;
    padding: calc(var(--safe-top) + 16px) 16px 24px 16px !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    -webkit-overflow-scrolling: touch;
    background: #0a0a0b !important;
  }
  
  .app-container {
    min-height: auto !important;
    overflow: visible !important;
  }
}

/* ============================================
   Utility Classes
   ============================================ */
.haptic-light,
.haptic-medium,
.haptic-heavy {
  cursor: pointer;
}

.skeleton {
  background: linear-gradient(90deg, rgba(255,255,255,0.05) 25%, rgba(255,255,255,0.1) 50%, rgba(255,255,255,0.05) 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s infinite;
  border-radius: 8px;
}

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