:root { --card-radius: 1rem; }
.product-card { border-radius: var(--card-radius); }
.navbar .badge { font-weight: 500; }

/* Mobile bottom nav */
.app-bottom-nav { height: 64px; }
@media (max-width: 767.98px) {
  body.app-has-bottom-nav { padding-bottom: 80px; }
}
.app-bottom-nav .nav-link { color: #198754; }
.app-bottom-nav .nav-link.active { color: #0a3622; }


/* Ensure bottom nav is always fixed (fallback if Bootstrap 'fixed-bottom' isn't working) */
.app-bottom-nav {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 1040;
  padding-bottom: env(safe-area-inset-bottom);
}
@supports (padding-bottom: max(0px)) {
  .app-bottom-nav { padding-bottom: max(env(safe-area-inset-bottom), 0px); }
}
@media (max-width: 767.98px) {
  body.app-has-bottom-nav { padding-bottom: calc(80px + env(safe-area-inset-bottom)); }
}


/* ================= Mobile Enhancements (2025-09-02) ================= */
/* Fix bottom menu sticking and safe-area padding */
.app-bottom-nav {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 1060; /* above content */
  background: rgba(255,255,255,0.98);
  backdrop-filter: saturate(140%) blur(6px);
  -webkit-backdrop-filter: saturate(140%) blur(6px);
  padding-bottom: env(safe-area-inset-bottom);
}

/* Ensure page content is not hidden by the bottom nav */
@media (max-width: 767.98px) {
  body.app-has-bottom-nav { padding-bottom: calc(88px + env(safe-area-inset-bottom)); }
}

/* Bottom nav items & badges */
.app-bottom-nav .nav-item, 
.app-bottom-nav a, 
.app-bottom-nav .nav-link, 
.app-bottom-nav .flex-fill { 
  position: relative; 
  padding-top: .35rem;
  padding-bottom: .25rem;
}

.app-bottom-nav .badge,
.app-bottom-nav .position-absolute.badge {
  position: absolute !important;
  right: 14px !important;
  top: 4px !important;
  left: auto !important;
  transform: none !important;
  min-width: 20px;
  height: 20px;
  line-height: 20px;
  border-radius: 10px;
  font-size: 12px;
  padding: 0 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 0 2px #fff; /* keep inside nav button */
}

/* Active state color harmony */
.app-bottom-nav .nav-link { color: #198754; }
.app-bottom-nav .nav-link.active, 
.app-bottom-nav .active.fw-semibold { color: #0a3622; }

/* ================= Favorites: vertical compact list ================= */
.page-favorites .catalog-title { margin-bottom: .25rem; }
.page-favorites .product-card {
  display: flex;
  flex-direction: row;
  gap: .75rem;
  align-items: stretch;
  min-height: auto;
}
.page-favorites .product-card .card-img-top {
  width: 96px;
  height: 96px;
  flex: 0 0 96px;
  object-fit: cover;
  border-top-left-radius: .75rem;
  border-top-right-radius: .75rem;
  border-bottom-left-radius: .75rem;
  border-bottom-right-radius: .75rem;
}
.page-favorites .product-card .card-body {
  padding: .75rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.page-favorites .product-card .btn-group,
.page-favorites .product-card .d-grid {
  margin-top: .25rem;
}

/* Make sure favorites grid is 1 column on mobile */
@media (max-width: 767.98px) {
  .page-favorites .col-12.col-sm-6.col-lg-4 { flex: 0 0 100%; max-width: 100%; }
}

/* Tighter headings for compact rows */
.page-favorites h3.h6 { margin-bottom: .25rem !important; }



/* Favorites row layout: picture - description - price - qty */
.page-favorites .product-card .row > .col-auto + .col { min-width: 40%; }
.page-favorites .product-card .input-group .form-control { text-align: center; }
@media (max-width: 575.98px) {
  .page-favorites .product-card .row { flex-wrap: nowrap; overflow-x: auto; }
  .page-favorites .product-card .col { min-width: 45%; }
}


/* Favorites single-row fit on phones */
.page-favorites .product-card .row.flex-nowrap { overflow: hidden; }
.page-favorites .product-card .row.flex-nowrap > .col,
.page-favorites .product-card .row.flex-nowrap > .col-auto { flex: 0 0 auto; }
.page-favorites .product-card .row.flex-nowrap > .col.min-w-0 { flex: 1 1 auto; min-width: 0; }
.page-favorites .product-card .fw-semibold.text-truncate { max-width: 100%; }
.page-favorites .product-card .input-group.input-group-sm .form-control { min-width: 56px; text-align:center; padding-right: .25rem; padding-left: .25rem; }
.page-favorites .product-card .input-group.input-group-sm .btn { padding-left: .5rem; padding-right: .5rem; }


/* Favorites 3-column row */
.page-favorites .product-card .row.flex-nowrap { overflow: hidden; }
.page-favorites .product-card .col.min-w-0 { min-width: 0; }
.page-favorites .product-card .fw-semibold.text-truncate { max-width: 100%; }
@media (max-width: 576px) {
  .page-favorites .product-card .input-group.input-group-sm { width: 110px !important; }
}


/* Price badge overlay on product images */
.price-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  z-index: 2;
  pointer-events: none;
}
.img-wrap { position: relative; display: inline-block; }
.img-wrap > img { display: block; }


/* XS badge for compact price labels */
.badge-xs{ 
  font-size: .55rem; 
  line-height: 1; 
  padding: .15em .35em; 
  border-radius: .4rem;
}
.badge-xs i { font-size: .85em; }


/* === Bottom nav: force equal widths, no-wrap, tidy icon/label === */
.app-bottom-nav.navbar { padding-left: 0; padding-right: 0; }
.app-bottom-nav .container-fluid { padding-left: 0; padding-right: 0; }

.app-bottom-nav .nav { flex-wrap: nowrap; gap: 0; width: 100%; }
.app-bottom-nav .nav-item { flex: 1 0 0; } /* equal columns */

.app-bottom-nav .nav-link {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 0;               /* allow shrink */
  padding: .45rem .25rem;     /* compact so 4 items fit comfortably */
  line-height: 1;
  text-align: center;
}

.app-bottom-nav .nav-link i { font-size: 1.2rem; }
.app-bottom-nav .nav-link .small {
  font-size: .74rem;
  white-space: nowrap;        /* avoid multi-line labels that grow width */
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

/* Badges should not shift layout */
.app-bottom-nav .nav-item .badge {
  position: absolute;
  top: 4px;
  right: 14px;
  min-width: 18px;
  height: 18px;
  line-height: 18px;
  padding: 0 5px;
}

/* alert message */
.alert.small {
  font-size: 0.85rem;
  padding: 0.5rem 0.8rem;
  margin-bottom: 0.8rem;
  border-radius: 0.375rem;
}


/* Force bottom nav visible on tablets (<= 1199.98px), hidden on >= 1200px */
@media (max-width: 1199.98px){
  .app-bottom-nav{ display:block !important; }
}
@media (min-width: 1200px){
  .app-bottom-nav{ display:none !important; }
  body.app-has-bottom-nav{ padding-bottom:0 !important; }
}


/* Tablet alignment guard */
.app-bottom-nav .nav{ flex-wrap: nowrap; }
.app-bottom-nav .nav-item{ flex:1 0 0; }
.app-bottom-nav .nav-link{ display:flex; flex-direction:column; align-items:center; justify-content:center; min-width:0; }


/* --- Mobile touch optimizations --- */
.catalog-grid, main.container { touch-action: pan-y; }
.js-add-to-cart, .js-toggle-fav, .app-bottom-nav a, .app-bottom-nav button { touch-action: manipulation; user-select: none; -webkit-user-select: none; }
/* --- /Mobile touch optimizations --- */
