/**
 * Mobile Bottom Navigation
 * App-style fixed bottom tab bar shown only on mobile (< 768px).
 * Replaces the hamburger menu. Includes slide-up bottom sheets for the
 * "More" and "Profile" tabs.
 */

.bottom-nav {
  display: none;
}

@media (max-width: 767px) {
  .bottom-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: stretch;
    justify-content: space-around;
    min-height: var(--bottom-nav-height, 4rem);
    padding-bottom: env(safe-area-inset-bottom, 0px);
    background: var(--color-background);
    border-top: 1px solid var(--color-border);
    box-shadow: 0 -2px 8px rgb(0 0 0 / 0.06);
    z-index: var(--z-sticky);
  }

  .bottom-nav__item {
    flex: 1 1 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: var(--space-2) 0;
    background: transparent;
    border: none;
    cursor: pointer;
    text-decoration: none;
    color: var(--color-muted-foreground);
    font-weight: var(--font-weight-medium);
    transition: color var(--transition-fast);
    -webkit-tap-highlight-color: transparent;
  }

  .bottom-nav__item i {
    font-size: 1.3rem;
    line-height: 1;
  }

  .bottom-nav__item span {
    font-size: 0.7rem;
    line-height: 1;
  }

  /* Notification count badge (e.g. unconfirmed students) over a nav icon. */
  .bottom-nav__icon {
    position: relative;
    display: inline-flex;
    line-height: 1;
  }

  .bottom-nav__badge {
    position: absolute;
    top: -6px;
    left: 100%;
    margin-left: -11px;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-full);
    background: var(--color-destructive);
    color: #fff;
    font-size: 0.625rem;
    font-weight: var(--font-weight-semibold);
    line-height: 1;
  }

  .bottom-nav__item:active {
    color: var(--color-foreground);
  }

  .bottom-nav__item--active,
  .bottom-nav__item.up-current {
    color: var(--color-primary);
  }

  .bottom-nav__avatar {
    width: 26px;
    height: 26px;
    border-radius: var(--radius-full);
    object-fit: cover;
    border: 2px solid transparent;
    transition: border-color var(--transition-fast);
  }

  .bottom-nav__item--active .bottom-nav__avatar {
    border-color: var(--color-primary);
  }

  /* Shared dimming overlay behind any open sheet */
  .bottom-sheet__overlay {
    position: fixed;
    inset: 0;
    background: rgb(0 0 0 / 0.45);
    opacity: 0;
    visibility: hidden;
    transition:
      opacity var(--transition-base),
      visibility var(--transition-base);
    z-index: var(--z-modal);
  }

  .bottom-nav--sheet-open .bottom-sheet__overlay {
    opacity: 1;
    visibility: visible;
  }

  /* Slide-up sheets */
  .bottom-sheet {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--color-card);
    border-top-left-radius: var(--radius-xl);
    border-top-right-radius: var(--radius-xl);
    border-top: 1px solid var(--color-border);
    box-shadow: var(--shadow-lg);
    padding: var(--space-2) var(--space-3)
      calc(var(--bottom-nav-height, 4rem) + env(safe-area-inset-bottom, 0px));
    transform: translateY(110%);
    transition: transform var(--transition-base);
    z-index: var(--z-modal);
    max-height: 75vh;
    overflow-y: auto;
  }

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

  .bottom-sheet__handle {
    width: 36px;
    height: 4px;
    border-radius: var(--radius-full);
    background: var(--color-border);
    margin: var(--space-2) auto var(--space-3);
  }

  .bottom-sheet__item {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3);
    color: var(--color-foreground);
    text-decoration: none;
    border-radius: var(--radius-md);
    font-size: var(--font-size-base);
    font-weight: var(--font-weight-medium);
    transition: background var(--transition-fast);
  }

  .bottom-sheet__item i {
    width: 1.4rem;
    text-align: center;
    color: var(--color-muted-foreground);
  }

  .bottom-sheet__item:active {
    background: var(--color-muted);
  }

  .bottom-sheet__separator {
    height: 1px;
    background: var(--color-border);
    margin: var(--space-2) 0;
  }

  /* Keep page content clear of the fixed bar */
  body {
    padding-bottom: calc(
      var(--bottom-nav-height, 4rem) + env(safe-area-inset-bottom, 0px)
    );
  }
}
