/**
 * Mobile Bottom Navigation Bar Styles
 *
 * Design principles:
 * - Fixed position at bottom of screen
 * - Mobile-only (hidden on XL+ screens)
 * - Consistent with design system (Tabler icons, primary color)
 * - RTL support
 * - Smooth animations
 * - iOS safe area support
 */

/* ============================================
   Mobile Bottom Navigation Container
   ============================================ */

.mobile-bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  width: 100%;
  margin: 0;
  /* Blurred background effect similar to navbar */
  backdrop-filter: saturate(200%) blur(10px);
  background: linear-gradient(0deg, rgba(var(--bs-body-bg-rgb), 85%) 44%, rgba(var(--bs-body-bg-rgb), 70%) 73%, rgba(var(--bs-body-bg-rgb), 0.3));
  border-top: 1px solid rgba(var(--bs-border-color-rgb), 0.3);
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.08);
  z-index: 1101; /* Above sidebar menu (max 1100) and all overlays, below modals (1055+) */
  padding-bottom: env(safe-area-inset-bottom); /* iOS safe area for home indicator */
  transition: transform var(--animation-duration-normal) var(--animation-ease-out), bottom 0.15s ease-out;
  /* Force hardware acceleration for smooth iOS Safari behavior */
  transform: translateZ(0);
  -webkit-transform: translateZ(0);
  /* Ensure no extra spacing */
  box-sizing: border-box;
}

/* Hide on desktop (XL and above - 1200px+) */
@media (min-width: 1200px) {
  .mobile-bottom-nav {
    display: none !important;
  }
}

/* Dark mode support */
[data-bs-theme="dark"] .mobile-bottom-nav {
  backdrop-filter: saturate(200%) blur(10px);
  background: linear-gradient(0deg, rgba(var(--bs-body-bg-rgb), 85%) 44%, rgba(var(--bs-body-bg-rgb), 70%) 73%, rgba(var(--bs-body-bg-rgb), 0.3));
  border-top-color: rgba(var(--bs-border-color-rgb), 0.2);
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.3);
}

/* Navigation container with flexible layout */
.mobile-bottom-nav-container {
  display: flex;
  justify-content: space-around;
  align-items: center;
  padding: 0.25rem 0.75rem;
  width: 100%; /* Full width like sidebar */
  gap: 0.5rem;
}

/* Home button always stays in first position (start) */
.mobile-bottom-nav-btn.home-btn {
  order: -1; /* Always first regardless of direction */
}

/* No flex-direction changes for RTL - natural order maintained */
/* RTL/LTR handled automatically by flex direction */

/* ============================================
   Navigation Buttons
   ============================================ */

.mobile-bottom-nav-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.125rem;
  padding: 0.375rem 0.5rem;
  border: none;
  background: transparent;
  color: var(--bs-secondary);
  border-radius: var(--bs-border-radius-lg);
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: all var(--animation-duration-fast) var(--animation-ease-out);
  flex: 1;
  max-width: 120px;
  min-width: 60px;
  -webkit-tap-highlight-color: transparent;
}

/* Home button styling - distinct from dynamic buttons */
.mobile-bottom-nav-btn.home-btn {
  color: inherit; /* Default color, not primary */
}

/* Home button active state - only when sidebar is expanded */
.mobile-bottom-nav-btn.home-btn.active {
  color: var(--bs-primary);
}

/* Separator after home button */
.mobile-bottom-nav-btn.home-btn::after {
  content: '';
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 1px;
  height: 50%;
  background: var(--bs-border-color);
  opacity: 0.6;
}

/* RTL: Move separator to left side */
[dir="rtl"] .mobile-bottom-nav-btn.home-btn::after {
  right: auto;
  left: 0;
}

/* Icon container */
.mobile-bottom-nav-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--bs-border-radius);
  transition: all var(--animation-duration-fast) var(--animation-ease-out);
  position: relative;
  z-index: 1;
}

.mobile-bottom-nav-icon i {
  font-size: 22px;
  transition: all var(--animation-duration-fast) var(--animation-ease-out);
}

/* Label styling */
.mobile-bottom-nav-label {
  font-size: 0.625rem;
  font-weight: 500;
  text-align: center;
  transition: all var(--animation-duration-fast) var(--animation-ease-out);
  line-height: 1.2;
  position: relative;
  z-index: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

/* ============================================
   Button States
   ============================================ */

/* Hover state */
.mobile-bottom-nav-btn:hover {
  background: rgba(var(--bs-primary-rgb), 0.08);
  color: var(--bs-primary);
  transform: translateY(-2px);
}

.mobile-bottom-nav-btn.home-btn:hover {
  background: rgba(var(--bs-primary-rgb), 0.08);
}

.mobile-bottom-nav-btn:hover .mobile-bottom-nav-icon {
  transform: scale(1.1);
}

/* Active/Click state */
.mobile-bottom-nav-btn:active,
.mobile-bottom-nav-btn.clicked {
  transform: scale(0.95) translateY(0);
  background: rgba(var(--bs-primary-rgb), 0.15);
}

/* Focus state for accessibility */
.mobile-bottom-nav-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(var(--bs-primary-rgb), 0.3);
}


/* Disabled state */
.mobile-bottom-nav-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

/* ============================================
   Badge Styling
   ============================================ */

.mobile-nav-badge {
  position: absolute;
  top: 0.25rem;
  right: 0.25rem;
  min-width: 1.25rem;
  height: 1.25rem;
  padding: 0.125rem 0.375rem;
  font-size: 0.625rem;
  font-weight: 600;
  line-height: 1;
  border-radius: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* RTL badge positioning */
[dir="rtl"] .mobile-nav-badge {
  right: auto;
  left: 0.25rem;
}

/* ============================================
   Ripple Effect
   ============================================ */

.mobile-nav-ripple {
  position: absolute;
  border-radius: 50%;
  background: rgba(var(--bs-primary-rgb), 0.3);
  transform: scale(0);
  animation: mobileNavRipple 600ms ease-out;
  pointer-events: none;
  z-index: 0;
}

@keyframes mobileNavRipple {
  to {
    transform: scale(2);
    opacity: 0;
  }
}

/* ============================================
   Slide-up Animation on Init
   ============================================ */

.mobile-bottom-nav {
  animation: mobileNavSlideUp var(--animation-duration-normal) var(--animation-ease-out);
}

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

/* ============================================
   Hide Animation (when needed)
   ============================================ */

.mobile-bottom-nav.hidden {
  transform: translateY(100%);
  opacity: 0;
  pointer-events: none;
}

/* ============================================
   Responsive Adjustments
   ============================================ */

/* Small screens (phones in portrait) */
@media (max-width: 375px) {
  .mobile-bottom-nav-container {
    padding: 0.25rem 0.5rem;
    gap: 0.25rem;
  }

  .mobile-bottom-nav-btn {
    padding: 0.25rem 0.375rem;
    min-width: 50px;
  }

  .mobile-bottom-nav-icon {
    width: 28px;
    height: 28px;
  }

  .mobile-bottom-nav-icon i {
    font-size: 20px;
  }

  .mobile-bottom-nav-label {
    font-size: 0.5625rem;
  }

  .mobile-nav-badge {
    min-width: 1rem;
    height: 1rem;
    font-size: 0.5rem;
    padding: 0.0625rem 0.25rem;
  }
}

/* Medium screens (tablets) */
@media (min-width: 768px) and (max-width: 1199px) {
  .mobile-bottom-nav-container {
    gap: 0.75rem;
    padding: 0.375rem 1rem;
  }

  .mobile-bottom-nav-btn {
    padding: 0.5rem 0.75rem;
  }
}

/* ============================================
   Landscape Mode Adjustments
   ============================================ */

@media (max-height: 500px) and (orientation: landscape) {
  .mobile-bottom-nav-container {
    padding: 0.25rem 0.5rem;
  }

  .mobile-bottom-nav-btn {
    padding: 0.25rem 0.375rem;
  }

  .mobile-bottom-nav-label {
    display: none; /* Hide labels in landscape to save space */
  }

  .mobile-bottom-nav-icon {
    width: 36px;
    height: 36px;
  }
}

/* ============================================
   Performance Optimizations
   ============================================ */

.mobile-bottom-nav-btn {
  will-change: transform;
}

/* Remove will-change when animations disabled */
html[data-animations-disabled] .mobile-bottom-nav-btn {
  will-change: auto;
}

/* ============================================
   Accessibility
   ============================================ */

/* High contrast mode support */
@media (prefers-contrast: high) {
  .mobile-bottom-nav {
    border-top-width: 2px;
  }

  .mobile-bottom-nav-btn:focus-visible {
    outline: 2px solid var(--bs-primary);
    outline-offset: 2px;
  }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  .mobile-bottom-nav,
  .mobile-bottom-nav-btn,
  .mobile-bottom-nav-icon,
  .mobile-nav-ripple {
    animation: none !important;
    transition: none !important;
  }
}

/* ============================================
   Content Safe Space for Mobile Bottom Nav
   ============================================ */

@media (max-width: 1199px) {
  #app-content {
    padding-bottom: 5rem !important; /* Clear mobile bottom nav (~70px + breathing room) */
  }
}

/* ============================================
   Print Styles
   ============================================ */

@media print {
  .mobile-bottom-nav {
    display: none !important;
  }
}

/* ============================================
   Reports Page Mobile Adjustments
   ============================================ */

/* Hide reports mobile trigger and date range on mobile (below XL) */
@media (max-width: 1199px) {
  .reports-mobile-trigger {
    display: none !important;
  }

  #reports-date-range {
    display: none !important;
  }

  /* Hide the entire mega menu container when both desktop menu and mobile trigger are hidden */
  .reports-mega-menu {
    display: none !important;
  }
}
