/**
 * Mobile Bottom Navigation
 * Touch-optimized navigation for mobile devices
 */

/* ========================================
   BOTTOM NAVIGATION
   ======================================== */

.mobile-bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  background: var(--glass-bg);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-top: 1px solid var(--glass-border);
  padding: 8px 0;
  padding-bottom: calc(8px + env(safe-area-inset-bottom));
  z-index: var(--z-fixed);
  box-shadow: 0 -4px 24px var(--glass-shadow);
  transition: transform var(--transition-base);
}

/* Hide on desktop */
@media (min-width: 768px) {
  .mobile-bottom-nav {
    display: none;
  }
}

/* Hide when scrolling down (optional) */
.mobile-bottom-nav.hidden {
  transform: translateY(100%);
}

.mobile-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 4px 4px;
  min-height: 48px;
  border: none;
  background: transparent;
  color: var(--color-text-secondary);
  font-size: 0.75rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--transition-fast);
  position: relative;
  -webkit-tap-highlight-color: transparent;
}

.mobile-nav-item:active {
  transform: scale(0.92);
}

.mobile-nav-item.active {
  color: var(--color-primary);
}

.mobile-nav-item .nav-icon {
  font-size: 1.5rem;
  transition: transform var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  line-height: 1;
  overflow: visible;
  font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif;
}

.mobile-nav-item.active .nav-icon {
  transform: scale(1.15);
}

.mobile-nav-item .nav-label {
  font-size: 0.6875rem;
  letter-spacing: 0.01em;
}

/* Active indicator dot */
.mobile-nav-item.active::before {
  content: '';
  position: absolute;
  top: 6px;
  width: 4px;
  height: 4px;
  background: var(--color-primary);
  border-radius: 50%;
  animation: pulse-dot 2s ease-in-out infinite;
}

@keyframes pulse-dot {
  0%, 100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.6;
    transform: scale(1.2);
  }
}

/* Badge for notifications/counts */
.mobile-nav-item .nav-badge {
  position: absolute;
  top: 4px;
  right: calc(50% - 16px);
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-error);
  color: white;
  font-size: 0.625rem;
  font-weight: 600;
  border-radius: 9px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* ========================================
   CONTENT PADDING FOR BOTTOM NAV
   ======================================== */

/* Add padding to body to prevent content being hidden by bottom nav */
@media (max-width: 767px) {
  body {
    padding-bottom: 80px; /* Height of bottom nav + safe area */
  }
  
  /* Adjust for devices with safe areas */
  @supports (padding-bottom: env(safe-area-inset-bottom)) {
    body {
      padding-bottom: calc(80px + env(safe-area-inset-bottom));
    }
  }
}

/* ========================================
   FAB (Floating Action Button)
   ======================================== */

.fab {
  position: fixed;
  bottom: 90px; /* Above bottom nav */
  right: 16px;
  bottom: calc(90px + env(safe-area-inset-bottom));
  width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-primary);
  color: white;
  border: none;
  border-radius: 28px;
  font-size: 1.5rem;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.4);
  transition: all var(--transition-fast);
  z-index: var(--z-fixed);
}

.fab:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 16px rgba(37, 99, 235, 0.5);
}

.fab:active {
  transform: scale(0.95);
}

/* Hide FAB on desktop */
@media (min-width: 768px) {
  .fab {
    display: none;
  }
}

/* ========================================
   MOBILE PULL-TO-REFRESH INDICATOR
   ======================================== */

.pull-to-refresh {
  position: absolute;
  top: -60px;
  left: 50%;
  transform: translateX(-50%);
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: all var(--transition-base);
  pointer-events: none;
}

.pull-to-refresh.visible {
  opacity: 1;
  top: 20px;
}

.pull-to-refresh .spinner {
  width: 24px;
  height: 24px;
  border-width: 2px;
}

/* ========================================
   MOBILE GESTURES & INTERACTIONS
   ======================================== */

/* Swipe indicators */
.swipe-indicator {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  width: 40px;
  height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--glass-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
  border-radius: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-base);
  z-index: var(--z-popover);
}

.swipe-indicator.left {
  left: -50px;
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
}

.swipe-indicator.right {
  right: -50px;
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}

.swipe-indicator.show {
  opacity: 1;
}

.swipe-indicator.left.show {
  left: 0;
}

.swipe-indicator.right.show {
  right: 0;
}

/* ========================================
   HAPTIC FEEDBACK (Visual)
   ======================================== */

@keyframes haptic-pulse {
  0% {
    box-shadow: 0 0 0 0 var(--color-primary);
  }
  70% {
    box-shadow: 0 0 0 10px transparent;
  }
  100% {
    box-shadow: 0 0 0 0 transparent;
  }
}

.haptic-feedback {
  animation: haptic-pulse 0.4s ease-out;
}

/* ========================================
   BOTTOM SHEET (Modal alternative for mobile)
   ======================================== */

.bottom-sheet {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  max-height: 90vh;
  background: var(--color-surface);
  border-top-left-radius: var(--radius-2xl);
  border-top-right-radius: var(--radius-2xl);
  box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.2);
  transform: translateY(100%);
  transition: transform var(--transition-slow);
  z-index: var(--z-modal);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.bottom-sheet.open {
  transform: translateY(0);
}

.bottom-sheet-handle {
  width: 40px;
  height: 4px;
  margin: 12px auto;
  background: var(--color-border);
  border-radius: 2px;
  cursor: grab;
}

.bottom-sheet-handle:active {
  cursor: grabbing;
}

.bottom-sheet-content {
  flex: 1;
  overflow-y: auto;
  padding: 0 var(--space-lg) var(--space-lg);
  padding-bottom: calc(var(--space-lg) + env(safe-area-inset-bottom));
}

.bottom-sheet-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.4);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-base);
  z-index: calc(var(--z-modal) - 1);
}

.bottom-sheet-backdrop.open {
  opacity: 1;
  pointer-events: all;
}

/* ========================================
   MOBILE-SPECIFIC ADJUSTMENTS
   ======================================== */

/* Larger tap targets on mobile */
@media (max-width: 767px) {
  button,
  a,
  .btn,
  .card {
    min-height: 44px;
    min-width: 44px;
  }
  
  /* Increase font sizes slightly for better readability */
  body {
    font-size: 16px;
  }
  
  .text-small {
    font-size: 14px;
  }
  
  /* More spacing between interactive elements */
  .cards-grid {
    gap: 16px;
  }
}

/* iPhone X and newer - Safe area support */
@supports (padding: max(0px)) {
  .mobile-bottom-nav {
    padding-bottom: max(8px, env(safe-area-inset-bottom));
  }
  
  body {
    padding-bottom: max(80px, calc(80px + env(safe-area-inset-bottom)));
  }
}
