/*
 * FIDELIS - Premium Mobile Navigation
 * Modern glassmorphism design with smooth animations
 */

/* ============================================
   PREMIUM MOBILE NAVIGATION
   ============================================ */

@media (max-width: 768px) {
  /* Hide desktop FAB on mobile (we use the nav center button) */
  .fab {
    display: none !important;
  }

  /* Premium Bottom Navigation */
  .mobile-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 80px;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 -4px 30px rgba(0, 0, 0, 0.08),
                0 -1px 10px rgba(0, 0, 0, 0.05);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 0 16px;
    padding-bottom: env(safe-area-inset-bottom, 8px);
  }

  [data-theme="dark"] .mobile-nav {
    background: rgba(15, 23, 42, 0.9);
    border-top-color: rgba(255, 255, 255, 0.05);
  }

  .mobile-nav-list {
    display: flex;
    justify-content: space-around;
    align-items: center;
    width: 100%;
    max-width: 420px;
    height: 100%;
    list-style: none;
    padding: 0;
    margin: 0;
    position: relative;
  }

  .mobile-nav-item {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
  }

  /* Regular Nav Items */
  .mobile-nav-link {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 8px 12px;
    color: #64748B;
    text-decoration: none;
    font-size: 11px;
    font-weight: 500;
    border-radius: 16px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    min-width: 56px;
    height: 56px;
  }

  [data-theme="dark"] .mobile-nav-link {
    color: #94A3B8;
  }

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

  /* Icon container */
  .mobile-nav-icon-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    transition: all 0.3s ease;
  }

  .mobile-nav-icon {
    width: 24px;
    height: 24px;
    stroke-width: 1.5;
    transition: all 0.3s ease;
  }

  /* Active state for regular items */
  .mobile-nav-link.active {
    color: #3B82F6;
  }

  [data-theme="dark"] .mobile-nav-link.active {
    color: #60A5FA;
  }

  .mobile-nav-link.active .mobile-nav-icon-wrapper {
    transform: translateY(-2px);
  }

  .mobile-nav-link.active .mobile-nav-icon {
    stroke-width: 2;
    filter: drop-shadow(0 2px 4px rgba(59, 130, 246, 0.3));
  }

  /* Active indicator dot */
  .mobile-nav-link::after {
    content: '';
    position: absolute;
    bottom: 4px;
    left: 50%;
    transform: translateX(-50%) scale(0);
    width: 4px;
    height: 4px;
    background: #3B82F6;
    border-radius: 50%;
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  }

  .mobile-nav-link.active::after {
    transform: translateX(-50%) scale(1);
  }

  /* Notification badge */
  .mobile-nav-badge {
    position: absolute;
    top: 2px;
    right: 2px;
    min-width: 18px;
    height: 18px;
    background: linear-gradient(135deg, #EF4444, #DC2626);
    color: white;
    font-size: 10px;
    font-weight: 700;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid rgba(255, 255, 255, 0.9);
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.4);
    animation: badgePulse 2s infinite;
    padding: 0 4px;
  }

  @keyframes badgePulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
  }

  /* ===== CENTER ACTION BUTTON (The "Cool" Button) ===== */
  .mobile-nav-item.center {
    position: relative;
    z-index: 2;
  }

  .mobile-nav-link.center-btn {
    position: relative;
    width: 64px;
    height: 64px;
    margin-top: -32px;
    background: linear-gradient(135deg, #3B82F6 0%, #8B5CF6 50%, #EC4899 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow:
      0 8px 32px rgba(59, 130, 246, 0.4),
      0 4px 16px rgba(139, 92, 246, 0.3),
      inset 0 1px 1px rgba(255, 255, 255, 0.3);
    border: 3px solid rgba(255, 255, 255, 0.9);
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    overflow: hidden;
  }

  [data-theme="dark"] .mobile-nav-link.center-btn {
    border-color: rgba(30, 41, 59, 0.9);
    box-shadow:
      0 8px 32px rgba(59, 130, 246, 0.5),
      0 4px 16px rgba(139, 92, 246, 0.4),
      inset 0 1px 1px rgba(255, 255, 255, 0.2);
  }

  .mobile-nav-link.center-btn::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255,255,255,0.3), transparent);
    border-radius: 50%;
  }

  /* Shine effect */
  .mobile-nav-link.center-btn::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(
      45deg,
      transparent 40%,
      rgba(255, 255, 255, 0.3) 50%,
      transparent 60%
    );
    animation: shine 3s infinite;
  }

  @keyframes shine {
    0% { transform: translateX(-100%) rotate(45deg); }
    100% { transform: translateX(100%) rotate(45deg); }
  }

  .mobile-nav-link.center-btn:hover {
    transform: scale(1.08) translateY(-4px);
    box-shadow:
      0 12px 40px rgba(59, 130, 246, 0.5),
      0 6px 20px rgba(139, 92, 246, 0.4);
  }

  .mobile-nav-link.center-btn:active {
    transform: scale(0.95);
  }

  .center-btn-icon {
    width: 28px;
    height: 28px;
    color: white;
    stroke-width: 2.5;
    position: relative;
    z-index: 1;
    transition: transform 0.3s ease;
  }

  .mobile-nav-link.center-btn:hover .center-btn-icon {
    transform: rotate(90deg);
  }

  /* Ripple effect on click */
  .mobile-nav-link.center-btn .ripple {
    position: absolute;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.5);
    transform: scale(0);
    animation: rippleEffect 0.6s ease-out;
    pointer-events: none;
  }

  @keyframes rippleEffect {
    to {
      transform: scale(4);
      opacity: 0;
    }
  }

  /* Wave animation around center button */
  .mobile-nav-item.center::before,
  .mobile-nav-item.center::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 64px;
    height: 64px;
    border-radius: 50%;
    border: 2px solid rgba(59, 130, 246, 0.3);
    animation: waveExpand 2s infinite;
    pointer-events: none;
  }

  .mobile-nav-item.center::after {
    animation-delay: 1s;
  }

  @keyframes waveExpand {
    0% {
      transform: translate(-50%, -50%) scale(1);
      opacity: 1;
    }
    100% {
      transform: translate(-50%, -50%) scale(1.5);
      opacity: 0;
    }
  }

  /* Haptic feedback simulation */
  .mobile-nav-link {
    -webkit-tap-highlight-color: transparent;
  }
}

/* ============================================
   QUICK ACTION MENU (Floating)
   ============================================ */

.quick-actions-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  z-index: 999;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

.quick-actions-overlay.open {
  opacity: 1;
  visibility: visible;
}

.quick-actions-menu {
  position: fixed;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%) translateY(20px) scale(0.9);
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(20px);
  border-radius: 24px;
  padding: 20px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  z-index: 1001;
  opacity: 0;
  visibility: hidden;
  transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  min-width: 280px;
}

[data-theme="dark"] .quick-actions-menu {
  background: rgba(30, 41, 59, 0.95);
}

.quick-actions-menu.open {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0) scale(1);
}

.quick-action-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 16px 12px;
  border-radius: 16px;
  text-decoration: none;
  color: #475569;
  transition: all 0.2s ease;
}

.quick-action-item:hover {
  background: rgba(59, 130, 246, 0.1);
  color: #3B82F6;
  transform: translateY(-2px);
}

.quick-action-icon {
  width: 48px;
  height: 48px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
}

.quick-action-item.sleep .quick-action-icon {
  background: linear-gradient(135deg, #DBEAFE, #BFDBFE);
}

.quick-action-item.health .quick-action-icon {
  background: linear-gradient(135deg, #D1FAE5, #A7F3D0);
}

.quick-action-item.vaccine .quick-action-icon {
  background: linear-gradient(135deg, #FEF3C7, #FDE68A);
}

.quick-action-label {
  font-size: 12px;
  font-weight: 500;
}

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

.ptr-indicator {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #3B82F6, #8B5CF6);
  color: white;
  font-size: 14px;
  font-weight: 500;
  transform: translateY(-100%);
  transition: transform 0.3s ease;
  z-index: 999;
}

.ptr-indicator.visible {
  transform: translateY(0);
}

.ptr-indicator-spinner {
  width: 20px;
  height: 20px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-right: 8px;
}

/* ============================================
   MOBILE CARD IMPROVEMENTS
   ============================================ */

@media (max-width: 768px) {
  .card {
    border-radius: 20px;
    margin-bottom: 16px;
  }

  .stat-card {
    padding: 20px;
    border-radius: 20px;
  }

  .stat-card-value {
    font-size: 28px;
  }

  /* Touch-friendly buttons */
  .btn {
    min-height: 48px;
    padding: 12px 24px;
  }

  .btn-full {
    width: 100%;
  }

  /* Form improvements */
  .form-input,
  .form-select,
  .form-textarea {
    min-height: 48px;
    font-size: 16px; /* Prevents iOS zoom */
    padding: 12px 16px;
    border-radius: 12px;
  }

  /* Swipeable cards */
  .swipe-card {
    touch-action: pan-y;
    user-select: none;
  }

  /* Bottom sheet modal */
  .modal {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    top: auto;
    max-width: 100%;
    width: 100%;
    border-radius: 24px 24px 0 0;
    max-height: 90vh;
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  }

  .modal-overlay.open .modal {
    transform: translateY(0);
  }

  /* Improved scrollbar for mobile */
  ::-webkit-scrollbar {
    width: 4px;
    height: 4px;
  }

  /* Hide scrollbar but keep functionality */
  .hide-scrollbar {
    -ms-overflow-style: none;
    scrollbar-width: none;
  }

  .hide-scrollbar::-webkit-scrollbar {
    display: none;
  }

  /* Horizontal scroll container */
  .horizontal-scroll {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    padding: 4px;
    margin: 0 -16px;
    padding: 0 16px;
  }

  .horizontal-scroll > * {
    scroll-snap-align: start;
    flex-shrink: 0;
  }
}

/* ============================================
   DARK MODE MOBILE ADJUSTMENTS
   ============================================ */

[data-theme="dark"] .mobile-nav {
  background: rgba(15, 23, 42, 0.9);
}

[data-theme="dark"] .quick-actions-menu {
  background: rgba(30, 41, 59, 0.95);
}

[data-theme="dark"] .quick-action-item {
  color: #94A3B8;
}

[data-theme="dark"] .quick-action-item:hover {
  background: rgba(59, 130, 246, 0.15);
  color: #60A5FA;
}
