/* Bottom Navigation Bar Styles (Modern & Attractive) */

.bottom-nav-btn {
  color: var(--muted-foreground, #6b7280);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  min-width: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  display: flex !important;
  visibility: visible !important;
  opacity: 1 !important;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  padding: 0.5rem 0.5rem;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  border-radius: 0.5rem;
  margin: 0;
  flex: 1 1 0;
  overflow: visible;
  text-align: center;
}

.bottom-nav-btn:hover,
.bottom-nav-btn:focus {
  color: var(--primary, #3b82f6);
  background-color: var(--muted, rgba(59, 130, 246, 0.1));
  outline: none;
  transform: translateY(-2px);
}

.bottom-nav-btn.active {
  color: var(--primary, #3b82f6);
  background-color: var(--muted, rgba(59, 130, 246, 0.15));
  font-weight: 600;
}

/* Cart button when cart is open (not using active class) */
.bottom-nav-btn[data-cart-open="true"] {
  background-color: var(--muted, rgba(59, 130, 246, 0.1));
}

.bottom-nav-btn[data-cart-open="true"]:not(.active) {
  color: var(--muted-foreground, #6b7280);
}

.bottom-nav-btn.active::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 40px;
  height: 3px;
  background: var(--primary);
  border-radius: 0 0 3px 3px;
}

.bottom-nav-btn.active svg {
  transform: scale(1.1);
}

.bottom-nav-btn svg {
  transition: transform 0.2s ease;
  display: block !important;
  visibility: visible !important;
  opacity: 1 !important;
  width: 1.25rem !important;
  height: 1.25rem !important;
  margin: 0 auto;
  flex-shrink: 0;
}

.bottom-nav-btn span {
  transition: color 0.2s ease;
  display: block;
  width: 100%;
  text-align: center;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Icon wrapper: keep compact so badge sits on icon, not full button width */
.bottom-nav-btn .bottom-nav-icon-wrap {
  width: auto !important;
  display: inline-block !important;
}

/* Badge on top of icon (cart count, announcements count) - exclude from full-width span rule */
.bottom-nav-btn .nav-icon-badge {
  width: auto !important;
  min-width: 1.125rem;
  position: absolute !important;
  top: 0 !important;
  right: 0 !important;
  transform: translate(50%, -50%);
  flex-shrink: 0;
}

/* Bottom nav container */
.fixed.bottom-0,
#pro-admin-bottom-nav,
nav.fixed.bottom-0,
.admin-bottom-nav {
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  background: rgba(255, 255, 255, 0.98) !important;
  border-top: 1px solid var(--border, #e5e7eb);
  box-shadow: 0 -4px 20px -2px rgba(0, 0, 0, 0.1), 0 -2px 8px -1px rgba(0, 0, 0, 0.06);
  display: flex !important;
  visibility: visible !important;
  opacity: 1 !important;
  align-items: center;
  justify-content: center;
  min-height: 60px;
  max-height: 70px;
  z-index: 99999 !important;
  position: fixed !important;
  bottom: 0 !important;
  left: 0 !important;
  right: 0 !important;
  width: 100% !important;
  height: auto !important;
  padding-bottom: env(safe-area-inset-bottom);
}

/* Container inside nav for proper alignment */
nav.fixed.bottom-0 > .container,
nav.fixed.bottom-0 > div {
  width: 100%;
  max-width: 100%;
  margin: 0;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: space-around;
  gap: 0.25rem;
}

nav.fixed.bottom-0 > .container > div,
nav.fixed.bottom-0 > div > div {
  display: flex;
  align-items: center;
  justify-content: space-around;
  width: 100%;
  gap: 0.25rem;
  padding: 0.5rem 0.25rem;
}

/* Cart badge on bottom nav */
#bottom-cart-count {
  position: absolute;
  top: -6px;
  right: -4px;
  font-size: 0.625rem;
  min-width: 1.25rem;
  height: 1.25rem;
  padding: 0 0.25rem;
  background: var(--primary) !important;
  color: white !important;
  border-radius: 9999px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* Ensure content doesn't get hidden behind bottom nav */
body {
  padding-bottom: 0;
}

/* Overlays (cart drawer, modals) must appear above bottom nav (z-index 99999) */
#cart-drawer,
#cart-drawer.open,
#cart-drawer-backdrop:not(.hidden),
.drawer,
.drawer.open,
.modal-overlay:not(.hidden),
#product-detail-modal:not(.hidden) {
  z-index: 100000 !important;
}

/* Hide bottom nav when cart drawer is open - prevents checkout button from being covered */
#cart-drawer.open ~ #shop-bottom-nav,
body.cart-drawer-open #shop-bottom-nav {
  visibility: hidden !important;
  opacity: 0 !important;
  pointer-events: none !important;
  transition: visibility 0.2s, opacity 0.2s;
}

/* Desktop: Keep bottom nav visible but adjust styling */
@media (min-width: 768px) {
  .fixed.bottom-0,
  #pro-admin-bottom-nav {
    display: flex !important;
    visibility: visible !important;
    opacity: 1 !important;
    max-width: 100%;
    position: fixed !important;
    bottom: 0 !important;
    z-index: 99999 !important;
  }
  
  /* Adjust bottom padding on desktop */
  .pb-20.sm\:pb-24 {
    padding-bottom: 5rem !important;
  }
}

/* Mobile: Show bottom nav and add padding */
@media (max-width: 767px) {
  .fixed.bottom-0,
  #pro-admin-bottom-nav,
  .admin-bottom-nav {
    display: flex !important;
    visibility: visible !important;
    opacity: 1 !important;
    position: fixed !important;
    bottom: 0 !important;
    z-index: 99999 !important;
  }
  
  /* Override md:hidden class on mobile for admin bottom nav */
  .admin-bottom-nav.md\:hidden {
    display: flex !important;
  }
  
  .pb-20,
  .pb-24 {
    padding-bottom: 5.5rem !important;
  }
  
  /* Modals/drawers z-index handled by global rule above */
  
  /* Chatbot should be above bottom nav */
  #chatbot-window {
    bottom: 5.5rem !important;
  }
  
  #chatbot-toggle {
    bottom: 5.5rem !important;
  }
  
  /* Ensure main content has proper padding so nothing is hidden behind bottom nav (incl. safe area) */
  main {
    padding-bottom: calc(7rem + env(safe-area-inset-bottom, 0px)) !important;
  }
  
  /* Cart drawer footer - extra padding so checkout button is never covered by bottom nav */
  #cart-drawer .cart-drawer-footer {
    padding-bottom: calc(1.5rem + env(safe-area-inset-bottom, 0px)) !important;
    padding-top: 1rem !important;
  }
  /* Ensure checkout button is fully visible and tappable */
  #cart-drawer #checkout-btn {
    margin-top: 0.5rem !important;
  }
  
  /* Admin dashboard content - extra padding for bottom nav on small screens */
  #dashboard-content {
    padding-bottom: calc(6rem + env(safe-area-inset-bottom, 0px)) !important;
  }
}

/* Short viewport (e.g. iPhone XS, iPhone SE): more padding so content is never under nav */
@media screen and (max-width: 767px) and (max-height: 700px) {
  main {
    padding-bottom: calc(7.5rem + env(safe-area-inset-bottom, 0px)) !important;
  }
  #dashboard-content {
    padding-bottom: calc(6.5rem + env(safe-area-inset-bottom, 0px)) !important;
  }
}

/* Smooth transitions */
.bottom-nav-btn {
  transform: translateY(0);
}

.bottom-nav-btn:active {
  transform: translateY(2px);
}

/* Ensure all buttons are evenly distributed */
nav.fixed.bottom-0 .flex.items-center.justify-around {
  display: flex !important;
  align-items: center !important;
  justify-content: space-around !important;
  width: 100% !important;
  gap: 0 !important;
}

nav.fixed.bottom-0 .flex.items-center.justify-around > .bottom-nav-btn {
  flex: 1 1 0 !important;
  min-width: 0 !important;
  max-width: 100% !important;
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
  justify-content: center !important;
}

/* Ensure icons are perfectly centered */
.bottom-nav-btn svg {
  display: block;
  margin-left: auto;
  margin-right: auto;
}

/* Ensure text is centered */
.bottom-nav-btn span {
  text-align: center;
  margin-left: auto;
  margin-right: auto;
}

/* Better touch targets */
@media (max-width: 767px) {
  nav.fixed.bottom-0 > .container > div,
  nav.fixed.bottom-0 > div > div {
    padding: 0.5rem 0.125rem;
    gap: 0.125rem;
  }
  
  .bottom-nav-btn {
    min-height: 48px;
    padding: 0.5rem 0.375rem;
    min-width: 0;
    flex: 1 1 0;
    max-width: 100%;
  }
  
  .bottom-nav-btn svg {
    width: 1.25rem !important;
    height: 1.25rem !important;
  }
  
  .bottom-nav-btn span {
    font-size: 0.625rem !important;
    line-height: 1.2 !important;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
  }
  
  /* Admin dashboard bottom nav specific styles */
  .admin-bottom-nav {
    min-height: 60px !important;
    max-height: 70px !important;
    padding-bottom: env(safe-area-inset-bottom) !important;
  }
  
  .admin-bottom-nav > div {
    gap: 0.125rem !important;
    padding: 0.375rem 0.25rem !important;
  }
  
  /* Ensure all buttons are visible and not cut off */
  .admin-bottom-nav .bottom-nav-btn {
    display: flex !important;
    visibility: visible !important;
    opacity: 1 !important;
    flex-shrink: 0 !important;
    min-width: 50px !important;
    max-width: none !important;
    overflow: visible !important;
  }
  
  /* Make sure the container doesn't hide buttons */
  .admin-bottom-nav > div {
    overflow-x: auto !important;
    overflow-y: hidden !important;
    -webkit-overflow-scrolling: touch !important;
    scrollbar-width: none !important;
    -ms-overflow-style: none !important;
  }
  
  .admin-bottom-nav > div::-webkit-scrollbar {
    display: none !important;
  }
}

