/* =====================================================
   SPYA Market Showcase — CSS
   ===================================================== */

/* Variables */
:root {
  --spya-bg:       #f2f2f2;
  --spya-white:    #ffffff;
  --spya-text:     #1a1a1a;
  --spya-muted:    #777777;
  --spya-border:   #e5e5e5;
  --spya-red:      #d32f2f;
  --spya-green:    #2e7d32;
  --spya-radius:   10px;
  --spya-shadow:   0 1px 6px rgba(0,0,0,0.09);
  --spya-shadow-md:0 4px 18px rgba(0,0,0,0.14);
}

/* ── CARRUSEL HOMEPAGE ── */
.spya-ms-carrusel-wrap {
  margin: 12px 0 20px;
}

.spya-ms-carrusel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.spya-ms-store-identity {
  display: flex;
  align-items: center;
  gap: 10px;
}

.spya-ms-store-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}

.spya-ms-store-identity strong {
  display: block;
  font-size: 15px;
  font-weight: 700;
  color: var(--spya-text);
}

.spya-ms-store-identity span {
  font-size: 12px;
  color: var(--spya-muted);
}

.spya-ms-btn-ver {
  font-size: 12px;
  font-weight: 600;
  border: 1.5px solid var(--spya-border);
  background: var(--spya-white);
  color: var(--spya-muted);
  padding: 6px 13px;
  border-radius: 20px;
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
  transition: border-color .15s, color .15s;
}

.spya-ms-btn-ver:hover {
  border-color: #aaa;
  color: var(--spya-text);
}

/* Carrusel scroll */
.spya-ms-carousel {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 10px;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.spya-ms-carousel::-webkit-scrollbar { display: none; }

/* Tarjeta del carrusel */
.spya-ms-card {
  flex: 0 0 142px;
  background: var(--spya-white);
  border-radius: var(--spya-radius);
  box-shadow: var(--spya-shadow);
  overflow: hidden;
  scroll-snap-align: start;
}

.spya-ms-card .spya-img-box {
  width: 100%;
  height: 114px;
  background: #fafafa;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.spya-ms-card .spya-img-box img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 8px;
}

.spya-ms-card .spya-card-info {
  padding: 7px 9px 9px;
}

/* ── PÁGINA COMPLETA ── */
.spya-ms-pagina {
  position: relative;
}

.spya-ms-search-bar {
  background: var(--spya-white);
  padding: 10px 14px;
  margin-bottom: 0;
}

.spya-ms-search-inner {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--spya-bg);
  border-radius: 9px;
  padding: 9px 13px;
}

.spya-ms-search-inner input {
  flex: 1;
  border: none;
  background: none;
  outline: none;
  font-size: 14px;
  color: var(--spya-text);
}

.spya-ms-search-inner svg {
  color: var(--spya-muted);
  flex-shrink: 0;
}

.spya-ms-info-badge {
  background: #eff6ff;
  color: #1d4ed8;
  font-size: 11px;
  padding: 7px 14px;
  border-bottom: 1px solid #dbeafe;
}

/* Layout sidebar + contenido */
.spya-ms-layout {
  display: flex;
  align-items: flex-start;
  min-height: 500px;
}

/* ── SIDEBAR ── */
.spya-ms-sidebar {
  width: 200px;
  flex-shrink: 0;
  background: var(--spya-white);
  border-right: 1px solid var(--spya-border);
  position: sticky;
  top: 60px;
  max-height: calc(100vh - 60px);
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--spya-border) transparent;
}

.spya-ms-sidebar-title {
  padding: 12px 14px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .3px;
}

.spya-ms-sidebar-nav {
  border-top: 1px solid var(--spya-border);
}

.spya-ms-cat-item {
  border-bottom: 1px solid var(--spya-border);
}

.spya-ms-cat-btn {
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  padding: 11px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--spya-text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  transition: background .1s;
}

.spya-ms-cat-btn:hover {
  background: var(--spya-bg);
}

.spya-ms-cat-item.active .spya-ms-cat-btn {
  /* color dinámico via JS */
  font-weight: 700;
}

.spya-ms-cat-arrow {
  font-size: 14px;
  color: var(--spya-muted);
  transition: transform .2s;
  flex-shrink: 0;
}

.spya-ms-cat-item.open .spya-ms-cat-arrow {
  transform: rotate(90deg);
}

/* Subcategorías */
.spya-ms-subcats {
  display: none;
  background: #fafafa;
  border-top: 1px solid var(--spya-border);
}

.spya-ms-cat-item.open .spya-ms-subcats {
  display: block;
}

.spya-ms-sub-btn {
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  border-bottom: 1px solid var(--spya-border);
  padding: 8px 14px 8px 22px;
  font-size: 12px;
  color: var(--spya-muted);
  cursor: pointer;
  transition: background .1s;
}

.spya-ms-sub-btn:hover {
  background: var(--spya-border);
  color: var(--spya-text);
}

.spya-ms-sub-btn.active {
  font-weight: 600;
  /* color dinámico via JS */
}

/* ── ÁREA DE PRODUCTOS ── */
.spya-ms-content {
  flex: 1;
  min-width: 0;
  padding: 14px 12px;
}

.spya-ms-menu-toggle {
  display: none;
  padding: 8px 14px;
  border: none;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  margin-bottom: 12px;
}

.spya-ms-section-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--spya-text);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.spya-ms-count {
  font-size: 11px;
  font-weight: 400;
  color: var(--spya-muted);
}

/* Grid de productos */
.spya-ms-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

/* Tarjeta de producto */
.spya-ms-product-card {
  background: var(--spya-white);
  border-radius: var(--spya-radius);
  box-shadow: var(--spya-shadow);
  overflow: hidden;
  position: relative;
}

.spya-ms-product-card .spya-img-box {
  width: 100%;
  height: 130px;
  background: #fafafa;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
}

.spya-ms-product-card .spya-img-box img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 10px;
}

.spya-ms-product-card .spya-card-info {
  padding: 9px 10px 11px;
}

/* Info compartida en tarjetas */
.spya-ms-marca {
  font-size: 9px;
  color: var(--spya-muted);
  text-transform: uppercase;
  letter-spacing: .4px;
  margin-bottom: 2px;
}

.spya-ms-nombre {
  font-size: 12px;
  font-weight: 600;
  color: var(--spya-text);
  line-height: 1.3;
  margin-bottom: 6px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.spya-ms-precio-oferta {
  font-size: 15px;
  font-weight: 800;
  color: var(--spya-red);
}

.spya-ms-precio-orig {
  font-size: 10px;
  color: var(--spya-muted);
  text-decoration: line-through;
}

.spya-ms-precio-normal {
  font-size: 15px;
  font-weight: 700;
  color: var(--spya-text);
}

/* Badges */
.spya-ms-badge-oferta {
  position: absolute;
  top: 6px;
  left: 6px;
  background: var(--spya-red);
  color: #fff;
  font-size: 8px;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 3px;
  text-transform: uppercase;
  letter-spacing: .3px;
}

.spya-ms-badge-pct {
  position: absolute;
  top: 6px;
  right: 6px;
  background: var(--spya-green);
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 10px;
}

/* ── LOADING / EMPTY ── */
.spya-ms-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 30px 20px;
  color: var(--spya-muted);
  font-size: 13px;
}

.spya-ms-spinner {
  width: 24px;
  height: 24px;
  border: 3px solid var(--spya-border);
  border-top-color: #e30613;
  border-radius: 50%;
  animation: spyaSpin .7s linear infinite;
  flex-shrink: 0;
}

@keyframes spyaSpin { to { transform: rotate(360deg); } }

.spya-ms-empty {
  padding: 30px;
  text-align: center;
  color: var(--spya-muted);
  font-size: 13px;
}

/* Overlay mobile */
.spya-ms-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 199;
}

.spya-ms-overlay.open { display: block; }

/* ── RESPONSIVE ── */
@media (max-width: 768px) {
  .spya-ms-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 600px) {
  .spya-ms-sidebar {
    position: fixed;
    top: 0;
    left: -220px;
    width: 220px;
    height: 100vh;
    max-height: 100vh;
    z-index: 200;
    transition: left .25s ease;
    box-shadow: none;
    top: 0;
  }

  .spya-ms-sidebar.open {
    left: 0;
    box-shadow: var(--spya-shadow-md);
  }

  .spya-ms-menu-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
  }

  .spya-ms-content {
    padding: 10px 8px;
  }
}

@media (max-width: 380px) {
  .spya-ms-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 7px;
  }
}

/* =====================================================
   NUEVO: tarjeta tocable + modal de producto + compartir
   Agregado sin modificar ninguna regla existente.
   ===================================================== */

/* Indicador visual de que la tarjeta se puede tocar */
.spya-ms-card,
.spya-ms-product-card {
  cursor: pointer;
}

.spya-ms-card .spya-img-box,
.spya-ms-product-card .spya-img-box {
  position: relative;
}

.spya-ms-card .spya-img-box::after,
.spya-ms-product-card .spya-img-box::after {
  content: "";
  position: absolute;
  right: 6px;
  bottom: 6px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(0,0,0,0.55);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
  background-size: 12px 12px;
  pointer-events: none;
}

/* Overlay del modal */
.spya-ms-modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 99999;
  background: rgba(0,0,0,0.6);
  align-items: flex-end;
  justify-content: center;
}

.spya-ms-modal.open {
  display: flex;
}

@media (min-width: 640px) {
  .spya-ms-modal {
    align-items: center;
  }
}

.spya-ms-modal-box {
  background: var(--spya-white);
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  border-radius: 16px 16px 0 0;
  position: relative;
  animation: spyaModalUp .18s ease-out;
}

@media (min-width: 640px) {
  .spya-ms-modal-box {
    border-radius: 16px;
  }
}

@keyframes spyaModalUp {
  from { transform: translateY(24px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

.spya-ms-modal-close {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 2;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: none;
  background: rgba(0,0,0,0.55);
  color: white;
  font-size: 16px;
  cursor: pointer;
  line-height: 1;
}

.spya-ms-modal-img-wrap {
  width: 100%;
  aspect-ratio: 1 / 1;
  background: #f5f5f5;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 16px 16px 0 0;
  overflow: hidden;
}

.spya-ms-modal-img-wrap img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.spya-ms-modal-info {
  padding: 16px 18px 22px;
}

.spya-ms-modal-nombre {
  font-size: 18px;
  font-weight: 700;
  color: var(--spya-text);
  margin: 4px 0 10px;
  line-height: 1.3;
}

.spya-ms-modal-share-btn {
  margin-top: 14px;
  width: 100%;
  border: none;
  border-radius: 10px;
  background: #1877f2; /* azul Facebook */
  color: white;
  font-size: 15px;
  font-weight: 600;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
}

.spya-ms-modal-share-btn:active {
  opacity: 0.85;
}

.spya-ms-share-icon {
  font-size: 17px;
}
