/**
 * Markmelo Catálogo — Styles
 * Mobile-first · Lighthouse ≥80 Performance target
 * Paleta: #6B21A8 (morado) + #FF6B35 (naranja CTA) + #F9F7FF (bg)
 *
 * @version 1.0.0
 */

/* ── WRAPPER ──────────────────────────────────────────── */
.mm-cat-wrapper {
  font-family: 'DM Sans', system-ui, sans-serif;
  color: #1C1028;
  max-width: 100%;
}

/* ── SEARCH BAR (sticky) ──────────────────────────────── */
.mm-cat-search-bar {
  position: sticky; top: 0; z-index: 100;
  background: #fff;
  border-bottom: 1px solid #e5e7eb;
  box-shadow: 0 2px 8px rgba(0,0,0,.08);
  padding: 14px 0;
}
.mm-cat-search-inner {
  max-width: 1400px; margin: 0 auto; padding: 0 24px;
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
}
.mm-cat-search-input-wrap {
  flex: 1; min-width: 200px; position: relative;
  display: flex; align-items: center;
}
.mm-cat-search-icon { display: none; }
.mm-cat-search-icon-outer {
  font-size: 1.3rem; flex-shrink: 0; line-height: 1; margin-right: 2px;
}
.mm-cat-search-input {
  width: 100%; padding: 12px 40px 12px 18px;
  border: 2px solid #e5e7eb; border-radius: 50px;
  font-size: 1rem; font-family: inherit;
  transition: border-color .2s, box-shadow .2s;
  background: #f9f8ff;
}
.mm-cat-wrapper--padded { padding: 0 12px; }
@media(min-width:768px) { .mm-cat-wrapper--padded { padding: 0 20px; } }
.mm-cat-search-input:focus {
  outline: none; border-color: #6B21A8;
  box-shadow: 0 0 0 3px rgba(107,33,168,.12);
  background: #fff;
}
.mm-cat-search-clear {
  position: absolute; right: 14px;
  background: none; border: none; cursor: pointer;
  font-size: 1.2rem; color: #9ca3af; line-height: 1;
}
.mm-cat-search-stats {
  font-size: .85rem; color: #6b7280; white-space: nowrap;
}
.mm-cat-filter-toggle {
  display: flex; align-items: center; gap: 6px;
  padding: 10px 18px; border-radius: 50px;
  border: 2px solid #e5e7eb; background: #fff;
  font-size: .9rem; font-weight: 600; cursor: pointer;
  transition: all .2s; position: relative;
}
.mm-cat-filter-toggle:hover,
.mm-cat-filter-toggle.has-filters { border-color: #6B21A8; color: #6B21A8; }
.mm-cat-filter-badge {
  background: #FF6B35; color: #fff;
  font-size: .72rem; font-weight: 800;
  padding: 2px 7px; border-radius: 50px; min-width: 20px; text-align: center;
}

/* ── AUTOCOMPLETE ─────────────────────────────────────── */
.mm-cat-autocomplete {
  position: absolute; top: 100%; left: 0; right: 0; z-index: 200;
  background: #fff; border: 1px solid #e5e7eb;
  border-radius: 12px; box-shadow: 0 8px 24px rgba(0,0,0,.12);
  max-height: 320px; overflow-y: auto;
  margin-top: 4px;
}
.mm-cat-ac-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px; text-decoration: none; color: inherit;
  transition: background .15s;
}
.mm-cat-ac-item:hover { background: #f5f3ff; }
.mm-cat-ac-img { width: 40px; height: 40px; object-fit: cover; border-radius: 8px; flex-shrink: 0; }
.mm-cat-ac-name { font-size: .9rem; font-weight: 600; }
.mm-cat-ac-cat  { font-size: .78rem; color: #9ca3af; }

/* ── LAYOUT ───────────────────────────────────────────── */
.mm-cat-layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 0;
  max-width: 1400px; margin: 0 auto;
  align-items: start;
}
@media(max-width:900px) {
  .mm-cat-layout { grid-template-columns: 1fr; }
}

/* ── SIDEBAR ──────────────────────────────────────────── */
.mm-cat-sidebar {
  position: sticky; top: 70px;
  border-right: 1px solid #e5e7eb;
  height: calc(100vh - 70px);
  overflow-y: auto;
  background: #fff;
}
.mm-cat-sidebar-inner { padding: 24px 20px; }
.mm-cat-sidebar-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 20px; gap: 8px;
}
.mm-cat-sidebar-title { font-size: 1rem; font-weight: 800; color: #280850; margin: 0; }
.mm-cat-clear-all {
  font-size: .78rem; color: #FF6B35; font-weight: 700;
  background: none; border: none; cursor: pointer; padding: 0;
}
.mm-cat-sidebar-close {
  display: none; background: none; border: none;
  font-size: 1.4rem; cursor: pointer; color: #9ca3af;
}

/* Mobile: sidebar drawer */
@media(max-width:900px) {
  .mm-cat-sidebar {
    position: fixed; top: 0; left: 0; height: 100vh;
    width: 300px; z-index: 300; box-shadow: 4px 0 24px rgba(0,0,0,.15);
    transform: translateX(-100%); transition: transform .3s ease;
  }
  .mm-cat-sidebar.is-open { transform: translateX(0); }
  .mm-cat-sidebar-close { display: block; }
  .mm-cat-sidebar-overlay {
    display: none;
    position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 299;
  }
  .mm-cat-sidebar.is-open .mm-cat-sidebar-overlay { display: block; }
}

/* Grupos de filtros */
.mm-cat-filter-group { border-bottom: 1px solid #f3f4f6; }
.mm-cat-filter-group-header {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%; padding: 12px 0; background: none; border: none;
  font-size: .88rem; font-weight: 700; color: #374151; cursor: pointer;
  text-align: left;
}
.mm-cat-filter-arrow { transition: transform .2s; font-size: .75rem; color: #9ca3af; }
.mm-cat-filter-arrow.open { transform: rotate(180deg); }
.mm-cat-filter-body { padding: 4px 0 12px; }
.mm-cat-filter-options { display: flex; flex-direction: column; gap: 6px; max-height: 240px; overflow-y: auto; }
.mm-cat-filter-option {
  display: flex; align-items: center; gap: 8px;
  font-size: .85rem; color: #374151; cursor: pointer;
}
.mm-cat-filter-option input[type="checkbox"],
.mm-cat-filter-option input[type="radio"] {
  accent-color: #6B21A8; width: 16px; height: 16px; flex-shrink: 0;
}
.mm-cat-filter-option:hover { color: #6B21A8; }

/* ── MAIN GRID ────────────────────────────────────────── */
.mm-cat-main { padding: 24px; min-height: 60vh; }

.mm-cat-loading {
  display: flex; flex-direction: column; align-items: center;
  padding: 60px 0; gap: 16px; color: #9ca3af;
}
.mm-cat-spinner {
  width: 40px; height: 40px;
  border: 3px solid #e5e7eb; border-top-color: #6B21A8;
  border-radius: 50%; animation: mm-spin .8s linear infinite;
}
@keyframes mm-spin { to { transform: rotate(360deg); } }

.mm-cat-empty { text-align: center; padding: 60px 0; color: #9ca3af; }
.mm-cat-empty p { margin-bottom: 20px; font-size: 1.05rem; }

.mm-cat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
}
@media(max-width:1200px) { .mm-cat-grid { grid-template-columns: repeat(3,1fr); } }
@media(max-width:900px)  { .mm-cat-grid { grid-template-columns: repeat(2,1fr); } }
@media(max-width:480px)  { .mm-cat-grid { grid-template-columns: 1fr; } }

/* ── PRODUCT CARD ─────────────────────────────────────── */
.mm-cat-product-card {
  border: 1px solid #e5e7eb; border-radius: 14px;
  overflow: hidden; background: #fff;
  transition: all .22s ease; cursor: pointer;
  display: flex; flex-direction: column;
}
.mm-cat-product-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 28px rgba(107,33,168,.15);
  border-color: #6B21A8;
}
.mm-cat-product-img {
  height: 200px; overflow: hidden; background: #f9f8ff;
  display: flex; align-items: center; justify-content: center;
  position: relative;
}
.mm-cat-product-img img {
  width: 100%; height: 100%; object-fit: cover;
  transition: transform .4s ease;
}
.mm-cat-product-card:hover .mm-cat-product-img img { transform: scale(1.05); }
.mm-cat-product-no-img { font-size: 3rem; color: #d1d5db; }
.mm-cat-product-body { padding: 14px 16px 16px; flex: 1; display: flex; flex-direction: column; }
.mm-cat-product-cat { font-size: .72rem; font-weight: 800; text-transform: uppercase; letter-spacing: 1px; color: #6B21A8; margin-bottom: 6px; }
.mm-cat-product-name { font-size: .95rem; font-weight: 700; color: #1C1028; margin-bottom: 8px; line-height: 1.3; }
.mm-cat-product-desc { font-size: .82rem; color: #6b7280; flex: 1; margin-bottom: 12px; line-height: 1.5; }
.mm-cat-product-footer {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding-top: 10px; border-top: 1px solid #f3f4f6;
}
.mm-cat-product-qty { font-size: .78rem; color: #9ca3af; }
.mm-cat-cta-btn {
  background: #FF6B35; color: #fff;
  padding: 7px 14px; border-radius: 50px;
  font-size: .78rem; font-weight: 800;
  text-decoration: none; transition: all .2s;
  white-space: nowrap;
}
.mm-cat-cta-btn:hover { background: #e55a25; transform: translateY(-1px); }

/* ── PAGINATION ───────────────────────────────────────── */
.mm-cat-pagination {
  display: flex; align-items: center; justify-content: center; gap: 20px;
  padding: 32px 0; flex-wrap: wrap;
}
.mm-cat-page-btn {
  padding: 10px 20px; border: 2px solid #e5e7eb; border-radius: 50px;
  background: #fff; font-size: .9rem; font-weight: 700; cursor: pointer;
  transition: all .2s;
}
.mm-cat-page-btn:hover:not(:disabled) { border-color: #6B21A8; color: #6B21A8; }
.mm-cat-page-btn:disabled { opacity: .4; cursor: not-allowed; }
.mm-cat-page-info { font-size: .9rem; color: #6b7280; }

/* ── MODAL ────────────────────────────────────────────── */
.mm-cat-modal-overlay {
  position: fixed; inset: 0; z-index: 500;
  background: rgba(0,0,0,.6); display: flex;
  align-items: center; justify-content: center; padding: 20px;
}
.mm-cat-modal {
  background: #fff; border-radius: 20px;
  max-width: 840px; width: 100%;
  max-height: 90vh; overflow-y: auto;
  position: relative;
}
.mm-cat-modal-close {
  position: sticky; top: 16px; float: right; margin: 16px 16px 0 0;
  background: #f3f4f6; border: none; border-radius: 50%;
  width: 36px; height: 36px; font-size: 1.2rem;
  cursor: pointer; z-index: 10; display: flex; align-items: center; justify-content: center;
}
.mm-cat-modal-inner {
  display: grid; grid-template-columns: 1fr 1fr; gap: 0;
  clear: both;
}
@media(max-width:640px) { .mm-cat-modal-inner { grid-template-columns: 1fr; } }
.mm-cat-modal-img { aspect-ratio: 1; overflow: hidden; border-radius: 20px 0 0 20px; }
.mm-cat-modal-img img { width: 100%; height: 100%; object-fit: cover; }
@media(max-width:640px) { .mm-cat-modal-img { border-radius: 20px 20px 0 0; } }
.mm-cat-modal-body { padding: 28px; }
.mm-cat-modal-body h2 { font-size: 1.2rem; font-weight: 800; margin: 8px 0 14px; }
.mm-cat-modal-body p  { font-size: .9rem; color: #6b7280; line-height: 1.65; margin-bottom: 16px; }
.mm-cat-modal-meta { display: flex; flex-direction: column; gap: 8px; margin-bottom: 24px; }
.mm-cat-modal-meta-item { font-size: .85rem; color: #374151; }
.mm-cat-modal-meta-item strong { color: #280850; }
.mm-cat-modal-actions { display: flex; flex-direction: column; gap: 10px; }

/* ── MODAL DISCLAIMER ─────────────────────────────────── */
.mm-cat-modal-disclaimer {
  margin-top: 12px;
  font-size: .75rem;
  color: #9ca3af;
  text-align: center;
  line-height: 1.5;
}

/* Alpine.js x-cloak */
[x-cloak] { display: none !important; }
