/* Floating cart toggle button */
#cartToggleBtn {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 1050;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  background: #0B1F33;
  color: #fff;
  font-size: 1.3rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
#cartToggleBtn:hover {
  background: #16324F;
}
.cart-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 22px;
  height: 22px;
  padding: 0 5px;
  border-radius: 11px;
  background: #dc3545;
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  align-items: center;
  justify-content: center;
}

/* Dimmed backdrop behind the panel - click to close, same as the × */
.cart-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 1060;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}
.cart-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

/* Slide-in panel */
.cart-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 380px;
  max-width: 100vw;
  background: #fff;
  z-index: 1070;
  box-shadow: -4px 0 16px rgba(0, 0, 0, 0.15);
  transform: translateX(100%);
  transition: transform 0.25s ease;
  display: flex;
  flex-direction: column;
}
.cart-panel.open {
  transform: translateX(0);
}
.cart-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid #e9ecef;
}
.cart-panel-header h3 {
  margin: 0;
  font-size: 1.1rem;
}
#cartCloseBtn {
  border: none;
  background: none;
  font-size: 1.5rem;
  line-height: 1;
  color: #6c757d;
  cursor: pointer;
}
#cartCloseBtn:hover {
  color: #212529;
}

.cart-empty {
  padding: 40px 20px;
  text-align: center;
  color: #6c757d;
}

.cart-items {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}
.cart-item {
  display: grid;
  grid-template-columns: 1fr auto auto auto;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-bottom: 1px solid #f1f3f5;
}
.cart-item-info {
  min-width: 0;
}
.cart-item-name {
  font-size: 0.9rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cart-item-number {
  font-size: 0.75rem;
  color: #6c757d;
}
.cart-item-qty {
  display: flex;
  align-items: center;
  gap: 4px;
}
.qty-btn {
  width: 24px;
  height: 24px;
  border: 1px solid #ced4da;
  background: #fff;
  border-radius: 4px;
  cursor: pointer;
  line-height: 1;
  font-size: 0.9rem;
}
.qty-btn:hover {
  background: #f1f3f5;
}
.qty-value {
  min-width: 18px;
  text-align: center;
  font-size: 0.9rem;
}
.cart-item-price {
  font-size: 0.9rem;
  font-weight: 600;
  white-space: nowrap;
}
.cart-item-remove {
  border: none;
  background: none;
  color: #adb5bd;
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
}
.cart-item-remove:hover {
  color: #dc3545;
}

.cart-panel-footer {
  border-top: 1px solid #e9ecef;
  padding: 16px 20px;
}
.cart-total-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 12px;
  font-size: 1.05rem;
}
.cart-note {
  margin: 10px 0 0;
  font-size: 0.75rem;
  color: #6c757d;
}

@media (max-width: 480px) {
  .cart-panel {
    width: 100vw;
  }
  /* The 4-column grid (name | qty | price | remove) is too tight at phone
     widths - wrap onto two rows instead of squeezing everything, rather
     than letting price/remove clip off the edge. */
  .cart-item {
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "info remove"
      "qty price";
    row-gap: 6px;
  }
  .cart-item-info { grid-area: info; }
  .cart-item-remove { grid-area: remove; }
  .cart-item-qty { grid-area: qty; }
  .cart-item-price { grid-area: price; justify-self: end; }
}
