/* ============================================
   Catalogue V2 — Redesigned with /ux-standard + /frontend-design
   Font: Outfit | Zero dependencies | ~11KB
   ============================================ */

/* ---------- CSS Custom Properties ---------- */
:root {
  --bg: #f5f5f7;
  --bg-card: #ffffff;
  --bg-header: rgba(245,245,247,0.97);
  --text: #1d1d1f;
  --text-secondary: #6e6e73;
  --border: #d2d2d7;
  --accent: #6366f1;
  --accent-hover: #4f46e5;
  --accent-subtle: rgba(99,102,241,0.07);
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.04), 0 0 1px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.07), 0 1px 3px rgba(0,0,0,0.04);
  --shadow-lg: 0 12px 40px rgba(0,0,0,0.1), 0 2px 8px rgba(0,0,0,0.04);
  --radius: 14px;
  --radius-sm: 10px;
  --transition: 0.2s ease;
  --max-w: 1320px;
  --header-h: 72px;
}

[data-theme="dark"] {
  --bg: #0c0d12;
  --bg-card: #161720;
  --bg-header: rgba(12,13,18,0.97);
  --text: #f5f5f7;
  --text-secondary: #86868b;
  --border: #262834;
  --accent: #818cf8;
  --accent-hover: #6366f1;
  --accent-subtle: rgba(129,140,248,0.08);
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.2);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.3);
  --shadow-lg: 0 12px 40px rgba(0,0,0,0.4);
}

/* ---------- Reset ---------- */
*,*::before,*::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Outfit', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

img { display: block; max-width: 100%; height: auto; }
a { color: inherit; text-decoration: none; }
button { cursor: pointer; border: none; background: none; font: inherit; color: inherit; }

/* ---------- Header ---------- */
.cat-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg-header);
  /* backdrop-filter removed for performance */
  border-bottom: 1px solid var(--border);
  padding: 0 1.25rem;
}

.cat-header__inner {
  display: flex;
  align-items: center;
  gap: 1rem;
  max-width: var(--max-w);
  margin: 0 auto;
  height: var(--header-h);
}

.cat-header__logo {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--border);
  box-shadow: var(--shadow-sm);
}

.cat-header__logo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.cat-header__logo-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent);
  color: #fff;
}

.cat-header__info {
  flex: 1;
  min-width: 0;
}

.cat-header__name {
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cat-header__meta {
  font-size: 0.72rem;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 1px;
}

.cat-header__meta svg { flex-shrink: 0; }

/* --- Search --- */
.cat-header__search {
  position: relative;
  width: 280px;
  flex-shrink: 0;
}

.cat-header__search-input {
  width: 100%;
  height: 40px;
  padding: 0 2.5rem 0 1rem;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
  font-size: 0.85rem;
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}

.cat-header__search-input::placeholder { color: var(--text-secondary); }

.cat-header__search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-subtle);
}

.cat-header__search-icon {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-secondary);
  pointer-events: none;
}

.cat-header__search-clear {
  position: absolute;
  right: 36px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-secondary);
  padding: 4px;
  display: none;
}

.cat-header__search-clear.visible { display: block; }

/* --- Category Nav --- */
.cat-header__nav {
  border-top: 1px solid var(--border);
  overflow: hidden;
}

.cat-header__nav-inner {
  display: flex;
  gap: 0.4rem;
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0.5rem 0;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.cat-header__nav-inner::-webkit-scrollbar { display: none; }

.cat-nav-chip {
  flex-shrink: 0;
  padding: 0.35rem 0.9rem;
  border-radius: 20px;
  font-size: 0.78rem;
  font-weight: 500;
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
  transition: all var(--transition);
  white-space: nowrap;
}

.cat-nav-chip:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-subtle);
}

.cat-nav-chip.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* --- Mobile header --- */
@media (max-width: 640px) {
  .cat-header { padding: 0.75rem 1rem; }
  .cat-header__inner {
    flex-wrap: wrap;
    height: auto;
    gap: 0.75rem;
  }
  .cat-header__search {
    width: 100%;
    order: 3;
  }
  .cat-header__meta { display: none; }
  .cat-header__nav-inner { padding: 0.5rem 0; }
}

/* ---------- Main Content ---------- */
.cat-main {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 1.75rem 1.25rem 4rem;
}

.cat-main__title {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 1rem;
  color: var(--fg);
}

/* ---------- Search Results Counter ---------- */
.cat-results {
  display: none;
  font-size: 0.82rem;
  color: var(--text-secondary);
  margin-bottom: 1.25rem;
  padding: 0.5rem 0;
  font-weight: 500;
}

.cat-results.visible { display: block; }

/* ---------- Category Section ---------- */
.cat-section {
  margin-bottom: 0.5rem;
  margin-top: 2.5rem;
}

.cat-section:first-of-type { margin-top: 0; }

.cat-section__title {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  padding-bottom: 0.6rem;
  border-bottom: 2px solid var(--accent);
}

.cat-section__count {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-secondary);
  letter-spacing: 0;
}

/* ---------- Product Grid ---------- */
.cat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 1.25rem;
  margin-bottom: 0.5rem;
  padding-top: 1.25rem;
}

/* ---------- Product Card ---------- */
.product-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  cursor: pointer;
  position: relative;
  transition: box-shadow var(--transition);
}

.product-card:hover {
  box-shadow: var(--shadow-md);
}

/* --- Image area --- */
.product-card__img-wrap {
  position: relative;
  aspect-ratio: 4/3;
  background: var(--bg);
  overflow: hidden;
}

.product-card__img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Shimmer skeleton for images */
.product-card__img-wrap::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.06) 50%, transparent 100%);
  background-size: 200% 100%;
  animation: shimmer 2s linear infinite;
  z-index: 1;
  pointer-events: none;
}

.product-card__img-wrap.loaded::before { display: none; }

/* "Ver detalles" overlay removed for performance */

/* Image error fallback placeholder */
.product-card__img-wrap.img-error::before {
  animation: none;
  background: none;
}

.product-card__placeholder {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  opacity: 0.2;
  z-index: 2;
}

.product-card__img-wrap.img-error .product-card__placeholder { display: flex; }
.product-card__img-wrap.img-error .product-card__img { visibility: hidden; }

@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

/* Discount badge */
.product-card__badge {
  position: absolute;
  top: 10px;
  left: 10px;
  background: var(--cat-danger, #ef4444);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.2rem 0.6rem;
  border-radius: 6px;
  z-index: 4;
  letter-spacing: 0.01em;
}

/* --- Card body --- */
.product-card__body {
  padding: 0.85rem 1rem 1rem;
}

.product-card__name {
  font-size: 0.85rem;
  font-weight: 600;
  line-height: 1.35;
  margin-bottom: 0.25rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  letter-spacing: -0.005em;
}

.product-card__sku {
  font-size: 0.7rem;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
  font-weight: 400;
  letter-spacing: 0.01em;
}

.product-card__price {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: -0.01em;
}

.product-card__price-range {
  font-size: 0.78rem;
  font-weight: 400;
  color: var(--text-secondary);
}

.product-card__stock-out {
  font-size: 0.72rem;
  color: #ef4444;
  font-weight: 600;
  margin-top: 0.3rem;
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.product-card__stock-out::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #ef4444;
  flex-shrink: 0;
}

/* ---------- No Results ---------- */
.cat-empty {
  display: none;
  text-align: center;
  padding: 5rem 1rem;
  color: var(--text-secondary);
}

.cat-empty.visible { display: block; }

.cat-empty svg {
  width: 56px;
  height: 56px;
  margin: 0 auto 1.25rem;
  opacity: 0.3;
}

.cat-empty__title {
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 0.35rem;
  color: var(--text);
  letter-spacing: -0.01em;
}

.cat-empty p {
  font-size: 0.85rem;
  color: var(--text-secondary);
  max-width: 280px;
  margin: 0 auto;
}

/* ---------- Product Modal ---------- */
.cat-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0,0,0,0.6);
  /* backdrop-filter removed for performance */
  display: flex;
  align-items: flex-end;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
}

.cat-modal-overlay.open {
  opacity: 1;
  visibility: visible;
}

.cat-modal {
  background: var(--bg-card);
  width: 100%;
  max-width: 720px;
  height: 85vh;
  border-radius: 20px 20px 0 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

@media (min-width: 641px) {
  .cat-modal-overlay { align-items: center; padding: 2rem; }
  .cat-modal {
    border-radius: 20px;
    height: 80vh;
  }
}

/* Modal loading skeleton */
.cat-modal__skeleton {
  padding: 1.5rem;
}

.cat-modal__skeleton-row {
  display: flex;
  gap: 1.25rem;
}

.cat-modal__skeleton-img {
  width: 200px;
  height: 150px;
  border-radius: var(--radius-sm);
  background: var(--bg);
  flex-shrink: 0;
}

.cat-modal__skeleton-lines {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  padding-top: 0.25rem;
}

.cat-modal__skeleton-line {
  height: 14px;
  border-radius: 7px;
  background: var(--bg);
  opacity: 0.5;
}

.cat-modal__skeleton-line:nth-child(1) { width: 70%; height: 18px; }
.cat-modal__skeleton-line:nth-child(2) { width: 40%; }
.cat-modal__skeleton-line:nth-child(3) { width: 55%; }
.cat-modal__skeleton-line:nth-child(4) { width: 30%; }
.cat-modal__skeleton-line:nth-child(5) { width: 85%; margin-top: 0.5rem; }

@media (max-width: 640px) {
  .cat-modal__skeleton-row { flex-direction: column; }
  .cat-modal__skeleton-img { width: 100%; height: 180px; }
}

/* External close row — hidden, close button is inside modal-header */
.cat-modal__close { display: none; }

/* Modal body wrapper */
.cat-modal__body {
  padding: 1rem 1.5rem 1rem;
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* --- Reset Bootstrap wrappers — flex chain for sticky footer --- */
.cat-modal .modal-dialog,
.cat-modal .modal-content {
  all: unset;
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

/* --- Modal header — fixed at top --- */
.cat-modal .modal-header {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  padding: 0.25rem 0 0.6rem;
  margin-bottom: 0;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.cat-modal .modal-header .close,
.cat-modal .modal-header .btn-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  min-width: 32px;
  border-radius: 50%;
  background: var(--bg);
  border: 1px solid var(--border);
  cursor: pointer;
  font-size: 0;
  padding: 0;
  margin: 0;
  /* Fixed top-right corner of the modal */
  position: absolute;
  top: 12px;
  right: 16px;
  z-index: 10;
  background-image: none;
}

.cat-modal .modal-header .close::before,
.cat-modal .modal-header .close::after,
.cat-modal .modal-header .btn-close::before,
.cat-modal .modal-header .btn-close::after {
  content: '';
  position: absolute;
  width: 14px;
  height: 2px;
  background: var(--text);
  border-radius: 1px;
}

.cat-modal .modal-header .close::before,
.cat-modal .modal-header .btn-close::before { transform: rotate(45deg); }

.cat-modal .modal-header .close::after,
.cat-modal .modal-header .btn-close::after { transform: rotate(-45deg); }

.cat-modal .modal-header .close:hover,
.cat-modal .modal-header .btn-close:hover { background: var(--border); }

.cat-modal .modal-header .modal-title {
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.4;
  color: var(--text);
  letter-spacing: -0.01em;
  padding-right: 40px;
}

/* --- Modal body layout — scrollable area --- */
.cat-modal .modal-body {
  padding: 1rem 0 0;
  flex: 1;
  overflow-y: auto;
  min-height: 0;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.cat-modal .modal-body .row {
  display: flex;
  flex-wrap: wrap;
  gap: 1.25rem;
}

.cat-modal .modal-body .col-md-4 {
  flex: 0 0 220px;
  max-width: 220px;
}

.cat-modal .modal-body .col-md-8 {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.cat-modal .modal-body .col-md-12 {
  width: 100%;
  padding: 0;
  margin: 0;
  float: none;
}

/* Thumbnail */
.cat-modal .modal-body .thumbnail {
  border-radius: var(--radius-sm);
  overflow: hidden;
  position: relative;
  background: var(--bg);
  border: 1px solid var(--border);
  margin: 0;
  padding: 0;
}

.cat-modal .modal-body .thumbnail img {
  width: 100%;
  display: block;
  border-radius: var(--radius-sm);
}

.cat-modal .modal-body .discount-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  background: #ef4444;
  color: #fff;
  padding: 0.2rem 0.55rem;
  border-radius: 6px;
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1.4;
}

/* Price line */
.cat-modal .modal-body .lead {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--accent);
  margin: 0 0 0.5rem;
  padding: 0;
  line-height: 1.4;
  letter-spacing: -0.01em;
}

.cat-modal .modal-body br { display: none; }
.cat-modal .modal-body td[colspan="2"] ul ~ br,
.cat-modal .modal-body td[colspan="2"] ol ~ br { display: inline; }

/* Info table */
.cat-modal .modal-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 0;
}

.cat-modal .modal-body table th,
.cat-modal .modal-body table td {
  padding: 0.35rem 0;
  text-align: left;
  font-size: 0.82rem;
  vertical-align: baseline;
  line-height: 1.5;
  border: none;
}

.cat-modal .modal-body table th {
  color: var(--text-secondary);
  font-weight: 500;
  white-space: nowrap;
  width: 110px;
  padding-right: 0.75rem;
}

.cat-modal .table { margin-bottom: 0; }
.cat-modal .table.no-border td,
.cat-modal .table.no-border th { border: none; }
.cat-modal .table-slim th,
.cat-modal .table-slim td { padding: 0.3rem 0; padding-right: 0.75rem; }

/* Description cell */
.cat-modal .modal-body td[colspan="2"] {
  padding-top: 0.6rem;
  border-top: 1px solid var(--border);
  font-size: 0.82rem;
  line-height: 1.7;
  color: var(--text);
}

.cat-modal .modal-body td[colspan="2"] ul {
  margin: 0.15rem 0;
  padding-left: 1.2rem;
}

.cat-modal .modal-body td[colspan="2"] li { margin-bottom: 0.15rem; }
.cat-modal .modal-body td[colspan="2"] p { margin: 0 0 0.4rem; }

/* Out of stock in modal */
.cat-modal .text-muted {
  color: #ef4444;
  font-size: 0.8rem;
}

.cat-modal .display_currency {
  color: var(--accent);
  font-weight: 700;
}

/* Modal footer — fixed at bottom */
.cat-modal .modal-footer {
  padding: 0.75rem 0;
  margin-top: 0;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  flex-shrink: 0;
}

.cat-modal .modal-footer .tw-dw-btn-neutral,
.cat-modal .modal-footer button[data-dismiss="modal"],
.cat-modal .modal-footer button[data-bs-dismiss="modal"],
.cat-modal .modal-footer .btn-secondary {
  all: unset;
  cursor: pointer;
  padding: 0.5rem 1.5rem;
  background: var(--accent);
  color: #fff;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 600;
  font-family: inherit;
  transition: background var(--transition);
}

.cat-modal .modal-footer button:hover {
  background: var(--accent-hover);
}

/* Modal responsive */
@media (max-width: 640px) {
  .cat-modal__body { padding: 0.5rem 1rem 1.25rem; }
  .cat-modal .modal-body .row { gap: 1rem; }
  .cat-modal .modal-body .col-md-4 {
    flex: 0 0 160px;
    max-width: 160px;
    margin: 0 auto;
  }
  .cat-modal .modal-body .col-md-8 {
    flex: 1 1 100%;
  }
}

/* ---------- Footer ---------- */
.cat-footer {
  text-align: center;
  padding: 2.5rem 1rem;
  font-size: 0.78rem;
  color: var(--text-secondary);
  border-top: 1px solid var(--border);
  letter-spacing: 0.01em;
}

/* ---------- Scroll to Top ---------- */
.cat-scroll-top {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-md);
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px);
  transition: all var(--transition);
  z-index: 50;
}

.cat-scroll-top.visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.cat-scroll-top:hover { background: var(--accent-hover); }

/* ---------- Currency display ---------- */
.display_currency { font-weight: 600; }

/* ---------- Print ---------- */
@media print {
  .cat-header, .cat-scroll-top, .cat-modal-overlay, .no-print { display: none !important; }
  .cat-main { padding-top: 0; }
  .product-card {
    break-inside: avoid;
    box-shadow: none;
    border: 1px solid #ccc;
  }
}
