/* =====================================================
   css/tienda.css | Tienda e inicio (responsive)
   Movil primero: 2 columnas, filtros en panel lateral, barra pegada arriba.
   ===================================================== */
:root {
  --cj-azul: #0d6efd;
  --cj-fondo: #f4f7fb;
  --cj-texto: #172b4d;
  --cj-borde: #e7edf5;
  --cj-sombra: 0 12px 28px #10294b1f;
}
body { background: var(--cj-fondo); color: var(--cj-texto); }

/* ---------- Portada / banner ---------- */
.cj-hero, .tienda-banner {
  position: relative; overflow: hidden; color: #fff;
  background: linear-gradient(120deg, #071b35, #0d6efd);
  border-radius: 20px;
}
.cj-hero { padding: clamp(24px, 6vw, 70px); border-radius: clamp(16px, 3vw, 24px); }
.tienda-banner { padding: clamp(18px, 3vw, 30px); }
.cj-hero h1, .tienda-banner h1 { font-weight: 800; letter-spacing: -.5px; }
.cj-hero p { color: #e5efff; max-width: 580px; }
.cj-hero .btn-light { color: #0d2b52; font-weight: 700; }
.cj-section-title { font-weight: 800; letter-spacing: -.4px; }

/* ---------- Paneles ---------- */
.tienda-panel { background: #fff; border: 1px solid var(--cj-borde); border-radius: 16px; padding: 16px; }
@media (min-width: 768px) { .tienda-panel { padding: 20px; } }

/* ---------- Barra de busqueda (pegada bajo el menu en movil) ---------- */
.tienda-barra {
  position: sticky; top: var(--cj-alto-menu, 56px); z-index: 1000;
  background: var(--cj-fondo); padding: 10px 0; margin-bottom: 4px;
}
@media (min-width: 992px) { .tienda-barra { position: static; padding: 0; } }
#buscador, #orden { min-height: 46px; }

/* ---------- Categorias ---------- */
.tienda-categoria {
  display: flex; align-items: center; gap: 8px;
  padding: 11px 12px; margin-bottom: 4px; color: #334155;
  border-radius: 10px; text-decoration: none; cursor: pointer;
  overflow-wrap: anywhere; min-height: 44px;
}
.tienda-categoria:hover, .tienda-categoria.active { color: var(--cj-azul); background: #eaf2ff; font-weight: 600; }
@media (min-width: 992px) {
  #filtros { position: sticky; top: calc(var(--cj-alto-menu, 56px) + 16px); }
  #filtros .offcanvas-body { max-height: calc(100vh - 120px); overflow-y: auto; }
}
@media (max-width: 991.98px) { #filtros { --bs-offcanvas-width: min(86vw, 340px); } }

/* ---------- Tarjetas de producto (tienda e inicio) ---------- */
.tienda-producto, .cj-product {
  height: 100%; display: flex; flex-direction: column; overflow: hidden;
  background: #fff; border: 1px solid #e6ebf2; border-radius: 15px; transition: .2s ease;
}
@media (hover: hover) {
  .tienda-producto:hover, .cj-product:hover { transform: translateY(-3px); box-shadow: var(--cj-sombra); }
}
.tienda-producto-imagen, .cj-product-img {
  aspect-ratio: 1 / 1; max-height: 220px; width: 100%;
  padding: 12px; display: flex; align-items: center; justify-content: center; background: #fff;
}
.tienda-producto-imagen img, .cj-product-img img { max-width: 100%; max-height: 100%; object-fit: contain; }
.tienda-sin-imagen, .cj-product-placeholder { color: #aab8ca; font-size: 44px; }
.tienda-producto-cuerpo, .cj-product-body { padding: 12px; display: flex; flex-direction: column; flex: 1; }
@media (min-width: 768px) { .tienda-producto-cuerpo, .cj-product-body { padding: 16px; } }
.tienda-producto-nombre, .cj-product-name {
  font-weight: 700; font-size: .92rem; line-height: 1.25;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  min-height: 2.5em; overflow-wrap: anywhere;
}
@media (min-width: 768px) { .tienda-producto-nombre, .cj-product-name { font-size: 1rem; } }
.tienda-precio, .cj-product-price { color: var(--cj-azul); font-size: 1.1rem; font-weight: 800; }
@media (min-width: 768px) { .tienda-precio, .cj-product-price { font-size: 1.25rem; } }
.tienda-acciones { margin-top: auto; }
.tienda-acciones .btn { min-height: 42px; }
.tienda-cantidad { max-width: 118px; }
.tienda-cantidad .form-control { text-align: center; padding-left: 0; padding-right: 0; }
.tienda-cantidad .btn { min-width: 36px; padding-left: 0; padding-right: 0; }

/* ---------- Inicio ---------- */
.cj-category {
  display: block; height: 100%; text-decoration: none; color: inherit;
  background: #fff; border: 1px solid var(--cj-borde); border-radius: 16px;
  padding: 16px 14px; transition: .2s ease;
}
@media (hover: hover) {
  .cj-category:hover { transform: translateY(-4px); border-color: #b7d2ff; box-shadow: var(--cj-sombra); color: var(--cj-azul); }
}
.cj-category-icon {
  width: 44px; height: 44px; display: grid; place-items: center; border-radius: 13px;
  color: var(--cj-azul); background: #eaf2ff; font-size: 20px; margin-bottom: 10px;
}
.cj-feature { height: 100%; padding: 22px; background: #fff; border: 1px solid var(--cj-borde); border-radius: 18px; }
.cj-feature i { color: var(--cj-azul); font-size: 27px; margin-bottom: 14px; }

/* ---------- Aviso flotante (se ve aunque estes abajo de todo) ---------- */
#avisos {
  position: fixed; z-index: 2000; left: 12px; right: 12px; bottom: 12px;
  display: flex; flex-direction: column; gap: 8px; pointer-events: none;
}
@media (min-width: 768px) { #avisos { left: auto; right: 20px; bottom: 20px; width: 360px; } }
.aviso {
  pointer-events: auto; padding: 12px 16px; border-radius: 12px; color: #fff;
  box-shadow: var(--cj-sombra); animation: avisoEntra .25s ease;
}
.aviso.ok { background: #198754; }
.aviso.error { background: #dc3545; }
@keyframes avisoEntra { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
#cart-count.pulso { animation: pulso .4s ease; }
@keyframes pulso { 50% { transform: scale(1.5); } }
@media (prefers-reduced-motion: reduce) { .aviso, #cart-count.pulso { animation: none; } }