/* Layout base web v2 — tokens y shell (sin depender de css/ externo) */

:root {
	--spanish-gray: hsl(0, 0%, 60%);
	--sonic-silver: hsl(0, 0%, 47%);
	--eerie-black: hsl(0, 0%, 13%);
	--sandy-brown: hsl(29, 90%, 65%);
	--bittersweet: hsl(0, 100%, 70%);
	--ocean-green: hsl(152, 51%, 52%);
	--davys-gray: hsl(0, 0%, 33%);
	--cultured: hsl(0, 0%, 93%);
	--white: hsl(0, 100%, 100%);
	--onyx: hsl(0, 0%, 27%);
	--fs-5: 1rem;
	--fs-7: 0.875rem;
	--fs-8: 0.813rem;
	--fs-9: 0.75rem;
	--weight-500: 500;
	--weight-600: 600;
	--border-radius-md: 10px;
	--border-radius-sm: 5px;
	--transition-timing: 0.2s ease;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; }
body { background: var(--white); color: var(--eerie-black); line-height: 1.5; }
main { background: #ededed; padding-top: 8px; }
a { text-decoration: none; color: inherit; }
button { font: inherit; cursor: pointer; background: none; border: none; }
img { display: block; max-width: 100%; }
input { font: inherit; }

.container { padding: 0 15px; width: 100%; margin: 0 auto; }
.has-scrollbar { padding-bottom: 5px; }

/*
 * Capas móvil (de abajo → arriba):
 * contenido < overlay menú < sidebar menú < header < overlay contacto < contacto
 * Contacto sombrea también header y barra inferior.
 */
.overlay {
	position: fixed; inset: 0; background: hsla(0, 0%, 0%, 0.5);
	opacity: 0; pointer-events: none; z-index: 10000; transition: 0.5s ease;
}
.overlay.active { opacity: 1; pointer-events: all; }
body.ns-contact-open .overlay { z-index: 10040; }

/* Header */
.desktop-navigation-menu { display: none; }

body > header {
	position: relative;
	z-index: 10020;
	background: var(--white);
}
.header-main {
	padding: 16px 0 10px;
	border-bottom: 1px solid var(--cultured);
	background: var(--white);
}
.header-top-row {
	display: flex;
	flex-direction: row;
	align-items: center;
	gap: 10px;
	position: relative;
	z-index: 1;
}
/* Dropdown favoritos abierto: por encima del nav desktop (z-index 10) y del buscador.
   Misma regla para sesión iniciada (chip cuenta) y guest (solo fav + carrito). */
.header-top-row.is-fav-open {
	z-index: 40;
}
.header-top-row.is-fav-open ~ .desktop-navigation-menu {
	z-index: 1;
}
.header-top-row.is-fav-open .header-tools,
.header-top-row.is-fav-open .header-user-actions {
	position: relative;
	z-index: 2;
	overflow: visible;
}
.header-top-row.is-fav-open .header-search-container {
	z-index: 1;
}
.header-top-row.is-fav-open .header-fav-wrap {
	z-index: 50;
}
.header-logo {
	flex-shrink: 0;
	display: inline-flex;
	align-items: center;
	gap: 10px;
	min-width: 0;
	text-decoration: none;
	color: inherit;
}
.header-logo img,
#web-header-logo-img {
	width: 40px;
	height: 40px;
	max-width: 40px;
	max-height: 40px;
	object-fit: contain;
	display: block;
	margin: 0;
	flex-shrink: 0;
}
/* Nombre del comercio: solo escritorio en contexto local */
.header-local-name {
	display: none;
	font-size: 1.05rem;
	font-weight: 700;
	color: var(--onyx);
	line-height: 1.2;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	max-width: 220px;
}
.header-tools {
	display: flex;
	align-items: center;
	gap: 8px;
	flex: 1;
	min-width: 0;
}
.header-search-container {
	position: relative;
	flex: 1;
	min-width: 0;
	z-index: 1;
}
.header-search-container .search-field {
	width: 100%;
	font-size: var(--fs-7);
	color: var(--onyx);
	padding: 10px 15px;
	padding-right: 50px;
	border: 1px solid var(--cultured);
	border-radius: var(--border-radius-md);
}
.search-field::-webkit-search-cancel-button { display: none; }
.search-btn {
	position: absolute; top: 50%; right: 2px; transform: translateY(-50%);
	padding: 8px 15px; border-radius: var(--border-radius-md);
	background: var(--white);
}
.search-btn:hover { opacity: 0.85; }
.header-user-actions {
	display: flex;
	align-items: center;
	gap: 4px;
	flex-shrink: 0;
	position: relative;
	z-index: 2;
}
.header-user-actions .action-btn { position: relative; padding: 2px; line-height: 0; }
.header-user-actions .action-btn img { display: block; width: 36px; height: auto; }
.header-user-actions .count {
	position: absolute; top: -2px; right: -3px;
	background: var(--bittersweet); color: var(--white);
	font-size: 11px; font-weight: var(--weight-500);
	line-height: 1; padding: 2px 4px; border-radius: 20px;
	min-width: 16px; text-align: center;
}

/* Favoritos desktop: texto + dropdown */
.header-fav-wrap {
	position: relative;
	z-index: 2;
}
.header-fav-wrap.is-open {
	z-index: 50;
}
.header-fav-trigger {
	display: inline-flex !important;
	align-items: center;
	gap: 6px;
	padding: 6px 10px !important;
	line-height: 1.2 !important;
	text-decoration: none;
	color: var(--onyx);
	font-size: .95rem;
	font-weight: var(--weight-600);
	border-radius: 6px;
	white-space: nowrap;
}
.header-fav-trigger:hover { background: rgba(0, 0, 0, .04); }
.header-fav-label { display: inline-block; }
.header-fav-trigger .count {
	position: static;
	top: auto;
	right: auto;
	margin-left: 2px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 18px;
	height: 18px;
	padding: 0 5px;
	line-height: 1;
	box-sizing: border-box;
	vertical-align: middle;
}
.header-fav-trigger:not(.has-count) .count { display: none; }
.header-fav-dropdown {
	position: absolute;
	top: 100%;
	right: 0;
	width: min(340px, calc(100vw - 24px));
	padding-top: 8px; /* puente hover sin hueco */
	background: transparent;
	border: none;
	box-shadow: none;
	z-index: 60;
	overflow: visible;
}
.header-fav-dropdown[hidden] { display: none !important; }
.header-fav-dropdown-panel {
	position: relative;
	z-index: 1;
	background: #fff;
	border: 1px solid #e8e8e8;
	border-radius: 10px;
	box-shadow: 0 12px 32px rgba(0, 0, 0, .18);
	overflow: hidden;
	isolation: isolate;
}
.header-fav-list {
	max-height: 320px;
	overflow-y: auto;
	padding: 4px 0;
	background: #fff;
}
.header-fav-empty {
	margin: 0;
	padding: 16px 14px;
	font-size: .88rem;
	color: #777;
	text-align: center;
}
.header-fav-item {
	display: grid;
	grid-template-columns: 48px minmax(0, 1fr);
	gap: 10px;
	align-items: center;
	padding: 10px 12px;
	text-decoration: none;
	color: #333;
	background: #fff;
}
.header-fav-item:hover { background: #f7f7f7; }
.header-fav-thumb {
	width: 48px !important;
	height: 48px !important;
	max-width: 48px;
	object-fit: contain;
	border-radius: 8px;
	background: #f5f5f5;
	border: 1px solid #eee;
	display: block;
}
.header-fav-meta { min-width: 0; }
.header-fav-name {
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
	font-size: .88rem;
	font-weight: 600;
	line-height: 1.3;
	color: #333;
}
.header-fav-local {
	display: block;
	margin: 2px 0 0;
	font-size: .75rem;
	color: #777;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}
.header-fav-price {
	display: block;
	margin: 3px 0 0;
	font-size: .9rem;
	font-weight: 600;
	color: #222;
}
.header-fav-price-list {
	margin-right: 6px;
	font-size: .78rem;
	font-weight: 400;
	color: #999;
	text-decoration: line-through;
}
.header-fav-discount {
	margin-left: 6px;
	font-size: .75rem;
	font-weight: 700;
	color: #00a650;
}
.header-fav-more {
	margin: 0;
	padding: 6px 12px 10px;
	font-size: .78rem;
	color: #888;
}
.header-fav-footer {
	display: block;
	padding: 11px 14px;
	text-align: center;
	font-size: .88rem;
	font-weight: 700;
	color: #3483fa;
	text-decoration: none;
	border-top: 1px solid #eee;
	background: #fafafa;
}
.header-fav-footer:hover { background: #f0f7ff; }

/* Sidebar móvil — debajo del header, sobre el sombreado */
.sidebar {
	background: var(--white);
	position: fixed;
	top: var(--web-header-h, 56px);
	left: -100%;
	bottom: 0;
	width: 100%; max-width: 320px; padding: 20px 24px 30px;
	overflow-y: auto; overscroll-behavior: contain;
	visibility: hidden; transition: 0.5s ease; z-index: 10010;
	box-shadow: 4px 0 24px rgba(0, 0, 0, 0.12);
}
.sidebar.active { left: 0; visibility: visible; }
.sidebar-category { margin-bottom: 15px; padding-bottom: 15px; border-bottom: 1px solid var(--cultured); }
.sidebar-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.sidebar-title {
	color: var(--onyx); font-size: var(--fs-5); text-transform: uppercase;
	letter-spacing: 0.8px; font-weight: var(--weight-600);
}
.sidebar-subtitle {
	margin: 4px 0 10px;
	color: var(--sonic-silver, #787878);
	font-size: .72rem;
	text-transform: uppercase;
	letter-spacing: .06em;
	font-weight: var(--weight-600);
}
.sidebar-close-btn { font-size: 22px; font-weight: var(--weight-600); }
.sidebar-auth {
	display: flex;
	flex-direction: column;
	gap: 8px;
	margin: 0 0 16px;
	padding-bottom: 14px;
	border-bottom: 1px solid var(--cultured);
}
.sidebar-auth-guest,
.sidebar-auth-user {
	display: flex;
	flex-direction: column;
	gap: 8px;
}
.sidebar-auth-guest[hidden],
.sidebar-auth-user[hidden] { display: none !important; }
.sidebar-auth-profile {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 10px 12px;
	border-radius: 10px;
	text-decoration: none;
	color: var(--onyx, #1a1a1a);
	background: #f8fafc;
	border: 1px solid #e2e8f0;
}
.sidebar-auth-profile:hover { background: #f1f5f9; }
.sidebar-auth-ava {
	width: 36px;
	height: 36px;
	font-size: .9rem;
}
.sidebar-auth-meta {
	display: flex;
	flex-direction: column;
	gap: 2px;
	min-width: 0;
	flex: 1;
}
.sidebar-auth-name {
	font-size: .95rem;
	font-weight: 700;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}
.sidebar-auth-sub {
	font-size: .75rem;
	color: #64748b;
	font-weight: 500;
}
.sidebar-auth-chev {
	color: #94a3b8;
	font-size: 1.25rem;
	line-height: 1;
	flex-shrink: 0;
}
.sidebar-auth-btn {
	display: block;
	text-align: center;
	text-decoration: none;
	padding: 11px 14px;
	border-radius: 8px;
	font-size: .92rem;
	font-weight: 600;
	line-height: 1.2;
}
.sidebar-auth-btn--primary {
	background: var(--sandy-brown, #c97b3a);
	color: #fff;
	border: 1px solid transparent;
}
.sidebar-auth-btn--outline {
	background: #fff;
	color: var(--onyx, #1a1a1a);
	border: 1px solid #e2e8f0;
}
.sidebar-menu-category-list { list-style: none; margin: 0; padding: 0; }

/* Nav inferior móvil — por debajo del overlay de menú/contacto */
.mobile-bottom-navigation {
	background: var(--white);
	position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
	width: 100%; max-width: 500px;
	display: flex; justify-content: space-around; align-items: center;
	padding: 5px 0; box-shadow: 0 0 10px hsla(0, 0%, 0%, 0.25); z-index: 9990;
}
body.ns-menu-open .mobile-bottom-navigation,
body.ns-contact-open .mobile-bottom-navigation {
	z-index: 9990;
}
.mobile-bottom-navigation .action-btn {
	position: relative;
	padding: 10px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	line-height: 0;
}
/* hidden debe ganar a display:inline-flex (si no, el logo del local queda visible en marketplace) */
.mobile-bottom-navigation .action-btn[hidden],
#web-mob-local[hidden] {
	display: none !important;
}
.mobile-bottom-navigation .action-btn img,
.mobile-bottom-navigation .action-btn svg {
	width: 35px;
	height: 35px;
	object-fit: contain;
	display: block;
	flex-shrink: 0;
}
#web-mob-home-img,
#web-mob-local-img {
	border-radius: 8px;
}
.header-logo--local img {
	border-radius: 10px;
	object-fit: contain;
	background: #f7f7f7;
}
.mobile-bottom-navigation .count {
	position: absolute;
	top: 2px;
	right: 2px;
	z-index: 2;
	background: var(--bittersweet);
	color: var(--white);
	font-size: 11px;
	font-weight: var(--weight-600);
	line-height: 1;
	min-width: 16px;
	padding: 2px 5px;
	border-radius: 20px;
	text-align: center;
	box-shadow: 0 0 0 1.5px #fff;
	pointer-events: none;
}
.mobile-bottom-navigation .action-btn:not(.has-count) .count {
	display: none;
}
.mobile-bottom-navigation .action-btn.has-count .count {
	display: block;
}

.product-container { width: 100%; max-width: 1200px; margin: 0 auto; padding: 0 15px; }

@media (min-width: 570px) {
	.header-top-row {
		gap: 16px;
	}
	.header-logo img,
	#web-header-logo-img {
		width: 44px;
		height: 44px;
		max-width: 44px;
		max-height: 44px;
	}
	.header-tools { flex: 1; }
}

@media (min-width: 768px) {
	.container { max-width: 980px; }
	.header-main { padding: 18px 0 8px; }
	.header-user-actions { gap: 10px; }
	.header-user-actions .action-btn img { width: 40px; }
}

@media (min-width: 1024px) {
	.container { max-width: 1200px; }
	.header-tools { max-width: 720px; margin-left: auto; }
	.header-user-actions .action-btn img { width: 43px; }
	/* Local escritorio: nombre al lado del logo + buscador al espacio restante */
	body.is-local-context .header-local-name {
		display: inline-block;
	}
	body.is-local-context .header-local-name[hidden] {
		display: none !important;
	}
	body.is-local-context .header-logo {
		gap: 12px;
		max-width: min(340px, 32vw);
	}
	body.is-local-context .header-local-name {
		max-width: none;
		flex: 1 1 auto;
		min-width: 0;
	}
	body.is-local-context .header-tools {
		max-width: none;
		flex: 1 1 auto;
		margin-left: 0;
	}
	.desktop-navigation-menu {
		display: block;
		padding: 2px 0 0;
		border-top: none;
		position: relative;
		z-index: 10;
	}
	.web-desktop-nav-inner {
		display: flex;
		justify-content: space-between;
		align-items: center;
		gap: 16px;
	}
	.web-desktop-nav-left,
	.web-desktop-nav-right {
		display: flex;
		align-items: center;
		gap: 20px;
		list-style: none;
		flex-wrap: wrap;
	}
	.web-desktop-nav-right {
		margin-left: auto;
		gap: 16px;
		justify-content: flex-end;
	}
	.web-nav-link--auth {
		font-weight: 600;
		color: var(--onyx);
	}
	.web-nav-link--auth:hover { color: #3483fa; }
	body.is-local-context .web-desktop-nav-right {
		gap: 14px;
	}
	/* Divisor | entre categorías/ofertas y enlace NuestroShops */
	body.is-local-context .web-nav-local-ns {
		display: inline-flex;
		align-items: center;
		gap: 20px;
	}
	body.is-local-context .web-nav-local-ns::before {
		content: '|';
		color: #c4c4c4;
		font-weight: 400;
		line-height: 1;
		user-select: none;
		pointer-events: none;
	}
	.desktop-menu-category-list {
		display: flex; justify-content: flex-start; align-items: center; gap: 30px;
		list-style: none; flex-wrap: wrap;
	}
	.mobile-bottom-navigation { display: none; }
	/* Legacy: sidebar lateral oculto en escritorio; catálogo a ancho completo */
	.product-container .container { display: block; }
	.product-box { width: 100%; }
	.web-sidebar-desk { display: none !important; }
}

@media (max-width: 1023px) {
	.web-sidebar-desk { display: none !important; }
	/* Favoritos y carrito solo en barra inferior móvil */
	.header-user-actions { display: none !important; }
	.header-logo img { margin: 0; }
}

/* Nav contextual — catálogo del local (#/l/{slug}) */
body.is-local-context .web-nav-marketplace-only {
	display: none !important;
}
body.is-local-context #web-home-hero,
body.is-local-context #web-home-filtros {
	display: none !important;
}
/* Auth / guest / contacto siguen visibles en local (derecha del nav) */
body.is-local-context .web-nav-auth-only[hidden],
body.is-local-context .web-nav-guest-only[hidden] {
	display: none !important;
}
