/* =============================================
   Mobile bottom nav, quick-add, cart UX
============================================= */

body.has-bottom-nav {
  padding-bottom: calc(76px + env(safe-area-inset-bottom, 0px));
}

/* Bottom navigation — hide on scroll down, show on scroll up */
.bottom-nav {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: calc(10px + env(safe-area-inset-bottom, 0px));
  z-index: 1200;
  display: none;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  background: rgba(255, 255, 255, 0.98);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 8px 6px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.35s ease;
}

.bottom-nav.is-visible { display: grid; }

.bottom-nav.is-hidden {
  transform: translateY(calc(110% + env(safe-area-inset-bottom, 0px)));
  opacity: 0;
  pointer-events: none;
}

.bottom-nav a,
.bottom-nav button {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 8px 4px;
  border: none;
  background: transparent;
  text-decoration: none;
  color: var(--text-light);
  font-family: var(--font-body);
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: pointer;
  border-radius: 14px;
  transition: var(--transition);
  position: relative;
}

.bottom-nav .nav-icon {
  font-size: 1.2rem;
  line-height: 1;
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.bottom-nav a.active,
.bottom-nav a:hover,
.bottom-nav button:hover {
  color: var(--earth);
  background: var(--cream);
}

.bottom-nav .nav-badge {
  position: absolute;
  top: 4px;
  right: calc(50% - 22px);
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  background: var(--earth);
  color: #fff;
  font-size: 0.55rem;
  font-weight: 700;
  border-radius: 10px;
  display: none;
  align-items: center;
  justify-content: center;
}

.bottom-nav .nav-badge.show { display: flex; }

.cart-fab {
  position: fixed;
  right: 16px;
  bottom: calc(88px + env(safe-area-inset-bottom, 0px));
  z-index: 1199;
  display: none;
  align-items: center;
  gap: 10px;
  background: var(--earth);
  color: #fff;
  padding: 12px 18px;
  border-radius: var(--radius-pill);
  font-size: 0.82rem;
  font-weight: 600;
  text-decoration: none;
  box-shadow: var(--shadow-md);
  border: none;
  cursor: pointer;
  font-family: var(--font-body);
  transition: transform 0.35s ease, opacity 0.35s ease;
}

.cart-fab.show { display: flex; }

.cart-fab.is-hidden {
  transform: translateY(120%);
  opacity: 0;
  pointer-events: none;
}

/* Product card — Anveshan-style quick ADD */
.product-card {
  position: relative;
}

.product-card .btn-quick-add {
  position: absolute;
  bottom: 12px;
  right: 12px;
  z-index: 3;
  background: var(--white);
  color: var(--earth);
  border: 2px solid var(--earth);
  padding: 8px 18px;
  border-radius: var(--radius-pill);
  font-family: var(--font-body);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  cursor: pointer;
  transition: var(--transition);
  box-shadow: var(--shadow-sm);
}

.product-card .btn-quick-add:hover,
.product-card .btn-quick-add.added {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
}

.product-card .product-actions-row {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}

.product-actions-row .btn-add {
  flex: 1;
}

.product-card .btn-view {
  flex: 0 0 auto;
  padding: 10px 14px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-mid);
  font-size: 0.8rem;
  font-weight: 600;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}

/* Horizontal product rail (mobile home) */
.product-rail-wrap {
  overflow: hidden;
  margin: 0 -24px;
  padding: 0 24px;
}

.product-rail {
  display: flex;
  gap: 16px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  padding-bottom: 12px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.product-rail::-webkit-scrollbar { display: none; }

.product-rail .product-card {
  flex: 0 0 min(280px, 78vw);
  scroll-snap-align: start;
}

/* Category chips */
.category-chips {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 8px;
  margin-bottom: 32px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.category-chips::-webkit-scrollbar { display: none; }

.category-chip {
  flex-shrink: 0;
  padding: 10px 20px;
  border-radius: var(--radius-pill);
  background: var(--white);
  border: 1px solid var(--border);
  color: var(--text-mid);
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: none;
  transition: var(--transition);
}

.category-chip:hover,
.category-chip.active {
  background: var(--green);
  color: #fff;
  border-color: var(--green);
}

/* Cart drawer improvements */
.cart-item {
  display: flex;
  gap: 14px;
  margin-bottom: 16px;
  align-items: center;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.cart-item img {
  width: 72px;
  height: 72px;
  object-fit: cover;
  border-radius: 12px;
  background: var(--cream);
}

.cart-item-info { flex: 1; min-width: 0; }
.cart-item-name {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--earth);
  margin-bottom: 6px;
  line-height: 1.3;
}

.cart-qty {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: var(--white);
}

.cart-qty button {
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 1rem;
  color: var(--earth);
}

.cart-qty span {
  min-width: 28px;
  text-align: center;
  font-size: 0.85rem;
  font-weight: 600;
}

.cart-item-price {
  font-weight: 700;
  color: var(--earth);
  text-align: right;
}

.cart-item-remove {
  background: none;
  border: none;
  color: var(--terracotta);
  font-size: 0.72rem;
  cursor: pointer;
  margin-top: 6px;
}

/* Sticky checkout bar (checkout page mobile) */
.checkout-sticky-bar {
  display: none;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1100;
  background: var(--white);
  border-top: 1px solid var(--border);
  padding: 14px 20px calc(14px + env(safe-area-inset-bottom, 0px));
  box-shadow: 0 -8px 24px rgba(0,0,0,0.08);
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.checkout-sticky-bar .btn-primary {
  flex-shrink: 0;
  padding: 12px 24px;
}

@media (max-width: 768px) {
  .bottom-nav.is-visible { display: grid; }

  header .hamburger { display: none; }

  .nav-actions .btn-primary { display: none; }

  .checkout-sticky-bar.checkout-page { display: flex; }

  body.checkout-page.has-bottom-nav {
    padding-bottom: calc(140px + env(safe-area-inset-bottom, 0px));
  }

  .toast {
    bottom: calc(100px + env(safe-area-inset-bottom, 0px)) !important;
  }
}

@media (min-width: 769px) {
  .bottom-nav,
  .cart-fab { display: none !important; }

  body.has-bottom-nav { padding-bottom: 0; }

  .product-rail .product-card { flex: 0 0 280px; }
}
