/* ============================
   GLOBAL BACKGROUND (Fixed)
============================ */
body {
  /* Your original background image */
  background-image: url("../img/bg-dots.png");

  /* === Added: stronger, darker dot pattern overlay === */
  background-image:
    radial-gradient(rgba(0,0,0,0.12) 1.2px, transparent 1.2px),
    radial-gradient(rgba(0,0,0,0.12) 1.2px, transparent 1.2px),
    url("../img/bg-dots.png");

  background-repeat: repeat, repeat, repeat;
  background-position: 0 0, 16px 16px, 0 0;
  background-size: 32px 32px, 32px 32px, auto;
  background-attachment: fixed;
}

/* === Global Theme Colors === */
body {
  background-color: #ffffff;
  color: #212529;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.navbar {
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* === Carousel === */
.carousel,
.carousel-inner,
.carousel-item,
.carousel-item img,
.carousel-img {
  border-radius: 0 !important;
}

.carousel-img {
  width: 100%;
  height: 480px;
  object-fit: cover;
}

@media (max-width: 768px) {
  .carousel-img {
    height: 280px;
  }
}

.carousel-control-prev-icon,
.carousel-control-next-icon {
  background-color: rgba(0, 0, 0, 0.5);
  border-radius: 50%;
  width: 50px;
  height: 50px;
}

/* === Search Section === */
.search-section {
  background-color: #dc3545; /* Red background */
}

#searchBtn {
  background-color: #28a745;
  border: none;
  font-weight: bold;
}

#searchBtn:hover {
  background-color: #218838;
}

/* === Product Cards (#f6f8f9 Border Style) === */
#product-list .card {
  border: 3px solid #f6f8f9 !important;
  border-radius: 14px !important;
  overflow: hidden;
  position: relative;
  background-color: #ffffff;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.03);
  transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
}

#product-list .card:hover {
  transform: scale(1.03);
  border-color: #e1e4e5;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.06);
}

.card-img-top {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  background-color: #fff;
  padding: 10px;
  border-radius: 12px;
  position: relative;
}

/* === Price Overlay (Top Left) === */
.price-overlay {
  position: absolute;
  top: 18px;
  left: 18px;
  background-color: rgba(0, 0, 0, 0.9);
  color: #fff;
  font-weight: 700;
  font-size: 1rem;
  padding: 10px 18px;
  border-radius: 8px;
  z-index: 10;
}

/* === Cart & Reset Buttons (Top Right) === */
.cart-overlay,
.reset-overlay {
  border: none;
  border-radius: 50%;
  width: 52px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 1.25rem;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
  position: relative;
  z-index: 15;
}

.cart-overlay {
  background-color: rgba(220, 53, 69, 0.9);
}

.reset-overlay {
  background-color: rgba(220, 53, 69, 0.9);
  opacity: 0;
  pointer-events: none;
}

.cart-overlay:hover,
.reset-overlay:hover {
  background-color: rgba(220, 53, 69, 1);
  transform: scale(1.05);
}

.reset-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

/* === Ensure stacking context for overlays === */
.position-relative {
  position: relative;
  z-index: 1;
}

/* === Red Counter (Below Cart, 23px Gap, Same Size) === */
.mini-counter {
  position: absolute;
  top: calc(52px + 23px);
  right: 18px;
  transform: translateY(0);
  width: 52px;
  height: 52px;
  background-color: #dc3545;
  color: #fff;
  font-size: 1rem;
  font-weight: 700;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  cursor: pointer;
  z-index: 25;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
  transition: opacity 0.3s ease, transform 0.3s ease, background-color 0.2s ease;
}

.mini-counter.visible {
  opacity: 1;
  transform: scale(1);
}

.mini-counter:hover {
  background-color: #b02a37;
  transform: scale(1.1);
}

/* === Total Price Box (Below Counter) === */
.cart-total {
  position: absolute;
  top: calc(52px + 23px + 60px);
  right: 18px;
  background-color: #000;
  color: #fff;
  font-size: 0.85rem;
  font-weight: 700;
  border-radius: 6px;
  padding: 4px 8px;
  min-width: 70px;
  text-align: center;
  z-index: 20;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
  opacity: 0;
  transform: translateY(-5px);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.cart-total.visible {
  opacity: 1;
  transform: translateY(0);
}

/* === Brand + Product Overlay === */
.card-title-overlay-green {
  position: absolute;
  bottom: 0;
  width: 100%;
  text-align: center;
  overflow: hidden;
  border-bottom-left-radius: 12px;
  border-bottom-right-radius: 12px;
  z-index: 2;
}

.card-title-overlay-green .brand-name {
  display: block;
  background-color: rgba(40, 167, 69, 0.95);
  color: #fff;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 4px;
}

.card-title-overlay-green .product-line {
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: rgba(220, 53, 69, 0.95);
  color: #fff;
  font-weight: 700;
  padding: 6px;
  gap: 6px;
}

.product-line .product-name {
  font-size: 0.95rem;
}

/* === Stock + Package Box === */
.stock-box {
  background-color: #f1f1f1;
  color: #dc3545;
  font-size: 0.85rem;
  font-weight: 700;
  border: 2px solid #dc3545;
  border-radius: 6px;
  padding: 2px 8px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* === Footer === */
footer {
  background-color: #dc3545;
  color: #fff;
  font-size: 0.9rem;
}

/* === Toast === */
.toast {
  min-width: 250px;
}

/* === Responsive Adjustments === */
@media (max-width: 768px) {
  .cart-overlay,
  .reset-overlay {
    width: 42px;
    height: 42px;
    font-size: 1rem;
  }

  .mini-counter {
    width: 42px;
    height: 42px;
    font-size: 0.9rem;
    top: calc(42px + 20px);
    right: 14px;
  }

  .price-overlay {
    font-size: 0.9rem;
    padding: 8px 14px;
  }

  .stock-box {
    font-size: 0.8rem;
    padding: 1px 6px;
  }

  .cart-total {
    top: calc(42px + 20px + 50px);
    right: 14px;
    font-size: 0.8rem;
    padding: 3px 6px;
  }
}

/* === Floating Cart Button === */
#floatingCartBtn {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 1050;
  display: none;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  width: 56px;
  height: 56px;
  font-size: 1.4rem;
  background-color: #ffc107;
  color: #000;
  border: none;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
  transition: all 0.3s ease;
}

#floatingCartBtn:hover {
  transform: translateY(-3px);
}

#floatingCartBtn.show {
  display: flex;
  opacity: 1;
  transform: scale(1);
}

#floatingCartBtn.hide {
  opacity: 0;
  transform: scale(0.95);
}

#floatingCartBtn .badge {
  position: absolute;
  top: -4px;
  right: -4px;
  font-size: 0.75rem;
  padding: 4px 6px;
  border-radius: 50%;
  background-color: #000;
  color: #ffc107;
  border: 2px solid #fff;
  font-weight: 700;
  min-width: 20px;
  text-align: center;
  line-height: 1;
}

@media (max-width: 768px) {
  #floatingCartBtn {
    bottom: 16px;
    right: 16px;
    width: 52px;
    height: 52px;
    font-size: 1.3rem;
  }

  #floatingCartBtn .badge {
    top: -3px;
    right: -3px;
    font-size: 0.7rem;
    min-width: 18px;
  }
}

/* === Fix: Ensure Left Alignment for Modal Text on Mobile === */
@media (max-width: 576px) {
  #productModal .modal-body,
  #productModal .modal-body * {
    text-align: left !important;
  }

  #modalProductDesc {
    text-align: left !important;
    line-height: 1.6;
    padding: 0 0.75rem;
  }

  #modalProductName,
  #modalProductBrand,
  #modalProductPrice {
    text-align: left !important;
    width: 100%;
  }

  #productModal .modal-body .row {
    flex-direction: column;
    align-items: flex-start !important;
    justify-content: flex-start !important;
  }

  #productModal .modal-body .col-md-7 {
    width: 100%;
    padding-left: 0.75rem;
    padding-right: 0.75rem;
  }
}
