:root {
  --color-bg: #f8f9fa;
  --color-primary: #85cbcc;
  --color-secondary: #a8dee0;
  --color-accent1: #f9e2ae;
  --color-accent2: #fbc78d;
  --color-accent3: #a7d676;
  --color-text: #343a40;
  --color-light-text: #6c757d;
  --color-white: #ffffff;
  --border-color: #e9ecef;
  --base-fondo1: #dfecfc;
  --base-fondo2: #f6eeeb;

  --producto1: #f2f7fd;
  --producto2: #f8f4f3;
  --producto3: #fcf4f1;

  --shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: "Poppins", sans-serif;
  background-color: var(--color-bg);
  color: var(--color-text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Prevent background scroll when modal is open */
body.no-scroll {
  height: 100vh;
  overflow: hidden;
}

/* --- Header --- */
.main-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 2rem;
  background-color: var(--color-white);
  border-bottom: 1px solid var(--border-color);
}

.logo-container {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.logo-image {
  height: 40px;
  width: auto;
}

.logo {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
}

.logo .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.logo .dot:nth-child(1) {
  background-color: var(--color-accent2);
}
.logo .dot:nth-child(2) {
  background-color: var(--color-primary);
}
.logo .dot:nth-child(3) {
  background-color: var(--color-text);
}
.logo .dot:nth-child(4) {
  background-color: var(--color-secondary);
}

.search-bar {
  flex-grow: 1;
  max-width: 400px;
  position: relative;
}

.search-bar input {
  width: 100%;
  padding: 0.7rem 1rem 0.7rem 2.5rem;
  border-radius: 20px;
  border: 1px solid var(--border-color);
  background-color: var(--color-bg);
}

.search-suggestions {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--color-white);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  margin-top: 5px;
  box-shadow: var(--shadow);
  z-index: 1000;
  max-height: 300px;
  overflow-y: auto;
}

.suggestion-item {
  display: flex;
  align-items: center;
  padding: 0.5rem;
  cursor: pointer;
  border-bottom: 1px solid var(--border-color);
  transition: background-color 0.2s;
}

.suggestion-item:hover {
  background-color: var(--color-bg);
}

.suggestion-image {
  width: 40px;
  height: 40px;
  object-fit: cover;
  border-radius: 4px;
  margin-right: 1rem;
}

.suggestion-info {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.suggestion-name {
  font-weight: 500;
}

.suggestion-category {
  font-size: 0.8rem;
  color: var(--color-light-text);
}

.suggestion-price {
  font-weight: 600;
  color: var(--color-primary);
}

.no-suggestions {
  padding: 1rem;
  text-align: center;
  color: var(--color-light-text);
}

.search-bar i {
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--color-light-text);
}

.header-icons {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  font-size: 1.2rem;
}

/* Footer */
.footer {
  margin-top: auto;
  background-color: var(--color-white);
  border-top: 1px solid var(--border-color);
  padding: 2rem 0;
}

.footer-content {
  max-width: 1200px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 2rem;
  padding: 0 2rem;
}

.footer-section {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.footer-section h3 {
  color: var(--color-text);
  font-size: 1.2rem;
  margin-bottom: 0.5rem;
}

.footer-section p,
.footer-section a {
  color: var(--color-light-text);
  text-decoration: none;
  font-size: 0.9rem;
  transition: color 0.2s;
}

.footer-section a:hover {
  color: var(--color-primary);
}

.social-links {
  display: flex;
  gap: 1rem;
}

.social-links a {
  font-size: 1.5rem;
}

.footer-bottom {
  text-align: center;
  padding-top: 2rem;
  margin-top: 2rem;
  border-top: 1px solid var(--border-color);
  color: var(--color-light-text);
  font-size: 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.cart-icon-container {
  position: relative;
  cursor: pointer;
}
.cart-counter {
  position: absolute;
  top: -8px;
  right: -10px;
  background-color: var(--color-accent2);
  color: var(--color-white);
  font-size: 0.7rem;
  font-weight: 600;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
}

/* --- Main Layout --- */
.main-container {
  display: grid;
  grid-template-columns: 250px 1fr;
  gap: 2rem;
  padding: 2rem;
  max-width: 1600px;
  margin: 0 auto;
  width: 95%;
}

/* --- Sidebar --- */
.sidebar h2 {
  margin-bottom: 1.5rem;
  font-size: 1.2rem;
}
#category-list {
  list-style: none;
}
#category-list li a {
  display: block;
  padding: 0.8rem 1rem;
  margin-bottom: 0.5rem;
  text-decoration: none;
  color: var(--color-light-text);
  border-radius: 8px;
  font-weight: 500;
  transition: all 0.2s ease;
}
#category-list li a:hover {
  background-color: var(--color-secondary);
  color: var(--color-text);
}
#category-list li a.active {
  background-color: var(--color-primary);
  color: var(--color-white);
}

/* --- Content --- */
.hero-section {
  display: flex;
  align-items: center;
  border-radius: 20px;
  padding: 2rem;
  margin-bottom: 3rem;
}
.hero-text {
  flex: 1;
}
.hero-text h1 {
  font-size: 2.5rem;
}
.hero-text p {
  font-size: 1rem;
  margin: 0.5rem 0 1.5rem;
}
.hero-text button {
  padding: 0.8rem 1.5rem;
  border: none;
  border-radius: 10px;
  background-color: var(--color-text);
  color: var(--color-white);
  font-weight: 600;
  cursor: pointer;
}
.hero-image img {
  max-width: 300px;
  animation: float 3s ease-in-out infinite;
}
@keyframes float {
  0% {
    transform: translatey(0px);
  }
  50% {
    transform: translatey(-15px);
  }
  100% {
    transform: translatey(0px);
  }
}
.products-section h2 {
  margin-bottom: 1.5rem;
}
.products-controls {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  justify-content: space-between;
  margin: 0.6rem 0 1rem 0;
  flex-wrap: wrap;
}
.products-controls .sort-group,
.products-controls .range-group {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.products-controls label {
  font-weight: 600;
  color: var(--color-text);
  font-size: 0.95rem;
}
.products-controls select,
.products-controls input[type="number"] {
  padding: 0.45rem 0.75rem;
  border-radius: 10px;
  border: 1px solid transparent;
  background: linear-gradient(180deg, rgba(255,255,255,0.9), rgba(250,250,250,0.95));
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.6), 0 1px 3px rgba(16,24,40,0.03);
  transition: all 180ms ease;
  font-size: 0.95rem;
  color: var(--color-text);
}

/* Custom select: hide native arrow and provide SVG arrow */
.products-controls select {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='14' height='8' viewBox='0 0 14 8'><path fill='%23666' d='M7 8L0 0h14z'/></svg>");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 36px;
  min-width: 170px;
}

/* Number inputs: remove native spin controls */
.products-controls input[type="number"]::-webkit-outer-spin-button,
.products-controls input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.products-controls input[type="number"] {
  -moz-appearance: textfield;
  appearance: none;
}

/* Range inputs visual grouping */
.products-controls .range-group input[type="number"] {
  width: 100px;
  padding-left: 0.55rem;
  padding-right: 0.55rem;
}
.products-controls .range-group input[type="number"]:first-child {
  border-top-right-radius: 6px;
  border-bottom-right-radius: 6px;
  border-top-left-radius: 8px;
  border-bottom-left-radius: 8px;
}
.products-controls .range-group input[type="number"]:last-child {
  border-top-left-radius: 6px;
  border-bottom-left-radius: 6px;
  border-top-right-radius: 8px;
  border-bottom-right-radius: 8px;
}

/* Focus and hover states */
.products-controls select:focus,
.products-controls input[type="number"]:focus {
  outline: none;
  border-color: rgba(133,203,204,0.9);
  box-shadow: 0 4px 12px rgba(133,203,204,0.12);
}

/* Ensure select dropdown stands out when focused */
.products-controls .sort-group:focus-within select,
.products-controls select:focus {
  background: linear-gradient(180deg, #ffffff, #fbffff);
  z-index: 20;
}

/* Screen-reader only helper */
.sr-only {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.products-controls button {
  padding: 0.38rem 0.7rem;
  border-radius: 8px;
  border: none;
  background: var(--color-primary);
  color: white;
  font-weight: 600;
  cursor: pointer;
}

.products-controls button.muted {
  background: transparent;
  color: var(--text-muted, #666);
  border: 1px solid var(--border-color);
  padding: 0.35rem 0.6rem;
}
.products-controls button#clear-range-btn {
  background: transparent;
  color: var(--color-text);
  border: 1px solid var(--border-color);
}

/* Primary apply button */
.products-controls button#apply-range-btn {
  background: linear-gradient(90deg, #6fc5c6 0%, #4fb7b8 100%);
  color: white;
  box-shadow: 0 6px 18px rgba(79,183,184,0.14);
}
.products-controls button#apply-range-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  box-shadow: none;
}
.products-controls button#apply-range-btn:hover:not(:disabled) {
  transform: translateY(-1px);
}
.products-controls button#clear-range-btn:hover {
  background: rgba(0,0,0,0.02);
}

@media (max-width: 800px) {
  .products-controls {
    gap: 0.5rem;
    align-items: flex-start;
  }
  .products-controls .sort-group {
    width: 100%;
  }
  .products-controls .range-group {
    width: 100%;
    justify-content: flex-start;
    gap: 0.5rem;
    margin-top: 0.4rem;
  }
  .products-controls input[type="number"] {
    width: 100px;
  }
}

@media (max-width: 420px) {
  .products-controls {
    flex-direction: column;
    gap: 0.4rem;
  }
  .products-controls select {
    width: 100%;
    min-width: 0;
  }
  .products-controls .range-group {
    flex-wrap: wrap;
    gap: 0.4rem;
  }
  .products-controls input[type="number"] {
    width: 48%;
  }
  .products-controls button {
    width: auto;
  }
}
.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1.5rem;
  width: 100%;
  margin: 0 auto;
}

/* --- Product Card --- */
.product-card {
  border-radius: 15px;
  box-shadow: var(--shadow);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  transition: transform 0.3s ease, background-color 0.3s ease;
}
.product-image-container {
  background-color: var(--color-bg);
  border-radius: 10px;
  padding: 1rem;
  margin-bottom: 1rem;
  text-align: center;
}
.product-card img {
  width: 100%;
  max-width: 180px;
  height: 160px;
  object-fit: contain;
  transition: transform 0.3s ease;
}
.product-card:hover {
  transform: translateY(-5px);
  box-shadow: var(--shadow), 0 6px 20px rgba(0, 0, 0, 0.08);
}

.product-card:hover img {
  transform: scale(1.05);
}
.product-info h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}
.product-info .category {
  font-size: 0.8rem;
  color: var(--color-light-text);
  margin-bottom: 0.5rem;
}
.price-container {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  margin-bottom: 1rem;
}
.price {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--color-primary);
}
.original-price {
  font-size: 0.9rem;
  text-decoration: line-through;
  color: var(--color-light-text);
}
.product-card.disabled {
  opacity: 0.6;
}
.badges {
  position: absolute;
  top: 10px;
  left: 10px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.badge {
  padding: 3px 8px;
  border-radius: 5px;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--color-white);
  z-index: 100;
}
.badge.sale {
  background-color: var(--color-accent2);
}
.badge.new {
  background-color: var(--color-accent3);
}
.badge.best-seller {
  background-color: var(--color-primary);
}

.product-card--soon .price-container,
.product-card--soon .product-actions {
  display: none;
}
/* Quantity & Buttons */
.product-actions {
  margin-top: auto;
}
.quantity-selector {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1rem;
  gap: 1rem;
}
.quantity-btn {
  width: 30px;
  height: 30px;
  border: 1px solid var(--border-color);
  background: var(--color-white);
  border-radius: 50%;
  font-size: 1.2rem;
  cursor: pointer;
  color: var(--color-text); /* Added color */
  transition: all 0.2s ease; /* Added transition */
}

.quantity-btn:hover {
  background-color: var(--color-primary); /* Added hover effect */
  color: var(--color-white); /* Added hover effect */
  border-color: var(--color-primary); /* Added hover effect */
}
.quantity-input {
  width: 40px;
  text-align: center;
  border: none;
  font-size: 1rem;
  font-weight: 600;
}
.product-buttons {
  display: flex;
  gap: 0.5rem;
}
.product-btn {
  flex: 1;
  padding: 0.7rem;
  border: none;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.2s;
}
.add-to-cart-btn {
  background: var(--color-secondary);
  color: var(--color-text);
}
.add-to-cart-btn:hover {
  background-color: #98d3d5;
}
.buy-now-btn {
  background-color: var(--color-primary);
  color: var(--color-white);
}
.buy-now-btn:hover {
  background-color: #72b9ba;
}

/* --- Cart Modal --- */
.cart-modal {
  position: fixed;
  top: 0;
  right: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  display: flex;
  justify-content: flex-end;
  visibility: hidden;
  opacity: 0;
  transition: visibility 0s 0.3s, opacity 0.3s ease;
  z-index: 1000;
}
.cart-modal.open {
  visibility: visible;
  opacity: 1;
  transition: opacity 0.3s ease;
}
.cart-modal-content {
  width: 480px;
  max-width: 90%;
  height: 100%;
  background-color: var(--color-white);
  box-shadow: -5px 0 15px rgba(0, 0, 0, 0.1);
  transform: translateX(100%);
  transition: transform 0.3s ease;
  display: flex;
  flex-direction: column;
  border-radius: 15px 0 0 15px; /* Added border-radius */
  padding-top: 1.5rem; /* Added padding-top */
}
.cart-modal.open .cart-modal-content {
  transform: translateX(0);
}
.cart-modal-content h2 {
  padding: 1.5rem;
  border-bottom: 1px solid var(--border-color);
}
.close-cart {
  position: absolute;
  top: 1rem;
  right: 1.5rem;
  background: none;
  border: none;
  font-size: 2rem;
  cursor: pointer;
  color: var(--color-light-text);
}
.cart-items-wrapper {
  flex-grow: 1;
  overflow-y: auto;
  padding: 1rem;
}
.cart-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
  padding: 0.8rem;
  border-radius: 10px;
  box-shadow: var(--shadow);
  background-color: var(--color-bg);
  transition: transform 0.12s ease;
}

.cart-item:hover {
  transform: translateY(-3px);
}
.cart-item img {
  width: 70px;
  height: 70px;
  object-fit: cover;
  border-radius: 10px;
  background-color: var(--color-white);
  padding: 4px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}
.cart-item-info {
  flex-grow: 1;
}
.cart-item-info h4 {
  font-size: 0.8rem;
}
.cart-item-info p {
  font-size: 0.95rem;
  color: var(--color-primary);
  font-weight: 700;
}
.cart-item-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.cart-item-actions .quantity-btn,
.cart-item-actions .quantity-input {
  height: 25px;
  width: 25px;
  font-size: 0.9rem;
}
.cart-item-actions .quantity-input {
  width: 30px;
}
.remove-from-cart-btn {
  background: none;
  border: none;
  color: #dc3545;
  cursor: pointer;
  font-size: 1rem;
  margin-left: 0.5rem;
  padding: 0.5rem; /* Added padding */
  border-radius: 5px; /* Added border-radius */
  transition: background-color 0.2s ease; /* Added transition */
}

.remove-from-cart-btn:hover {
  background-color: rgba(220, 53, 69, 0.1); /* Added hover effect */
}
.cart-summary {
  padding: 1.5rem;
  border-top: 1px solid var(--border-color);
}
.cart-summary p {
  font-size: 1.2rem;
  font-weight: 600;
  margin-bottom: 1rem;
  display: flex;
  justify-content: space-between;
}
.checkout-whatsapp-btn {
  width: 100%;
  padding: 1rem;
  background-color: #25d366;
  color: white;
  border: none;
  border-radius: 10px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  box-shadow: 0 4px 10px rgba(37, 211, 102, 0.3); /* Added box-shadow */
  transition: all 0.2s ease; /* Added transition */
}

.checkout-whatsapp-btn:hover {
  transform: translateY(-2px); /* Added hover effect */
  box-shadow: 0 6px 12px rgba(37, 211, 102, 0.4); /* Added hover effect */
}
.cart-empty-message {
  text-align: center;
  margin-top: 5rem;
  color: var(--color-light-text);
  display: none;
}

/* --- Historial de Compras --- */
.cart-history-container {
  padding: 0.8rem 1rem 0.8rem 1rem;
  border-top: 1px solid var(--border-color);
  background-color: #ffffff;
  margin: 0.6rem 1rem 0.8rem 1rem;
  border-radius: 8px;
  box-shadow: 0 6px 18px rgba(0,0,0,0.03);
  max-height: 220px; /* No crecer más: scroll interno */
  overflow-y: auto;
  overflow-x: hidden;
}
.cart-history-container h3 {
  margin: 0 0 0.6rem 0;
  font-size: 1rem;
  color: var(--color-text);
}
.purchase-history-entry {
  padding: 0.6rem 0;
  border-bottom: 1px dashed var(--border-color);
}
.purchase-history-entry:last-child {
  border-bottom: none;
}
.purchase-history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.6rem;
}
.purchase-date {
  font-size: 0.85rem;
  color: var(--color-light-text);
}
.purchase-total {
  font-weight: 700;
  color: var(--color-primary);
}
.purchase-items {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

/* Ensure the cart items area keeps priority space and remains visible */
.cart-items-wrapper {
  flex: 1 1 auto; /* allow it to grow/shrink */
  min-height: 120px; /* ensure some visible area even when history present */
}
.history-item-row {
  display: flex;
  gap: 0.8rem;
  align-items: center;
}
.history-item-row img {
  width: 80px;
  height: 80px;
  object-fit: cover;
  border-radius: 8px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.06);
}
.history-item-info {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}
.history-item-info strong {
  font-size: 0.95rem;
}
.history-item-info div {
  font-size: 0.85rem;
  color: var(--color-light-text);
}

/* Make sure the cart items container used by JS matches */
#cart-items-container.cart-items-wrapper {
  padding: 1rem;
}

.search-suggestions {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--color-white);
  border: 1px solid var(--border-color);
  border-top: none;
  border-radius: 0 0 15px 15px;
  box-shadow: var(--shadow);
  z-index: 10;
  display: none; /* Hidden by default */
}

.suggestion-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.5rem 1.5rem;
  cursor: pointer;
}

.suggestion-image {
  width: 40px;
  height: 40px;
  object-fit: contain;
}

.suggestion-item:hover {
  background-color: var(--color-bg);
}
