:root {
  --bg: #ffffff;
  --bg-alt: #f6f6f4;
  --ink: #1c1917;
  --muted: #78716c;
  --line: #e7e5e4;
  --brand: #136f63;
  --brand-ink: #0d4f46;
  --action: #f7e310;
  --surface: #fdfdfd;
  --text: #7a7a7a;
  --warn: #b91c1c;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

* { box-sizing: border-box; }

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

body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.5;
}

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

.container { max-width: none; width: 100%; margin: 0 auto; padding: 0 1rem; }

/* Layout: columna izquierda (configurable) + contenido */
.layout { display: flex; align-items: flex-start; }
.aside-left {
  flex: 0 0 250px; min-width: 250px;
  display: none;
  padding: 1.25rem 1rem 3rem 0;
  position: sticky; top: 56px; align-self: flex-start;
  max-height: calc(100vh - 56px); overflow-y: auto;
}
@media (min-width: 1024px) { .aside-left { display: block; } }
.content { flex: 1; min-width: 0; padding: 1.25rem 0 3rem; }

/* Bloqueo de scroll con drawer abierto */
.no-scroll { overflow: hidden; }

/* Número de artículos por fila (configurable por usuario) */
.cards[data-cols="1"] { grid-template-columns: repeat(1, 1fr); }
.cards[data-cols="2"] { grid-template-columns: repeat(2, 1fr); }
.cards[data-cols="5"] { grid-template-columns: repeat(5, 1fr); }
.cards[data-cols="10"] { grid-template-columns: repeat(10, 1fr); }

/* Header */
.header {
  background: var(--surface);
  color: var(--text);
  border-bottom: 1px solid #eeeeee;
  position: sticky;
  top: 0;
  z-index: 40;
}
.header-inner {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: nowrap;
  padding: 0.7rem 0;
}
@media (min-width: 1024px) {
  .header-inner { display: flex; align-items: center; }
}
.brand { font-weight: 800; font-size: 1.25rem; letter-spacing: 0.02em; color: var(--text); display: flex; align-items: center; gap: 0.5rem; }
.brand-logo { height: 34px; width: auto; display: block; }
.search-form { display: flex; gap: 0.4rem; }
.search-form input[type=search] {
  flex: 1;
  padding: 0.55rem 0.75rem;
  border-radius: 8px;
  border: 1px solid #e5e5e5;
  background: #fff;
  color: var(--text);
  font-size: 0.95rem;
}
.btn {
  display: inline-flex; align-items: center; gap: 0.35rem;
  padding: 0.55rem 0.9rem;
  border-radius: 8px;
  border: 1px solid transparent;
  background: var(--action);
  color: #1c1917;
  font-weight: 600;
  cursor: pointer;
}
.btn:hover { background: #e6d60e; color: #1c1917; }
.btn-ghost { background: transparent; border-color: #dddddd; color: var(--text); }
.btn-ghost:hover { background: #f4f4f4; color: var(--text); }
.header-actions { display: flex; gap: 0.35rem; align-items: center; flex-wrap: nowrap; margin-left: auto; }

.locale-switch { display: flex; gap: 0.15rem; font-size: 0.85rem; }
.locale-switch a {
  padding: 0.2rem 0.45rem;
  border-radius: 6px;
  color: var(--text);
}
.locale-switch a.active { background: var(--action); color: #1c1917; font-weight: 700; }

.context-form { display: flex; gap: 0.35rem; align-items: center; }
.context-form select { padding: 0.4rem; border-radius: 8px; border: 1px solid var(--line); background: #fff; }
.context-form label { font-size: 0.75rem; color: #d6d3d1; }

/* Cards */
.cards {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
}
.card {
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  background: #fff;
  display: flex;
  flex-direction: column;
  transition: box-shadow 0.15s ease, transform 0.15s ease;
}
.card:hover { box-shadow: 0 6px 18px rgba(0,0,0,0.09); transform: translateY(-2px); }
.card img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; background: var(--bg-alt); }
.card-body { padding: 0.6rem 0.75rem 0.8rem; display: flex; flex-direction: column; gap: 0.25rem; }
.card-title { font-weight: 600; font-size: 0.95rem; line-height: 1.25; min-height: 2.4em; }
.card-meta { color: var(--muted); font-size: 0.75rem; }
.card-price { font-weight: 800; color: var(--brand-ink); font-size: 1rem; margin-top: auto; }

/* Sidebar derecha (off-canvas) */
.drawer-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 60;
  display: block;
  opacity: 1;
  transition: opacity 0.2s ease;
}
.drawer-backdrop.hidden { display: none !important; opacity: 0; }
.drawer {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: min(92vw, 400px);
  background: #fff;
  z-index: 70;
  transform: translateX(100%);
  transition: transform 0.2s ease;
  display: flex;
  flex-direction: column;
  box-shadow: -8px 0 24px rgba(0,0,0,0.15);
}
.drawer.open { transform: translateX(0); }
.drawer-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 0.9rem 1.1rem;
  border-bottom: 1px solid var(--line);
  font-weight: 700;
}
.drawer-body { flex: 1; overflow-y: auto; padding: 1rem 1.1rem; }

/* Menú lateral */
.menu { list-style: none; margin: 0; padding: 0; }
.menu li { margin: 0.15rem 0; }
.menu a { display: block; padding: 0.45rem 0.6rem; border-radius: 8px; }
.menu a:hover { background: var(--bg-alt); }
.menu .sub { list-style: none; padding-left: 1rem; }

/* Vista de producto */
.product-grid { display: grid; gap: 1.5rem; grid-template-columns: 1fr; }
@media (min-width: 900px) { .product-grid { grid-template-columns: 1fr 1fr; } }
.product-gallery img { width: 100%; border-radius: 12px; }
/* Galería: contenedor ancho máx 100% con scroll horizontal (móvil) */
.product-gallery { width: 100%; max-width: 100%; overflow: hidden; }
.thumbnails {
  display: flex; gap: 0.5rem; margin-top: 0.5rem;
  overflow-x: auto; overflow-y: hidden;
  max-width: 100%;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  padding-bottom: 0.25rem;
}
.thumbnails::-webkit-scrollbar { height: 6px; }
.thumbnails::-webkit-scrollbar-thumb { background: var(--line); border-radius: 3px; }
.thumbnails img { flex: 0 0 auto; }
.thumbnails img { width: 72px; aspect-ratio: 1; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }
.price-lg { font-size: 1.6rem; font-weight: 800; color: var(--brand-ink); }
.badge { display: inline-block; padding: 0.15rem 0.5rem; border-radius: 999px; font-size: 0.75rem; font-weight: 700; }
.badge.parent { background: #eef2ff; color: #3730a3; }
.badge.orphan { background: #ecfdf5; color: #065f46; }

/* Listados comerciales */
.section-title { font-size: 1.2rem; font-weight: 800; margin: 1.25rem 0 0.75rem; }
.toolbar { display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: center; justify-content: space-between; margin-bottom: 1rem; }
.toolbar select { padding: 0.45rem; border-radius: 8px; border: 1px solid var(--line); }

.pagination { display: flex; gap: 0.35rem; justify-content: center; margin-top: 2rem; flex-wrap: wrap; }
.pagination a, .pagination span {
  min-width: 2.2rem; text-align: center; padding: 0.45rem 0.2rem;
  border-radius: 8px; border: 1px solid var(--line);
}
.pagination .current { background: var(--brand); color: #fff; border-color: var(--brand); }

/* Footer */
.footer { border-top: 1px solid var(--line); background: var(--bg-alt); padding: 2rem 0; margin-top: 2rem; }
.footer-inner { display: flex; flex-wrap: wrap; gap: 1rem; justify-content: space-between; color: var(--muted); font-size: 0.85rem; }

.hidden { display: none !important; }
.muted { color: var(--muted); }
.mt-1 { margin-top: 1rem; }
.mb-1 { margin-bottom: 1rem; }
.grid-collapsible { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.grid-collapsible summary { cursor: pointer; padding: 0.7rem 1rem; font-weight: 700; background: var(--bg-alt); }

table.spec { width: 100%; border-collapse: collapse; }
table.spec th, table.spec td { text-align: left; padding: 0.5rem 0.6rem; border-bottom: 1px solid var(--line); }
table.spec th { color: var(--muted); font-weight: 600; width: 40%; }

.empty { text-align: center; padding: 3rem 1rem; color: var(--muted); }

/* Carrito */
.cart-lines { display: flex; flex-direction: column; gap: 0.9rem; }
.cart-line { border: 1px solid var(--line); border-radius: 10px; padding: 0.6rem 0.75rem; display: flex; flex-direction: column; gap: 0.35rem; }
.cart-line-name { font-weight: 600; }
.cart-line-row { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }
.cart-line-subtotal { color: var(--muted); font-size: 0.85rem; }
.cart-line-remove { align-self: flex-end; }
.cart-delay { font-size: 0.8rem; font-weight: 700; color: var(--brand-ink); background: #ecfdf5; padding: 0.1rem 0.5rem; border-radius: 999px; }
.qty-input { width: 4.5rem; padding: 0.45rem; border-radius: 8px; border: 1px solid var(--line); text-align: center; }
.badge.warn { background: #fef2f2; color: var(--warn); }
.card-add { padding: 0 0.75rem 0.75rem; }
.card-add .btn { width: 100%; justify-content: center; }

/* Checkout */
.checkout-fields { display: grid; gap: 0.7rem; grid-template-columns: 1fr; padding: 0.8rem 1rem; }
@media (min-width: 640px) { .checkout-fields { grid-template-columns: 1fr 1fr; } }
.checkout-fields label { display: flex; flex-direction: column; gap: 0.25rem; font-size: 0.85rem; font-weight: 600; }
.checkout-fields input { padding: 0.5rem 0.7rem; border-radius: 8px; border: 1px solid var(--line); }
.checkout-payments { padding: 0.8rem 1rem; display: flex; flex-direction: column; gap: 0.5rem; }
.payment-option { display: flex; gap: 0.5rem; align-items: center; border: 1px solid var(--line); padding: 0.6rem 0.8rem; border-radius: 8px; cursor: pointer; }
.checkout-form .btn { margin-top: 0.75rem; }

.header-user { color: var(--text); font-size: 0.85rem; }
.login-form { max-width: 22rem; display: flex; flex-direction: column; gap: 0.7rem; margin-top: 0.5rem; }
.login-form label { display: flex; flex-direction: column; gap: 0.25rem; font-weight: 600; font-size: 0.9rem; }
.login-form input { padding: 0.5rem 0.7rem; border-radius: 8px; border: 1px solid var(--line); }
.badge.ok { background: #ecfdf5; color: #065f46; }

.banner { background: #eef2ff; border: 1px solid #c7d2fe; border-radius: 10px; padding: 0.7rem 1rem; margin: 1rem 0; }
.banner-footer { background: transparent; border: none; padding: 0; margin: 1rem 0 0; color: var(--muted); font-size: 0.85rem; }
.blocked-page { max-width: 34rem; margin-top: 4rem; text-align: center; }
.blocked-page h1 { color: var(--warn); }

.drawer-context { display: flex; flex-direction: column; gap: 0.7rem; }
.drawer-context label { display: flex; flex-direction: column; gap: 0.25rem; font-weight: 600; font-size: 0.85rem; }
.drawer-context select, .drawer-context input { padding: 0.5rem 0.7rem; border-radius: 8px; border: 1px solid var(--line); background: #fff; }

/* Submenú: hijos diferenciados */
.sub-item { display: flex; gap: 0.35rem; align-items: flex-start; }
.sub-dash { color: var(--muted); }
.aside-left nav { padding-right: 0.5rem; }

/* Árbol de categorías */
.category-tree { list-style: none; margin: 0; padding: 0; }
.category-tree > li { margin: 0.5rem 0; }
.category-parent { font-weight: 700; }
.category-sub {
  list-style: none; margin: 0.3rem 0 0.3rem 0.5rem; padding-left: 1rem;
  border-left: 1px solid var(--line);
}
.category-sub li { display: flex; gap: 0.4rem; align-items: baseline; padding: 0.2rem 0; }

/* Header: iconos (móvil solo icono, PC icono + texto) */
.header-icon { font-size: 0.9rem; padding: 0.45rem 0.6rem; }
.header-icon-symbol { font-size: 1.2rem; line-height: 1; }
.header-label { display: none; }
.cart-badge {
  background: #1c1917; color: var(--action);
  border-radius: 999px; padding: 0 0.35rem;
  font-size: 0.7rem; font-weight: 700;
}
@media (min-width: 1024px) {
  .header-label { display: inline; }
}

/* Logo móvil: máx 25% del ancho */
@media (max-width: 1023px) {
  .brand-logo { max-width: 25vw; height: auto; }
}

/* Drawer izquierdo (menú móvil) */
.drawer.drawer-left { left: 0; right: auto; transform: translateX(-100%); box-shadow: 8px 0 24px rgba(0,0,0,0.15); }
.drawer.drawer-left.open { transform: translateX(0); }

/* Stepper de cantidad */
.qty-stepper { display: flex; align-items: center; gap: 0.35rem; flex-wrap: wrap; }
.qty-btn {
  width: 2rem; height: 2rem; border-radius: 8px;
  border: 1px solid var(--line); background: #fff;
  font-size: 1.05rem; line-height: 1; cursor: pointer;
}
.qty-btn:hover { background: var(--action); }
.card-add .qty-input { width: 3.2rem; }

/* Toast de confirmación */
.toast {
  position: fixed; top: 0.75rem; right: 0.75rem; z-index: 90;
  background: #1c1917; color: #fff;
  padding: 0.6rem 1rem; border-radius: 8px;
  opacity: 0; transform: translateY(-8px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  pointer-events: none; box-shadow: 0 4px 12px rgba(0,0,0,0.2);
  font-size: 0.9rem;
}
.toast.show { opacity: 1; transform: translateY(0); }

/* Indicador de unidades en carrito */
.in-cart {
  display: inline-block; font-size: 0.78rem; font-weight: 700;
  color: var(--brand-ink); background: #ecfdf5;
  border: 1px solid #a7f3d0; padding: 0.1rem 0.5rem; border-radius: 999px;
}

/* Filtro por subcategorías */
.filter-chips { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.chip {
  border: 1px solid var(--line); border-radius: 999px;
  padding: 0.3rem 0.7rem; font-size: 0.85rem;
  color: var(--text); background: #fff;
}
.chip:hover, .chip.active { background: var(--action); border-color: var(--action); color: #1c1917; }

/* Acciones de tarjeta */
.card-add.qty-stepper .btn { width: auto; flex: 1; }
.qty-stepper .btn { width: auto; }

.category-select { width: 100%; max-width: 26rem; padding: 0.55rem 0.7rem; border-radius: 8px; border: 1px solid var(--line); background: #fff; }

/* Indicador 'En carrito' debajo del stepper */
.card-add .in-cart { flex-basis: 100%; text-align: center; }

/* Móvil con 2 por fila: ocultar botones +/-, input más compacto */
@media (max-width: 1023px) {
  .cards[data-cols="2"] .qty-btn { display: none; }
  .cards[data-cols="2"] .qty-input { width: 3rem; }
}
@media (min-width: 1024px) {
  .cards[data-cols="10"] .qty-btn { display: none; }
  .cards[data-cols="10"] .qty-input { width: 3rem; }
}

/* Fila del buscador: ancho completo en móvil, centrado y máx 500px en PC */
.header-search-row { padding-bottom: 0.6rem; }
.header-search-row .search-form { width: 100%; max-width: 500px; margin: 0 auto; }

/* Botón bandera */
.flag-btn { padding: 0.3rem 0.5rem !important; }
.flag-emoji { font-size: 1.25rem !important; }

/* Buscador del header: input bien formado */
.header-search-row .search-form { width: 100%; max-width: 500px; margin: 0 auto; }
.header-search-row .search-form input[type=search] {
  width: 100%;
  padding: 0.6rem 0.9rem;
  border-radius: 24px;
  border: 1px solid #e3e3e3;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  font-size: 0.95rem;
  color: var(--text);
}
.header-search-row .search-form input[type=search]:focus {
  outline: none; border-color: var(--action); box-shadow: 0 0 0 3px rgba(247,227,16,0.25);
}
.header-search-row .search-form .btn { border-radius: 24px; }

/* Input del formulario de búsqueda (página) */
.search-input {
  flex: 1;
  padding: 0.6rem 0.9rem;
  border-radius: 24px;
  border: 1px solid #e3e3e3;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  font-size: 0.95rem;
  color: var(--text);
}
.search-input:focus { outline: none; border-color: var(--action); box-shadow: 0 0 0 3px rgba(247,227,16,0.25); }
.toolbar .search-input { min-width: 220px; }

/* Padding a los iconos de borde: hamburguesa (izq) y carrito (der) */
.header-inner > .header-icon:first-child { margin-left: 0; }
.header-actions .header-icon:last-child { margin-right: 0.25rem; }

/* Sidebar ancho (modos hijos / ficha): máx 900px en PC, 100% del ancho en móvil */
.drawer.wide {
  width: min(100vw, 900px);
  max-width: 100%;
}
@media (min-width: 1024px) {
  .drawer.wide { width: min(60vw, 900px); }
}
/* Grid de hijos: igual que la lista (rejilla adaptativa) */
.drawer.wide .cards {
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
}

.thumbs-hint { font-size: 0.72rem; color: var(--muted); margin-top: 0.5rem; }
