@import './variables.css';

/* ─── Store wrapper background ─── */
.store-wrapper {
  background: var(--gray-50);
  border-top: 1px solid var(--gray-200);
  border-bottom: 1px solid var(--gray-200);
}

/* ─── Store Layout ─── */
.store-layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  gap: 2rem;
  padding: 2.5rem 0;
  align-items: start;
}


/* ─── Sidebar ─── */
.store-sidebar {
  position: sticky;
  top: calc(var(--nav-h) + 1.5rem);
}
.sidebar-card {
  background: var(--white);
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow);
}
.sidebar-card h3 {
  font-family: var(--font-secondary);
  font-size: var(--text-sm);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--gray-500);
  margin-bottom: 1rem;
}
.category-list { display: flex; flex-direction: column; gap: 0.25rem; }
.category-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.65rem 1rem;
  border-radius: var(--radius-lg);
  border: none;
  background: transparent;
  color: var(--gray-700);
  font-family: var(--font-secondary);
  font-size: var(--text-sm);
  font-weight: 600;
  text-align: left;
  transition: var(--transition);
  width: 100%;
}
.category-btn:hover  { background: var(--gray-50); color: var(--primary); }
.category-btn.active { background: var(--primary); color: var(--white); box-shadow: var(--shadow-sm); }
.category-btn .cat-icon { font-size: 1.1rem; }
.category-btn .cat-count {
  background: var(--gray-200);
  color: var(--gray-600);
  border-radius: var(--radius-full);
  padding: 0.1rem 0.5rem;
  font-size: var(--text-xs);
  font-weight: 700;
}
.category-btn.active .cat-count { background: rgba(255,255,255,0.3); color: var(--white); }

.price-range { display: flex; flex-direction: column; gap: 0.75rem; }
.price-inputs { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; }
.price-input-wrap { display: flex; flex-direction: column; gap: 0.25rem; }
.price-input-wrap label { font-size: var(--text-xs); color: var(--gray-500); font-weight: 500; }
.price-input-wrap input {
  padding: 0.5rem 0.625rem;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  font-size: var(--text-sm);
  color: var(--gray-800);
  width: 100%;
  font-family: var(--font);
}
.price-input-wrap input:focus {
  outline: none;
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(47,128,193,0.1);
}

/* ─── Store Main ─── */
.store-main {}
.store-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}
.store-search {
  display: flex;
  align-items: center;
  background: var(--white);
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-full);
  padding: 0.7rem 1.5rem;
  gap: 0.75rem;
  flex: 1;
  max-width: 480px;
  box-shadow: var(--shadow-sm), 0 1px 3px rgba(31, 78, 121, 0.04);
  transition: var(--transition);
  position: relative;
}
.store-search:hover {
  border-color: rgba(31, 78, 121, 0.25);
  box-shadow: var(--shadow), 0 2px 8px rgba(31, 78, 121, 0.06);
}
.store-search:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(31, 78, 121, 0.1), var(--shadow-md);
  background: #fafcff;
}
.store-search input {
  border: none;
  outline: none;
  font-size: var(--text-sm);
  color: var(--gray-800);
  background: transparent;
  width: 100%;
  font-family: var(--font);
}
.store-search input::placeholder {
  color: var(--gray-400);
  font-weight: 400;
}
.store-search .search-icon {
  color: var(--gray-400);
  flex-shrink: 0;
  transition: all 0.25s ease;
}
.store-search:focus-within .search-icon {
  color: var(--primary);
  transform: scale(1.1);
}
.store-meta {
  font-size: var(--text-sm);
  color: var(--gray-500);
}
.store-toolbar-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
}
.store-sort select {
  padding: 0.625rem 1rem;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius);
  font-size: var(--text-sm);
  color: var(--gray-700);
  background: var(--white);
  font-family: var(--font);
  cursor: pointer;
}
.store-sort select:focus { outline: none; border-color: var(--primary); }
.mobile-filter-btn {
  display: none;
  align-items: center;
  gap: 0.4rem;
  background: var(--white);
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 0.5rem 1rem;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--gray-700);
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}
.mobile-filter-btn:hover { border-color: var(--primary); color: var(--primary); }
.mobile-filter-btn.active { background: var(--primary); color: var(--white); border-color: var(--primary); }

/* ─── Product Grid ─── */
.products-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.5rem;
  min-height: 200px;
}

/* ─── Skeleton loading cards ─── */
.skeleton-card {
  background: var(--white);
  border: 1px solid var(--gray-100);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.skeleton-media {
  aspect-ratio: 1/1;
  margin: 0.75rem 0.75rem 0 0.75rem;
  border-radius: var(--radius);
  background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
}
.skeleton-body { padding: 1.25rem; }
.skeleton-line {
  height: 0.875rem;
  border-radius: 4px;
  background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  margin-bottom: 0.625rem;
}
.skeleton-line.short { width: 55%; }
.skeleton-line.medium { width: 80%; }
.skeleton-line.long { width: 100%; }
.skeleton-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.875rem 1.25rem;
  border-top: 1px solid var(--gray-100);
  margin-top: 0.5rem;
}
.skeleton-price {
  height: 1.25rem;
  width: 5rem;
  border-radius: 4px;
  background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
}
.skeleton-btn {
  height: 2rem;
  width: 4rem;
  border-radius: var(--radius-full);
  background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
}
@keyframes shimmer {
  from { background-position: 200% 0; }
  to   { background-position: -200% 0; }
}

/* Card shell */
.product-card {
  background: var(--white);
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: var(--transition-slow);
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow);
}
.product-card:hover {
  transform: translateY(-5px);
  box-shadow: var(--shadow-xl);
  border-color: rgba(31, 78, 121, 0.3);
}

/* Image area */
.product-card-media {
  position: relative;
  aspect-ratio: 1/1;
  overflow: hidden;
  background: var(--gray-50);
  border: 1.5px solid var(--gray-100);
  border-radius: var(--radius);
  margin: 0.75rem 0.75rem 0 0.75rem;
  transition: var(--transition-slow);
}
.product-card-media > a {
  display: block;
  width: 100%;
  height: 100%;
}
.product-card-media img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: var(--white);
  padding: 0.75rem;
  transition: transform 0.4s ease;
}
.product-card:hover .product-card-media {
  border-color: rgba(31, 78, 121, 0.25);
  box-shadow: 0 4px 12px rgba(31, 78, 121, 0.04);
}
.product-card:hover .product-card-media img {
  transform: scale(1.04);
}

.product-card-chips {
  position: absolute;
  top: 0.6rem;
  left: 0.6rem;
  right: 0.6rem;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.4rem;
  pointer-events: none;
  z-index: 2;
}
.product-chip-cat {
  display: none; /* In case any old chips remain cached */
}
.product-chip-feat {
  background: var(--primary-dark);
  border-radius: 100px;
  padding: 0.35rem 0.8rem;
  font-size: 0.7rem;
  font-weight: 800;
  color: var(--yellow);
  white-space: nowrap;
  box-shadow: 0 2px 6px rgba(0,0,0,0.15);
  border: 1px solid rgba(255,255,255,0.2);
}

/* Card body */
.product-card-body {
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  flex: 1;
}
.product-card-category {
  font-family: var(--font-secondary);
  font-size: 0.65rem;
  font-weight: 800;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 0.35rem;
}
.product-card-name {
  font-family: var(--font-primary);
  font-size: var(--text-base);
  font-weight: 700;
  color: var(--gray-900);
  line-height: 1.35;
  margin-bottom: 0.4rem;
}
.product-card-desc {
  font-size: 0.78rem;
  color: var(--gray-500);
  line-height: 1.6;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  margin-bottom: 1rem;
}
.product-card-footer {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding-top: 1rem;
  border-top: 1.5px solid var(--gray-100);
  margin-top: auto;
}

/* Price */
.product-price-wrap { display: flex; flex-direction: column; gap: 0.1rem; }
.product-price-row { display: flex; align-items: center; gap: 0.4rem; }
.product-price-original {
  font-size: 0.7rem;
  color: var(--gray-400);
  text-decoration: line-through;
  font-weight: 500;
  line-height: 1.2;
}
.product-discount-tag {
  background: rgba(202, 138, 4, 0.08);
  color: var(--yellow-dark);
  font-family: var(--font-secondary);
  font-size: 0.62rem;
  font-weight: 800;
  padding: 0.1rem 0.4rem;
  border-radius: var(--radius-full);
  letter-spacing: 0.02em;
  text-transform: uppercase;
  white-space: nowrap;
}
.product-price {
  font-size: var(--text-2xl);
  font-weight: 900;
  color: var(--primary-dark);
  line-height: 1.1;
  letter-spacing: -0.02em;
}
.product-price .currency {
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--primary-dark);
  margin-right: 0.1rem;
}
.product-price-request {
  font-family: var(--font-secondary);
  font-size: 0.75rem;
  font-weight: 800;
  color: var(--primary);
  background: rgba(31, 78, 121, 0.05);
  border: 1px solid rgba(31, 78, 121, 0.1);
  padding: 0.25rem 0.6rem;
  border-radius: var(--radius-full);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  display: inline-block;
}

.btn-ver {
  background: var(--primary);
  color: var(--white);
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius-full);
  font-family: var(--font-secondary);
  font-size: var(--text-sm);
  font-weight: 700;
  border: none;
  transition: var(--transition);
  white-space: nowrap;
  letter-spacing: 0.02em;
  width: 100%;
  text-align: center;
  display: block;
}
.btn-ver:hover {
  background: var(--primary-dark);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

/* ─── Empty State ─── */
.empty-state {
  text-align: center;
  padding: 4rem 2rem;
  grid-column: 1 / -1;
}
.empty-state .empty-icon { font-size: 4rem; margin-bottom: 1rem; }
.empty-state h3 { font-size: var(--text-xl); color: var(--gray-600); margin-bottom: 0.5rem; }
.empty-state p  { color: var(--gray-400); font-size: var(--text-sm); }

/* ─── Active Filters ─── */
.active-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
}
.filter-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: var(--primary);
  color: var(--white);
  padding: 0.25rem 0.75rem;
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: 600;
}
.filter-tag button {
  background: none;
  border: none;
  color: var(--white);
  font-size: 1rem;
  line-height: 1;
  padding: 0;
  opacity: 0.7;
  transition: var(--transition);
}
.filter-tag button:hover { opacity: 1; }

/* ─── Responsive ─── */
@media (max-width: 1024px) {
  .products-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  /* Layout */
  .store-layout { grid-template-columns: 1fr; gap: 1rem; padding: 1.5rem 0; }

  /* Sidebar: oculto por defecto, visible con clase .open */
  .store-sidebar { position: static; display: none; }
  .store-sidebar.open { display: block; margin-bottom: 1rem; }

  /* Toolbar */
  .store-toolbar { flex-wrap: wrap; gap: 0.75rem; }
  .store-search { max-width: 100%; flex: 1 1 100%; order: 2; }
  .store-toolbar-right { order: 1; width: 100%; justify-content: space-between; }
  .mobile-filter-btn { display: flex; }
  .store-meta { font-size: var(--text-xs); }

  /* Sort: ocultar en móvil cuando hay botón filtros */
  .store-sort select { font-size: var(--text-xs); padding: 0.5rem 0.75rem; }

  /* Products */
  .products-grid { grid-template-columns: repeat(2, 1fr); gap: 1rem; }

  /* Cards más compactas */
  .product-card-body { padding: 1rem; }
  .product-card-name { font-size: var(--text-sm); }
  .product-card-desc { display: none; }
  .product-card-footer { padding-top: 0.75rem; }
  .product-price { font-size: var(--text-lg); }
}

@media (max-width: 400px) {
  .products-grid { grid-template-columns: 1fr; }
  .product-card-desc { display: -webkit-box; }
}
