/* PWA Bottom Bar Navigation Styles */

:root {
  --q-bottom-bar-height: 56px; /* Native mobile tab bar height */
  --q-bottom-bar-padding: 8px;
  --q-bottom-bar-transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --q-bottom-bar-active-color: var(--pwa-theme-color, #0f172a);
  --q-bottom-bar-inactive-color: #64748b;
}

/* Bottom Bar Container */
.q-pwa-bottom-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  background: var(--q-bottom-bar-bg, #ffffff);
  border-top: 1px solid rgba(0, 0, 0, 0.08); /* Subtle top division */
  display: flex;
  justify-content: space-around;
  align-items: center;
  /* Use max() to ensure space for Home Indicator/Gesture Bar or provide a safe fallback for older devices */
  padding: 0 var(--q-bottom-bar-padding) max(env(safe-area-inset-bottom), 8px); 
  z-index: 1000;
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.03); /* Extremely soft shadow */
}

/* Adjust body padding when bottom bar is present */
body.q-pwa-has-bottom-bar {
  padding-bottom: calc(var(--q-bottom-bar-height) + env(safe-area-inset-bottom) + 16px);
}

/* Navigation Item */
.q-bottom-bar-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  flex: 1;
  min-width: 0;
  height: var(--q-bottom-bar-height);
  padding: 8px 4px 4px;
  text-decoration: none;
  color: var(--q-bottom-bar-inactive-color);
  transition: var(--q-bottom-bar-transition);
  position: relative;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.q-bottom-bar-item:active {
  transform: scale(0.96);
}

.q-bottom-bar-item.active {
  color: var(--q-bottom-bar-active-color);
}

/* Icon */
.q-bottom-bar-item-icon {
  width: var(--q-bottom-bar-icon-size, 24px);
  height: var(--q-bottom-bar-icon-size, 24px);
  margin-bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--q-bottom-bar-transition);
}

.q-bottom-bar-item.active .q-bottom-bar-item-icon {
  transform: translateY(-2px);
}

.q-bottom-bar-item-icon img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: grayscale(100%) opacity(0.6);
  transition: var(--q-bottom-bar-transition);
}

.q-bottom-bar-item.active .q-bottom-bar-item-icon img {
  filter: grayscale(0%) opacity(1);
}

.q-bottom-bar-item-icon svg {
  width: 100%;
  height: 100%;
  fill: currentColor;
}

.q-bottom-bar-item-icon-fallback {
  width: 100%;
  height: 100%;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  color: currentColor;
  background: transparent;
}

/* Label */
.q-bottom-bar-item-label {
  font-size: 10px;
  font-weight: 500;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  text-align: center;
  letter-spacing: 0.2px;
  transition: var(--q-bottom-bar-transition);
}

.q-bottom-bar-item.active .q-bottom-bar-item-label {
  font-weight: 600;
}
  line-height: 1.2;
  letter-spacing: 0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  transition: var(--q-bottom-bar-transition);
  opacity: 0;
  transform: translateY(3px);
  max-height: 0;
}

/* Label always visible */
.q-pwa-bottom-bar[data-label-visibility="always"] .q-bottom-bar-item-label {
  opacity: 0.92;
  transform: translateY(0);
  max-height: 1.4em;
}

/* Label show on hover or active */
.q-pwa-bottom-bar[data-label-visibility="hover"]
  .q-bottom-bar-item:hover
  .q-bottom-bar-item-label,
.q-pwa-bottom-bar[data-label-visibility="hover"]
  .q-bottom-bar-item.active
  .q-bottom-bar-item-label {
  opacity: 0.92;
  transform: translateY(0);
  max-height: 1.4em;
}

/* Label never visible */
.q-pwa-bottom-bar[data-label-visibility="never"] .q-bottom-bar-item-label {
  display: none;
}

/* Badge */
.q-bottom-bar-item-badge {
  position: absolute;
  top: 6px;
  right: 10px;
  min-width: 18px;
  height: 18px;
  background-color: #ef4444;
  color: #fff;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
  font-size: 10px;
  font-weight: 700;
  border: 2px solid var(--q-bottom-bar-bg, #ffffff);
  box-shadow: 0 2px 8px rgba(239, 68, 68, 0.35);
}

.q-bottom-bar-item-badge:empty {
  display: none;
}

/* Remove old dot indicator */
.q-bottom-bar-item.active::after {
  content: none;
}

/* Responsive adjustments */
@media (max-width: 480px) {
  :root {
    --q-bottom-bar-height: 62px;
  }

  .q-pwa-bottom-bar {
    left: 8px;
    right: 8px;
    border-radius: 15px;
    padding: 7px;
  }

  .q-bottom-bar-item {
    padding: 3px 4px;
    margin: 0 1px;
  }

  .q-bottom-bar-item-label {
    font-size: 10px;
  }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
  .q-pwa-bottom-bar {
    border-color: rgba(255, 255, 255, 0.1);
    background: var(--q-bottom-bar-bg, #111827);
    box-shadow: 0 16px 34px rgba(0, 0, 0, 0.42);
  }

  .q-bottom-bar-item:hover {
    background: rgba(255, 255, 255, 0.08);
  }

  .q-bottom-bar-item-icon-fallback {
    background: rgba(255, 255, 255, 0.15);
  }
}

/* Accessibility */
.q-bottom-bar-item:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: -2px;
}

/* Print media */
@media print {
  .q-pwa-bottom-bar {
    display: none !important;
  }

  body.q-pwa-has-bottom-bar {
    padding-bottom: 0 !important;
    padding-top: 0 !important;
  }
}
