/* --- Bottom Navigation --- */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background-color: var(--color-surface-subtle);
  display: flex;
  justify-content: space-around;
  box-shadow: 0 -2px 5px rgba(0, 0, 0, 0.1);
  z-index: 1000;
  padding-top: 8px;

  /* Use min-height for the content height (60px) and let padding handle the safe area */
  min-height: 60px;

  border-top: 1px solid var(--color-border-default);
  box-sizing: border-box;

  /* CRITICAL FIX: Ensure the padding correctly handles the iOS safe area */
  /* Fallback for older iOS versions */
  padding-bottom: constant(safe-area-inset-bottom);
  /* Standard for current iOS versions */
  padding-bottom: env(safe-area-inset-bottom);
}

/* This spacer is added at the end of the layout-wrapper. It must match the total height
 * of the fixed nav bar to ensure the scrollable content isn't cut off.
 */
.nav-bar-spacer {
  /* CRITICAL FIX: Calculate the height as content height (60px) PLUS safe area inset */
  /* Fallback */
  height: calc(60px + constant(safe-area-inset-bottom));
  /* Standard */
  height: calc(60px + env(safe-area-inset-bottom));

  flex-shrink: 0; /* Prevent the spacer from shrinking */
}

.nav-button {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  color: var(--color-text-muted);
  font-size: 12px;
  flex-grow: 1;
  padding: 0;
  position: relative; /* Needed for absolute positioning of the icon */
}

.nav-button .material-symbols-outlined {
  font-size: 30px;
  margin-bottom: 4px;
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.6s ease-in-out;
}

.nav-button.active {
  color: var(--color-primary-base);
  /* Ensure the button container doesn't collapse weirdly when text is hidden */
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
}

.nav-button.active::before {
  content: "";
  position: absolute;
  top: -28px;
  left: 50%;
  transform: translateX(-50%);
  background-color: var(--color-primary-base);
  width: 60px;
  height: 60px;
  border-radius: 50%;
  box-shadow: 0 4px 12px rgba(58, 134, 255, 0.4);
  transition: all 0.5s ease-in-out;
  z-index: -1; /* Place it behind the icon and text */
}

@keyframes icon-bounce-in {
  0% {
    transform: translateY(0) scale(0.8);
    opacity: 0.8;
  }
  50% {
    transform: translateY(-32px) scale(1.1);
    opacity: 1;
  }
  100% {
    /* Move up significantly to center in the popped bubble since text is gone */
    transform: translateY(-26px) scale(1);
  }
}

@keyframes bg-bounce-in {
  0% {
    transform: translateX(-50%) translateY(0) scale(0.8);
    opacity: 0.8;
  }
  50% {
    transform: translateX(-50%) translateY(-18px) scale(1.05);
    opacity: 1;
  }
  100% {
    transform: translateX(-50%) translateY(-10px) scale(1);
  }
}

.nav-button.active::before {
  animation: bg-bounce-in 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.nav-button.active .material-symbols-outlined {
  color: white;
  font-variation-settings: "FILL" 1;
  animation: icon-bounce-in 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

/* --- Dark Mode Overrides --- */
html.dark-mode .bottom-nav {
  background-color: var(--color-surface-subtle);
  border-color: var(--color-border-default);
}

html.dark-mode .nav-button.active::before {
  border-color: var(--color-surface-subtle);
}

/* --- Update Indicator (Red Dot) --- */
.nav-button[href="profile.html"].update-available::after {
  content: "";
  position: absolute;
  top: 8px;
  right: calc(50% - 16px); /* Position top-right of the icon */
  width: 10px;
  height: 10px;
  background-color: #ef4444; /* Red */
  border-radius: 50%;
  border: 2px solid var(--color-surface-subtle);
  z-index: 10;
  box-sizing: border-box;
  pointer-events: none;
}