/* Navegación de categorías — includes/theme/category-nav.php */

.sgm-nav,
.sgm-acc {
	--sgm-red: #db1010;
	--sgm-text: #11181c;
	--sgm-muted: #6b7280;
	--sgm-line: #e5e7eb;
	--sgm-soft: #f5f5f6;
	font-family: Inter, system-ui, sans-serif;
}

.sgm-nav-icon { flex-shrink: 0; color: var(--sgm-muted); }
.sgm-nav-chev { flex-shrink: 0; }

/* ---------- Escritorio: barra ---------- */

.sgm-nav {
	position: relative;
	width: 100%;
	background: #fff;
	border-top: 1px solid var(--sgm-line);
}

.sgm-nav__inner {
	max-width: 1440px;
	margin: 0 auto;
	height: 48px;
	display: flex;
	align-items: stretch;
	gap: 0;
}

.sgm-nav__all {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 0 16px;
	margin: 0;
	border: 0;
	border-radius: 0;
	background: transparent;
	color: var(--sgm-text);
	font: 600 14px/1 Inter, system-ui, sans-serif;
	cursor: pointer;
	white-space: nowrap;
}
.sgm-nav__all > svg:first-child { color: var(--sgm-red); }
.sgm-nav__all .sgm-nav-chev { transition: transform .2s ease; color: var(--sgm-muted); }
.sgm-nav__all:hover,
.sgm-nav__all[aria-expanded="true"] { background: var(--sgm-soft); color: var(--sgm-text); }
.sgm-nav__all[aria-expanded="true"] .sgm-nav-chev { transform: rotate(180deg); }

.sgm-nav__bar {
	flex: 1;
	min-width: 0;
	display: flex;
	align-items: stretch;
	justify-content: space-between;
	gap: 4px;
	margin: 0;
	padding: 0 24px;
	list-style: none;
	overflow: hidden;
	border-left: 1px solid var(--sgm-line);
}
.sgm-nav__bar li { display: flex; margin: 0; }

.sgm-nav__link {
	position: relative;
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 0 12px;
	color: var(--sgm-text);
	font-size: 14px;
	font-weight: 500;
	white-space: nowrap;
	text-decoration: none;
}
.sgm-nav__link::after {
	content: "";
	position: absolute;
	left: 12px;
	right: 12px;
	bottom: 0;
	height: 2px;
	background: var(--sgm-red);
	transform: scaleX(0);
	transition: transform .15s ease;
}
.sgm-nav__link:hover,
.sgm-nav__link.is-current { color: var(--sgm-red); }
.sgm-nav__link .sgm-nav-icon { width: 18px; height: 18px; transition: color .15s ease; }
.sgm-nav__link:hover .sgm-nav-icon,
.sgm-nav__link.is-current .sgm-nav-icon { color: var(--sgm-red); }
.sgm-nav__link:hover::after,
.sgm-nav__link.is-current::after { transform: scaleX(1); }

.sgm-nav__quote {
	display: flex;
	border-left: 1px solid var(--sgm-line);
	align-items: center;
	gap: 8px;
	padding: 0 16px;
	color: var(--sgm-text);
	font-size: 14px;
	font-weight: 600;
	white-space: nowrap;
	text-decoration: none;
}
.sgm-nav__quote svg { color: var(--sgm-red); }
.sgm-nav__quote:hover { color: var(--sgm-red); }

.sgm-nav a:focus-visible,
.sgm-nav button:focus-visible,
.sgm-acc a:focus-visible,
.sgm-acc button:focus-visible {
	outline: 2px solid var(--sgm-red);
	outline-offset: -2px;
}

/* ---------- Escritorio: mega menú ---------- */

.sgm-mega {
	position: absolute;
	top: 100%;
	left: 0;
	right: 0;
	z-index: 50;
	background: #fff;
	border-top: 1px solid var(--sgm-line);
	border-bottom: 1px solid var(--sgm-line);
	box-shadow: 0 16px 32px -12px rgba(17, 24, 28, .18);
	opacity: 0;
	transform: translateY(-8px);
	transition: opacity .2s ease, transform .2s cubic-bezier(.2, .7, .3, 1);
}
.sgm-mega.is-open { opacity: 1; transform: none; }
.sgm-mega[hidden] { display: none; }

/* Al cambiar de categoría, el panel derecho aparece con un fundido suave */
.sgm-mega__panel { animation: sgm-panel-in .18s ease both; }
@keyframes sgm-panel-in {
	from { opacity: 0; transform: translateX(6px); }
	to { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
	.sgm-mega { transition: none; transform: none; }
	.sgm-mega__panel { animation: none; }
}

.sgm-mega__inner {
	max-width: 1440px;
	margin: 0 auto;
	display: grid;
	grid-template-columns: 300px 1fr;
	min-height: 360px;
	max-height: calc(100vh - 160px);
}

.sgm-mega__list {
	margin: 0;
	padding: 0 0 8px;
	list-style: none;
	border-right: 1px solid var(--sgm-line);
	overflow-y: auto;
}
.sgm-mega__list li { margin: 0; }

.sgm-mega__parent {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 11px 16px;
	color: var(--sgm-text);
	font-size: 15px;
	font-weight: 500;
	text-decoration: none;
}
.sgm-mega__name { flex: 1; }
.sgm-mega__parent .sgm-nav-chev { color: #9ca3af; }
.sgm-mega__parent.is-active { background: var(--sgm-soft); color: var(--sgm-red); }
.sgm-mega__parent.is-active .sgm-nav-icon,
.sgm-mega__parent.is-active .sgm-nav-chev { color: var(--sgm-red); }
.sgm-mega__parent.is-current .sgm-mega__name { font-weight: 600; }

.sgm-mega__shop {
	margin-top: 8px !important;
	padding-top: 8px;
	border-top: 1px solid var(--sgm-line);
}
.sgm-mega__shop a {
	display: flex;
	align-items: center;
	gap: 6px;
	padding: 10px 16px;
	color: var(--sgm-red);
	font-size: 14px;
	font-weight: 600;
	text-decoration: none;
}
.sgm-mega__shop a:hover { text-decoration: underline; text-underline-offset: 3px; }

.sgm-mega__panels { padding: 24px 32px; overflow-y: auto; }
.sgm-mega__panel[hidden] { display: none; }

.sgm-mega__head {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	gap: 16px;
	padding-bottom: 14px;
	margin-bottom: 12px;
	border-bottom: 1px solid var(--sgm-line);
}
.sgm-mega__head h2 {
	margin: 0;
	color: var(--sgm-text);
	font-size: 20px;
	font-weight: 700;
	line-height: 1.2;
}
.sgm-mega__seeall {
	display: inline-flex;
	align-items: center;
	gap: 4px;
	color: var(--sgm-red);
	font-size: 14px;
	font-weight: 600;
	white-space: nowrap;
	text-decoration: none;
}
.sgm-mega__seeall:hover { text-decoration: underline; text-underline-offset: 3px; }

.sgm-mega__children {
	margin: 0;
	padding: 0;
	list-style: none;
	columns: 3 200px;
	column-gap: 32px;
}
.sgm-mega__children li { margin: 0; break-inside: avoid; }
.sgm-mega__children a {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	gap: 8px;
	padding: 8px 0;
	color: #374151;
	font-size: 14px;
	text-decoration: none;
}
.sgm-mega__children a:hover,
.sgm-mega__children a.is-current { color: var(--sgm-red); }
.sgm-mega__count { color: #9ca3af; font-size: 12px; }

.sgm-mega__empty { margin: 4px 0 16px !important; color: var(--sgm-muted); font-size: 14px; }
.sgm-mega__cta {
	display: inline-flex;
	align-items: center;
	height: 40px;
	padding: 0 18px;
	border-radius: 8px;
	background: var(--sgm-red);
	color: #fff !important;
	font-size: 14px;
	font-weight: 600;
	text-decoration: none;
}
.sgm-mega__cta:hover,
.sgm-mega__cta:focus,
.sgm-mega__cta:visited { background: #b80d0d; color: #fff !important; }

/* ---------- Móvil: acordeón ---------- */

.sgm-acc { margin: 0; padding: 0; list-style: none; }
.sgm-acc__item { margin: 0; border-bottom: 1px solid var(--sgm-line); }

.sgm-acc__row { display: flex; align-items: stretch; min-height: 52px; }

.sgm-acc__link {
	flex: 1;
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 0 16px;
	color: var(--sgm-text);
	font-size: 16px;
	font-weight: 500;
	text-decoration: none;
}
.sgm-acc__link.is-current { color: var(--sgm-red); font-weight: 600; }
.sgm-acc__link.is-current .sgm-nav-icon { color: var(--sgm-red); }
.sgm-acc__link--shop { color: var(--sgm-red); font-weight: 600; }

.sgm-acc__toggle {
	width: 52px;
	margin: 0;
	padding: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	border: 0;
	border-left: 1px solid var(--sgm-line);
	border-radius: 0;
	background: transparent;
	color: var(--sgm-muted);
	cursor: pointer;
}
.sgm-acc__toggle:hover,
.sgm-acc__toggle:focus,
.sgm-acc__toggle:active,
.sgm-drawer__close:hover,
.sgm-drawer__close:focus { background: transparent !important; box-shadow: none; }
.sgm-acc__toggle .sgm-nav-chev { width: 20px; height: 20px; transition: transform .2s ease; }
.sgm-acc__toggle[aria-expanded="true"] { color: var(--sgm-red); }
.sgm-acc__toggle[aria-expanded="true"] .sgm-nav-chev { transform: rotate(180deg); }

.sgm-acc__sub {
	margin: 0;
	padding: 4px 0 10px;
	list-style: none;
	background: var(--sgm-soft);
}
.sgm-acc__sub[hidden] { display: none; }
.sgm-acc__sub li { margin: 0; }
.sgm-acc__sub a {
	display: block;
	padding: 11px 16px 11px 48px;
	color: #374151;
	font-size: 15px;
	text-decoration: none;
}
.sgm-acc__sub a.is-current { color: var(--sgm-red); font-weight: 600; }
.sgm-acc__sub a.sgm-acc__all { color: var(--sgm-red); font-weight: 600; }

/* Panel móvil (components/header/modalMenuMobile.php) */
.sgm-drawer { position: fixed; inset: 0; z-index: 999; }
.sgm-drawer[hidden] { display: none; }
.sgm-drawer__backdrop { position: absolute; inset: 0; background: rgba(17, 24, 28, .45); opacity: 0; transition: opacity .25s ease; }
.sgm-drawer__panel {
	position: absolute;
	top: 0;
	bottom: 0;
	left: 0;
	width: min(86vw, 380px);
	display: flex;
	flex-direction: column;
	background: #fff;
	transform: translateX(-100%);
	transition: transform .25s ease;
}
.sgm-drawer.is-open .sgm-drawer__backdrop { opacity: 1; }
.sgm-drawer.is-open .sgm-drawer__panel { transform: translateX(0); }

.sgm-drawer__head {
	flex-shrink: 0;
	display: flex;
	align-items: center;
	justify-content: space-between;
	height: 56px;
	padding: 0 4px 0 16px;
	border-bottom: 1px solid #e5e7eb;
}
.sgm-drawer__title { margin: 0 !important; color: #11181c; font-size: 17px; font-weight: 700; }
.sgm-drawer__close {
	width: 48px;
	height: 48px;
	margin: 0;
	padding: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	border: 0;
	background: transparent;
	color: #11181c;
	cursor: pointer;
}
.sgm-drawer__body { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
.sgm-drawer__label {
	margin: 0 !important;
	padding: 16px 16px 8px;
	color: #6b7280;
	font-size: 12px;
	font-weight: 600;
	letter-spacing: .06em;
	text-transform: uppercase;
}
.sgm-drawer__links { margin: 0; padding: 0 0 24px; list-style: none; }
.sgm-drawer__links li { margin: 0; }
.sgm-drawer__links a {
	display: flex;
	align-items: center;
	gap: 12px;
	min-height: 48px;
	padding: 0 16px;
	color: #11181c;
	font-size: 15px;
	text-decoration: none;
}
.sgm-drawer__links svg { color: #6b7280; flex-shrink: 0; }

html.sgm-no-scroll, html.sgm-no-scroll body { overflow: hidden; }

@media (prefers-reduced-motion: reduce) {
	.sgm-drawer__panel, .sgm-drawer__backdrop, .sgm-nav-chev, .sgm-nav__link::after { transition: none; }
}

/* Barra en pantallas medianas: primero se quitan íconos, luego las últimas categorías (siguen en "Todas las categorías"). */
@media (max-width: 1279px) {
	.sgm-nav__bar { padding: 0 8px; }
	.sgm-nav__bar .sgm-nav-icon { display: none; }
	.sgm-nav__link { padding: 0 10px; }
	.sgm-nav__link::after { left: 10px; right: 10px; }
}
@media (max-width: 1099px) {
	.sgm-nav__bar li:nth-child(n+6) { display: none; }
	.sgm-nav__all, .sgm-nav__quote { padding: 0 12px; }
}
@media (max-width: 959px) {
	.sgm-nav__bar li:nth-child(n+5) { display: none; }
}
@media (max-width: 879px) {
	.sgm-nav__bar li:nth-child(n+4) { display: none; }
}

/* Mega menú: productos destacados (categorías sin subcategorías) */
.sgm-mega__label {
	margin: 4px 0 12px !important;
	color: var(--sgm-muted);
	font-size: 12px;
	font-weight: 600;
	letter-spacing: .06em;
	text-transform: uppercase;
}
.sgm-mega__products {
	display: grid;
	grid-template-columns: repeat(4, minmax(0, 1fr));
	gap: 16px;
	margin: 0 0 20px;
	padding: 0;
	list-style: none;
}
.sgm-mega__products li { margin: 0; }
.sgm-mega__product {
	display: flex;
	flex-direction: column;
	gap: 6px;
	height: 100%;
	padding: 10px;
	border: 1px solid var(--sgm-line);
	border-radius: 10px;
	color: var(--sgm-text);
	text-decoration: none;
	transition: border-color .15s ease, box-shadow .15s ease;
}
.sgm-mega__product:hover { border-color: #d1d5db; box-shadow: 0 6px 16px -8px rgba(17, 24, 28, .2); color: var(--sgm-text); }
.sgm-mega__thumb {
	display: block;
	aspect-ratio: 1;
	margin-bottom: 4px;
	border-radius: 6px;
	background: #fff;
	overflow: hidden;
}
.sgm-mega__thumb img { width: 100%; height: 100%; object-fit: contain; }
.sgm-mega__pname {
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
	font-size: 13px;
	line-height: 1.35;
	min-height: 2.7em;
}
.sgm-mega__product:hover .sgm-mega__pname { color: var(--sgm-red); }
.sgm-mega__price { margin-top: auto; font-size: 14px; font-weight: 700; color: var(--sgm-text); }
.sgm-mega__price del { color: #9ca3af; font-weight: 400; font-size: 12px; margin-right: 4px; }
.sgm-mega__price ins { text-decoration: none; }
.sgm-mega__thumb { aspect-ratio: 4 / 3; }
.sgm-mega__label--sep { margin-top: 24px !important; }
