/**
 * RADEXEL Design System - Bottom Navigation
 *
 * Mobile-only bottom navigation bar (max-width: 768px).
 * Replaces the right sidebar on smaller viewports.
 *
 * Structure:
 *   .bottom-nav
 *     .bottom-nav__dropdown       (upward popup, conditional)
 *       .bottom-nav__dropdown-item
 *     .bottom-nav__tabs
 *       .bottom-nav__tab
 *         .bottom-nav__icon
 *         .bottom-nav__label
 *
 * Design tokens used:
 *   --color-surface, --color-border, --color-text-muted, --rdx-blue
 *   --shadow-lg, --radius-md, --space-*, --font-size-xs, --z-sticky, --z-dropdown
 */


/* ==========================================================================
   Bottom Nav Container
   Hidden by default. Shown only at mobile breakpoint (768px).
   ========================================================================== */

.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: var(--z-sticky);
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
  box-shadow: var(--shadow-bottom-nav);

  /* iOS safe area support */
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

/* Show at mobile breakpoint (same breakpoint where right sidebar hides) */
@media (max-width: 768px) {
  .bottom-nav {
    display: flex;
    flex-direction: column;
  }
}


/* ==========================================================================
   Tab Bar
   5 equally spaced tabs in a horizontal row.
   ========================================================================== */

.bottom-nav__tabs {
  display: flex;
  align-items: stretch;
  height: 56px;
}

.bottom-nav__tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-1);
  padding: var(--space-1) 0;
  border: none;
  background: transparent;
  color: var(--color-text-muted);
  cursor: pointer;
  position: relative;
  transition:
    color var(--duration-fast) var(--ease-default);

  /* Remove default button styles */
  -webkit-tap-highlight-color: transparent;
  outline: none;
  font-family: var(--font-sans);
}

/* Focus visible for keyboard users */
.bottom-nav__tab:focus-visible {
  outline: 2px solid var(--rdx-blue);
  outline-offset: -2px;
  border-radius: var(--radius-sm);
}

/* Active tab state */
.bottom-nav__tab--active {
  color: var(--rdx-blue);
}

/* "More" button open state */
.bottom-nav__tab--open {
  color: var(--rdx-blue);
}

/* Active indicator bar (top edge of active tab) */
.bottom-nav__tab--active::before {
  content: '';
  position: absolute;
  top: 0;
  left: 25%;
  right: 25%;
  height: 2px;
  background: var(--rdx-blue);
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
}


/* ==========================================================================
   Tab Icon
   ========================================================================== */

.bottom-nav__icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
}

.bottom-nav__icon svg {
  width: 20px;
  height: 20px;
}


/* ==========================================================================
   Tab Label
   ========================================================================== */

.bottom-nav__label {
  font-size: 10px;
  font-weight: var(--font-weight-medium);
  line-height: 1;
  letter-spacing: var(--letter-spacing-wide);
  white-space: nowrap;
}


/* ==========================================================================
   "More" Dropdown (Upward)
   Positioned above the bottom nav bar.
   ========================================================================== */

.bottom-nav__dropdown {
  position: absolute;
  bottom: 100%;
  right: var(--space-2);
  min-width: 180px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  z-index: var(--z-dropdown);
  padding: var(--space-1) 0;
  margin-bottom: var(--space-2);

  /* Entry animation */
  animation: bottomNavDropdownIn var(--duration-fast) var(--ease-out);
}

@keyframes bottomNavDropdownIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}


/* ==========================================================================
   Dropdown Item
   ========================================================================== */

.bottom-nav__dropdown-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  padding: var(--space-3) var(--space-4);
  border: none;
  background: transparent;
  color: var(--color-text-secondary);
  font-family: var(--font-sans);
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-normal);
  cursor: pointer;
  transition:
    background-color var(--duration-fast) var(--ease-default),
    color var(--duration-fast) var(--ease-default);
  text-align: left;

  -webkit-tap-highlight-color: transparent;
  outline: none;
}

.bottom-nav__dropdown-item:hover {
  background: var(--color-surface-hover);
  color: var(--color-text);
}

.bottom-nav__dropdown-item:active {
  background: var(--color-surface-active);
}

.bottom-nav__dropdown-item:focus-visible {
  outline: 2px solid var(--rdx-blue);
  outline-offset: -2px;
}

/* Active item (current route matches) */
.bottom-nav__dropdown-item--active {
  color: var(--rdx-blue);
  font-weight: var(--font-weight-medium);
  background: var(--color-info-light);
}

.bottom-nav__dropdown-item--active:hover {
  color: var(--rdx-blue);
  background: var(--color-info-light);
}


/* ==========================================================================
   Dropdown Item Icon
   ========================================================================== */

.bottom-nav__dropdown-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.bottom-nav__dropdown-icon svg {
  width: 18px;
  height: 18px;
}


/* ==========================================================================
   Dropdown Item Label
   ========================================================================== */

.bottom-nav__dropdown-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}


/* ==========================================================================
   Touch Device Enhancements
   ========================================================================== */

@media (pointer: coarse) {
  .bottom-nav__tab {
    min-height: 44px;
  }

  .bottom-nav__dropdown-item {
    min-height: 44px;
  }
}


/* ==========================================================================
   Landscape Phone Adjustments
   ========================================================================== */

@media (max-height: 500px) and (orientation: landscape) and (max-width: 768px) {
  .bottom-nav__tabs {
    height: 44px;
  }

  .bottom-nav__label {
    font-size: 9px;
  }

  .bottom-nav__icon svg {
    width: 18px;
    height: 18px;
  }
}


/* ==========================================================================
   Print: Hide bottom nav
   ========================================================================== */

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