@import url("https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500;700&display=swap");

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

body {
  font-family: "Roboto", sans-serif;
  background-color: #f5f5f5;
  color: #333;
  line-height: 1.6;
}

/* =======
    HEADER 
    =======*/

.header {
  background: linear-gradient(135deg, #ffe600 0%, #ffed4e 100%);
  padding: 12px 0;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  position: sticky;
  top: 0;
  z-index: 1000;
}

.header-container {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 0 20px;
}

.logo {
  font-size: 2rem;
  font-weight: 700;
  color: #333;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 8px;
}

.search-container {
  flex: 1;
  display: flex;
  max-width: 600px;
  position: relative;
}

.search-input {
  width: 100%;
  padding: 12px 20px;
  border: none;
  border-radius: 4px;
  font-size: 16px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  outline: none;
}

.search-input:focus {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.search-btn {
  background: #3483fa;
  color: white;
  border: none;
  padding: 12px 20px;
  border-radius: 0 4px 4px 0;
  cursor: pointer;
  margin-left: -1px;
  transition: background 0.3s ease;
}

.search-btn:hover {
  background: #2968c8;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 20px;
}

.cart-icon {
  position: relative;
  color: #333;
  text-decoration: none;
  font-size: 1.5rem;
  transition: transform 0.3s ease;
}

.cart-icon:hover {
  transform: scale(1.1);
}

.cart-count {
  position: absolute;
  top: -8px;
  right: -8px;
  background: #ff3344;
  color: white;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
}

/* ======================================== 
    FILTROS Y NAVEGACIÓN
    ======================================== */

.filters-container {
  background: white;
  padding: 20px 0;
  border-bottom: 1px solid #e5e5e5;
}

.filters-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  align-items: center;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.filter-label {
  font-size: 14px;
  font-weight: 500;
  color: #666;
}

.filter-select {
  padding: 8px 12px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 14px;
  min-width: 150px;
  outline: none;
}

.filter-select:focus {
  border-color: #3483fa;
}

.price-range {
  display: flex;
  align-items: center;
  gap: 10px;
}

.price-input {
  width: 80px;
  padding: 8px;
  border: 1px solid #ddd;
  border-radius: 4px;
  text-align: center;
  font-size: 14px;
}

.clear-filters {
  background: #f5f5f5;
  color: #666;
  border: 1px solid #ddd;
  padding: 8px 16px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.3s ease;
}

.clear-filters:hover {
  background: #e5e5e5;
}

/* ======================================== 
    GRID DE PRODUCTOS
    ======================================== */

.main-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 30px 20px;
}

.products-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.products-count {
  font-size: 16px;
  color: #666;
}

.sort-select {
  padding: 8px 12px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 14px;
  outline: none;
}

.products-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 20px;
  margin-bottom: 40px;
}

/* ======================
    TARJETAS DE PRODUCTO  
    ======================*/

.product-card {
  background: white;
  border-radius: 8px;
  padding: 16px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  transition: all 0.3s ease;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

.product-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

.product-image {
  width: 100%;
  height: 200px;
  object-fit: cover;
  border-radius: 4px;
  margin-bottom: 12px;
}

.product-title {
  font-size: 16px;
  font-weight: 400;
  color: #333;
  margin-bottom: 8px;
  line-height: 1.4;
  display: -webkit-box;
  line-clamp: 2;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.product-price {
  font-size: 24px;
  font-weight: 300;
  color: #333;
  margin-bottom: 4px;
}

.product-original-price {
  font-size: 14px;
  color: #999;
  text-decoration: line-through;
  margin-bottom: 8px;
}

.product-discount {
  color: #00a650;
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 8px;
}

.shipping-info {
  color: #00a650;
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.product-rating {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 12px;
  font-size: 14px;
  color: #666;
}

.stars {
  color: #ffa500;
}

.add-to-cart-btn {
  width: 100%;
  background: #3483fa;
  color: white;
  border: none;
  padding: 12px;
  border-radius: 6px;
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

.add-to-cart-btn:hover {
  background: #2968c8;
  transform: translateY(-1px);
}

.add-to-cart-btn:active {
  transform: translateY(0);
}

.add-to-cart-btn.added {
  background: #00a650;
  animation: addedSuccess 0.5s ease;
}

.stock-badge {
  position: absolute;
  top: 12px;
  right: 12px;
  background: #00a650;
  color: white;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 500;
}

.out-of-stock {
  background: #ff3344;
}

/* ======================================== 
    MODAL DE CONFIRMACIÓN
    ======================================== */

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 2000;
  animation: fadeIn 0.3s ease;
}

.modal {
  background: white;
  padding: 30px;
  border-radius: 12px;
  max-width: 400px;
  width: 90%;
  text-align: center;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
  animation: slideIn 0.3s ease;
}

.modal-icon {
  font-size: 3rem;
  color: #00a650;
  margin-bottom: 20px;
}

.modal-title {
  font-size: 20px;
  font-weight: 500;
  margin-bottom: 10px;
  color: #333;
}

.modal-message {
  color: #666;
  margin-bottom: 25px;
  line-height: 1.5;
}

.modal-actions {
  display: flex;
  gap: 15px;
  justify-content: center;
}

.modal-btn {
  padding: 10px 20px;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s ease;
}

.modal-btn-primary {
  background: #3483fa;
  color: white;
}

.modal-btn-primary:hover {
  background: #2968c8;
}

.modal-btn-secondary {
  background: #f5f5f5;
  color: #666;
  border: 1px solid #ddd;
}

.modal-btn-secondary:hover {
  background: #e5e5e5;
}

/* ======================================== 
    TOAST NOTIFICATIONS
    ======================================== */

.toast {
  position: fixed;
  top: 100px;
  right: 20px;
  background: #00a650;
  color: white;
  padding: 15px 20px;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  z-index: 3000;
  transform: translateX(400px);
  transition: transform 0.3s ease;
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 500;
}

.toast.show {
  transform: translateX(0);
}

/* ======================================== 
    ESTADOS VACÍOS Y CARGA
    ======================================== */

.loading {
  text-align: center;
  padding: 60px 20px;
  color: #666;
}

.loading-spinner {
  font-size: 2rem;
  animation: spin 1s linear infinite;
  margin-bottom: 20px;
}

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: #666;
}

.empty-icon {
  font-size: 4rem;
  margin-bottom: 20px;
  color: #ddd;
}

/* ======================================== 
    ANIMACIONES
    ======================================== */

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes slideIn {
  from {
    transform: translateY(-20px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

@keyframes addedSuccess {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.05);
  }
  100% {
    transform: scale(1);
  }
}

/* ======================================== 
    RESPONSIVE DESIGN
    ======================================== */

@media (max-width: 768px) {
  .header-container {
    flex-direction: column;
    gap: 15px;
    padding: 15px 20px;
  }

  .search-container {
    order: 2;
    max-width: 100%;
  }

  .header-actions {
    order: 1;
    align-self: flex-end;
  }

  .filters-content {
    flex-direction: column;
    align-items: stretch;
  }

  .filter-group {
    width: 100%;
  }

  .filter-select {
    min-width: 100%;
  }

  .products-grid {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 15px;
  }

  .product-card {
    padding: 12px;
  }

  .product-image {
    height: 150px;
  }

  .modal {
    margin: 20px;
    width: calc(100% - 40px);
  }
}

@media (max-width: 480px) {
  .products-grid {
    grid-template-columns: 1fr 1fr;
  }

  .product-title {
    font-size: 14px;
  }

  .product-price {
    font-size: 20px;
  }
}