/* =========================================================
   Megafix — Hoja de estilos del catálogo público
   Paleta reducida, mucho espacio en blanco, sin saturación.
   ========================================================= */

:root {
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;

  --color-bg: #ffffff;
  --color-bg-soft: #f6f7f9;
  --color-border: #e6e8eb;
  --color-text: #16181d;
  --color-text-muted: #667085;
  --color-text-faint: #98a2b3;

  --color-primary: #1d4ed8;
  --color-primary-dark: #1739a8;
  --color-available: #16a34a;
  --color-out: #dc2626;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;

  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow-md: 0 8px 24px rgba(16, 24, 40, .08);

  --container: 1280px;
  --header-h: 64px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font);
  color: var(--color-text);
  background: var(--color-bg-soft);
  -webkit-font-smoothing: antialiased;
  line-height: 1.45;
}

img { max-width: 100%; display: block; }

a { color: inherit; text-decoration: none; }

button, input {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

.container {
  max-width: var(--container);
  margin: 0 auto;
  padding: 0 24px;
}

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ---------------------------------------------------------
   Header
   --------------------------------------------------------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-border);
}

.site-header__bar {
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  font-size: 1.3rem;
  font-weight: 800;
  letter-spacing: .01em;
  color: var(--color-primary);
}

.main-nav {
  display: flex;
  align-items: center;
  gap: 28px;
}

.main-nav a {
  font-size: .92rem;
  color: var(--color-text-muted);
  padding: 6px 2px;
  border-bottom: 2px solid transparent;
  transition: color .15s ease, border-color .15s ease;
}

.main-nav a:hover {
  color: var(--color-text);
}

.main-nav a[aria-current="page"] {
  color: var(--color-text);
  border-bottom-color: var(--color-primary);
  font-weight: 600;
}

/* WhatsApp global del encabezado */
.global-whatsapp {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  white-space: nowrap;
  color: #159447;
  font-size: .84rem;
  font-weight: 700;
  text-decoration: none;
  padding: 7px 10px;
  border-radius: 999px;
  background: #eefbf3;
  border: 1px solid #d6f4e1;
}

.global-whatsapp:hover {
  background: #e3f8eb;
}

.branch-whatsapp {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  width: fit-content;
  margin-top: 12px;
  color: #159447;
  font-size: .88rem;
  font-weight: 700;
  text-decoration: none;
}

.branch-whatsapp:hover {
  text-decoration: underline;
}

.menu-toggle {
  display: none;
  background: none;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  cursor: pointer;
}

.menu-toggle svg { display: block; }

/* ---------------------------------------------------------
   Buscador
   --------------------------------------------------------- */

.search-section {
  background: var(--color-bg-soft);
  border-bottom: 1px solid var(--color-border);
  padding: 24px 24px;
}

.search-section__inner {
  max-width: 640px;
  margin: 0 auto;
  text-align: center;
}

.search-section__title {
  font-size: 1.05rem;
  font-weight: 600;
  margin: 0 0 16px;
  color: var(--color-text);
}

.search-form {
  position: relative;
  display: flex;
}

.search-form input[type="search"] {
  width: 100%;
  padding: 13px 46px 13px 16px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-bg);
  font-size: .95rem;
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}

.search-form input[type="search"]:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(29, 78, 216, .12);
}

.search-form__submit {
  position: absolute;
  right: 6px;
  top: 6px;
  bottom: 6px;
  width: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--color-text-muted);
}

.search-form__submit:hover {
  background: var(--color-border);
  color: var(--color-text);
}

.search-hint {
  margin: 12px 0 0;
  font-size: .8rem;
  color: var(--color-text-faint);
}

/* ---------------------------------------------------------
   Categorías
   --------------------------------------------------------- */

.categories-bar {
  border-bottom: 1px solid var(--color-border);
}

.categories-bar__row {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding: 14px 0;
  scrollbar-width: thin;
}

.categories-bar__row::-webkit-scrollbar { height: 5px; }
.categories-bar__row::-webkit-scrollbar-thumb { background: var(--color-border); border-radius: 10px; }

.pill {
  flex: 0 0 auto;
  padding: 7px 16px;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  font-size: .84rem;
  color: var(--color-text-muted);
  white-space: nowrap;
  transition: background .15s ease, color .15s ease, border-color .15s ease;
}

.pill:hover {
  border-color: var(--color-primary);
  color: var(--color-text);
}

.pill.is-active {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: #fff;
}

.categories-toggle {
  display: none;
}

.categories-modal {
  display: none;
}

.categories-modal.is-open {
  display: block;
  position: fixed;
  inset: 0;
  z-index: 60;
}

.categories-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(16, 18, 22, .45);
}

.categories-modal__panel {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  max-height: 75vh;
  overflow-y: auto;
  background: var(--color-bg);
  border-radius: 18px 18px 0 0;
  padding: 20px 20px 28px;
  box-shadow: var(--shadow-md);
}

.categories-modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.categories-modal__header h2 {
  font-size: 1rem;
  margin: 0;
}

.categories-modal__close {
  background: none;
  border: none;
  font-size: 1.3rem;
  line-height: 1;
  color: var(--color-text-muted);
  cursor: pointer;
  padding: 4px;
}

.categories-modal__list {
  display: flex;
  flex-direction: column;
}

.categories-modal__list a {
  padding: 13px 4px;
  border-bottom: 1px solid var(--color-border);
  font-size: .95rem;
  color: var(--color-text);
}

.categories-modal__list a.is-active {
  color: var(--color-primary);
  font-weight: 600;
}

/* ---------------------------------------------------------
   Listado / grid de productos
   --------------------------------------------------------- */

.catalog-main {
  padding: 24px 0 56px;
  transition: opacity .12s ease;
}

.catalog-main[aria-busy="true"] {
  opacity: .55;
}

.catalog-meta {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 18px;
  color: var(--color-text-muted);
  font-size: .85rem;
}

.product-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
}

.product-card {
  position: relative;
  display: block;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-bg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: box-shadow .15s ease, transform .15s ease, border-color .15s ease;
}

.product-card:hover {
  box-shadow: var(--shadow-md);
  border-color: #c7cfdb;
  transform: translateY(-2px);
}

/* Enlace "estirado": cubre toda la tarjeta y lleva al detalle del
   producto, sin envolver físicamente al botón de WhatsApp (que es un
   <a> hermano, no anidado) — así los dos son clicables por separado. */
.product-card__link {
  position: absolute;
  inset: 0;
  z-index: 1;
}

.whatsapp-btn {
  position: relative;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  align-self: flex-start;
  margin-top: 4px;
  padding: 5px 10px;
  border-radius: 999px;
  background: #25d366;
  color: #fff;
  font-size: .72rem;
  font-weight: 700;
  text-decoration: none;
  line-height: 1;
}

.whatsapp-btn:hover {
  background: #1ebe5b;
}

.whatsapp-btn--lg {
  margin-top: 12px;
  padding: 10px 18px;
  font-size: .85rem;
}

.product-card__image {
  position: relative;
  aspect-ratio: 1 / 1;
  background: var(--color-bg-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border-bottom: 1px solid var(--color-border);
}

.product-card__image--placeholder {
  background: linear-gradient(180deg, #f8f9fb 0%, #eef0f3 100%);
}

.product-card__image img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 10px;
}

.product-card__image--placeholder img {
  padding: 16px;
  opacity: .92;
}

.product-card__category {
  position: absolute;
  top: 6px;
  left: 6px;
  z-index: 1;
  font-size: .62rem;
  font-weight: 700;
  letter-spacing: .03em;
  text-transform: uppercase;
  color: var(--color-primary-dark);
  background: rgba(255, 255, 255, .92);
  border: 1px solid var(--color-border);
  border-radius: 999px;
  padding: 2px 8px;
  max-width: calc(60% - 12px);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.product-card__sucursal {
  position: absolute;
  top: 6px;
  right: 6px;
  z-index: 1;
  font-size: .62rem;
  font-weight: 700;
  letter-spacing: .01em;
  color: #fff;
  background: var(--color-primary-dark);
  border-radius: 999px;
  padding: 2px 8px;
  max-width: calc(60% - 12px);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.product-card__body {
  padding: 10px 12px 12px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.product-card__name {
  font-size: .82rem;
  font-weight: 600;
  line-height: 1.28;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 2.1em;
}

.product-card__meta {
  font-size: .72rem;
  color: var(--color-text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.product-card__description {
  font-size: .72rem;
  color: var(--color-text-muted);
  line-height: 1.35;
  white-space: normal;
  overflow-wrap: break-word;
}

.product-card__price {
  font-size: 1rem;
  font-weight: 800;
  margin-top: 3px;
  color: var(--color-primary-dark);
}

.product-card__stock {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: .7rem;
  font-weight: 600;
  color: var(--color-available);
  background: #eafaf0;
  border-radius: 999px;
  padding: 2px 8px 2px 7px;
  width: fit-content;
}

.dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--color-available);
  flex: 0 0 auto;
}

.dot.is-out { background: var(--color-out); }

.product-card__branch {
  font-size: .68rem;
  color: var(--color-text-faint);
  padding-top: 2px;
  border-top: 1px dashed var(--color-border);
  margin-top: 3px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.badge-out {
  display: inline-block;
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--color-out);
  background: #fdecec;
  border-radius: 999px;
  padding: 3px 10px;
  width: fit-content;
}

.empty-state {
  text-align: center;
  padding: 90px 20px;
  color: var(--color-text-muted);
}

.empty-state h2 {
  font-size: 1.1rem;
  color: var(--color-text);
  margin: 14px 0 6px;
}

.empty-state p {
  margin: 0;
  font-size: .9rem;
}

/* ---------------------------------------------------------
   Paginación
   --------------------------------------------------------- */

.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 6px;
  margin-top: 44px;
  flex-wrap: wrap;
}

.pagination a,
.pagination span {
  min-width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  font-size: .87rem;
  color: var(--color-text-muted);
  padding: 0 10px;
}

.pagination a:hover {
  background: var(--color-bg-soft);
  color: var(--color-text);
}

.pagination .is-current {
  background: var(--color-text);
  color: #fff;
  font-weight: 600;
}

.pagination .is-disabled {
  opacity: .35;
}

/* ---------------------------------------------------------
   Páginas simples (categorías, sucursales)
   --------------------------------------------------------- */

.page-header {
  padding: 36px 0 8px;
}

.page-header h1 {
  font-size: 1.4rem;
  margin: 0 0 6px;
}

.page-header p {
  margin: 0;
  color: var(--color-text-muted);
  font-size: .92rem;
}

.simple-list {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  padding: 24px 0 56px;
}

.simple-card {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 18px;
  transition: border-color .15s ease, box-shadow .15s ease;
}

.simple-card:hover {
  border-color: #d7dbe2;
  box-shadow: var(--shadow-sm);
}

.simple-card strong {
  display: block;
  font-size: .96rem;
  margin-bottom: 4px;
}

.simple-card span {
  font-size: .82rem;
  color: var(--color-text-muted);
}

/* ---------------------------------------------------------
   Detalle de producto
   --------------------------------------------------------- */

.breadcrumb {
  font-size: .82rem;
  color: var(--color-text-faint);
  padding: 22px 0 0;
}

.breadcrumb a:hover { color: var(--color-text-muted); }

.product-detail {
  display: grid;
  grid-template-columns: minmax(0, 460px) 1fr;
  gap: 48px;
  padding: 24px 0 60px;
  align-items: start;
}

.gallery__radio { display: none; }

.gallery__stage {
  position: relative;
  aspect-ratio: 1 / 1;
  background: var(--color-bg-soft);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.gallery__slide {
  display: none;
  position: absolute;
  inset: 0;
  align-items: center;
  justify-content: center;
  cursor: default;
}

.gallery__slide img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 24px;
}

#g0:checked ~ .gallery__stage .slide-0,
#g1:checked ~ .gallery__stage .slide-1,
#g2:checked ~ .gallery__stage .slide-2,
#g3:checked ~ .gallery__stage .slide-3,
#g4:checked ~ .gallery__stage .slide-4 {
  display: flex;
}

.gallery__thumbs {
  display: flex;
  gap: 10px;
  margin-top: 12px;
}

.gallery__thumb {
  width: 60px;
  height: 60px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
  overflow: hidden;
  background: var(--color-bg-soft);
  cursor: pointer;
}

.gallery__thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 6px;
}

.product-info__category {
  font-size: .82rem;
  color: var(--color-primary);
  font-weight: 600;
  margin: 0 0 8px;
}

.product-info h1 {
  font-size: 1.5rem;
  margin: 0 0 6px;
  line-height: 1.3;
}

.product-info__meta {
  color: var(--color-text-muted);
  font-size: .92rem;
  margin: 0 0 18px;
}

.product-info__price {
  font-size: 1.9rem;
  font-weight: 800;
  margin: 0 0 14px;
}

.product-info__description {
  color: var(--color-text-muted);
  font-size: .92rem;
  line-height: 1.6;
  margin: 0 0 24px;
}

.stock-table {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
  margin-bottom: 24px;
}

.stock-table__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  font-size: .88rem;
}

.stock-table__row + .stock-table__row {
  border-top: 1px solid var(--color-border);
}

.stock-table__branch {
  color: var(--color-text);
}

.stock-table__branch span {
  display: block;
  font-size: .76rem;
  color: var(--color-text-faint);
}

.stock-table__qty {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--color-text-muted);
  font-weight: 600;
}

.variant-block {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  margin-bottom: 14px;
}

.variant-block__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 10px;
}

.variant-block__head strong {
  font-size: .96rem;
}

.variant-block__price {
  font-weight: 700;
}

.section-title {
  font-size: .78rem;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--color-text-faint);
  margin: 0 0 12px;
}

/* ---------------------------------------------------------
   Footer
   --------------------------------------------------------- */

.site-footer {
  border-top: 1px solid var(--color-border);
  padding: 28px 0;
  color: var(--color-text-faint);
  font-size: .82rem;
}

/* ---------------------------------------------------------
   Responsive
   --------------------------------------------------------- */

@media (max-width: 900px) {
  .product-detail {
    grid-template-columns: 1fr;
    gap: 28px;
  }
}

@media (max-width: 720px) {
  .container { padding: 0 16px; }

  .global-whatsapp {
    margin-left: auto;
    font-size: .76rem;
    padding: 6px 8px;
    gap: 5px;
  }

  .global-whatsapp svg { width: 16px; height: 16px; }

  .main-nav { display: none; }

  .main-nav.is-open {
    display: flex;
    position: absolute;
    top: var(--header-h);
    left: 0; right: 0;
    background: var(--color-bg);
    border-bottom: 1px solid var(--color-border);
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding: 6px 16px 14px;
  }

  .main-nav.is-open a {
    padding: 12px 4px;
    border-bottom: 1px solid var(--color-border);
  }

  .menu-toggle { display: flex; align-items: center; justify-content: center; }

  .categories-bar > .container { display: none; }

  .categories-toggle {
    display: block;
    width: 100%;
    text-align: left;
    padding: 12px 16px;
    background: var(--color-bg);
    border: none;
    border-bottom: 1px solid var(--color-border);
    font-size: .88rem;
    color: var(--color-text-muted);
    cursor: pointer;
  }

  .search-section { padding: 28px 16px; }
}

@media (max-width: 560px) {
  .product-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 12px;
  }
}