/**
 * BeatLatin app shell — floating glass sidebar + topbar (Apple Music).
 * Adapted from production reference (style.css APP SHELL + app-shell.css).
 */

/* ---------- Sidebar — panel flotante glass ---------- */

.bl-sidebar.mc-sidebar {
	position: fixed;
	top: var(--bl-shell-inset);
	left: var(--bl-shell-inset);
	bottom: var(--bl-shell-inset);
	z-index: var(--z-sidebar);

	display: flex;
	flex-direction: column;
	gap: 0;

	width: var(--bl-sidebar-width);
	min-width: var(--bl-sidebar-width);
	max-width: var(--bl-sidebar-width);
	height: auto;
	min-height: 0;
	padding: 22px 15px 14px;
	box-sizing: border-box;

	overflow-x: hidden;
	overflow-y: hidden;

	background: var(--bl-glass-material-bg);
	backdrop-filter: saturate(220%) blur(16px);
	-webkit-backdrop-filter: saturate(220%) blur(16px);

	border: 1px solid var(--bl-border);
	border-radius: var(--bl-radius-lg);
	box-shadow: 0 10px 40px var(--bl-glass-material-shadow);

	transition:
		background 0.28s ease,
		border-color 0.28s ease,
		transform var(--bl-sidebar-speed) var(--bl-ease);
}

[data-theme="light"] .bl-sidebar.mc-sidebar {
	background: var(--bl-glass-material-bg);
	box-shadow: 0 10px 40px var(--bl-glass-material-shadow);
}

.bl-sidebar__top,
.bl-sidebar__nav,
.bl-sidebar__bottom {
	width: 100%;
	min-width: 0;
	box-sizing: border-box;
}

.bl-sidebar__top {
	display: flex;
	align-items: center;
	justify-content: space-between;
	width: 100%;
	min-height: 42px;
	margin-bottom: 38px;
	padding: 0 4px;
}

.bl-sidebar-logo {
	display: inline-flex;
	width: 125px;
	max-width: 125px;
	text-decoration: none;
	opacity: 1;
}

.bl-sidebar-logo:hover {
	text-decoration: none;
	opacity: 0.95;
}

.bl-sidebar__nav {
	flex: 1 1 auto;
	min-height: 0;
	overflow-x: hidden;
	overflow-y: auto;
	-webkit-overflow-scrolling: touch;
}

.bl-sidebar__bottom {
	margin-top: auto;
	padding-top: 14px;
	padding-left: 4px;
	padding-right: 4px;
}

/* Nav list */
.bl-nav__list {
	display: flex;
	flex-direction: column;
	gap: 3px;
	margin: 0;
	padding: 0;
	list-style: none;
}

.bl-nav__link {
	display: flex;
	align-items: center;
	gap: 12px;
	min-height: 43px;
	padding: 0 11px;
	border-radius: 10px;
	color: var(--bl-nav-text);
	text-decoration: none !important;
	font-size: 14px;
	font-weight: 400;
	line-height: 1.2;
	transition: background 0.22s ease, color 0.22s ease;
}

.bl-nav__link:hover {
	background: transparent;
	color: var(--bl-nav-text);
	text-decoration: none;
}

.bl-nav__icon {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 20px;
	min-width: 20px;
	height: 20px;
	color: currentColor;
}

.bl-nav__icon .bl-icon {
	display: block;
	fill: currentColor;
}

.bl-nav__icon .bl-icon path[fill="none"],
.bl-nav__icon .bl-icon circle[fill="none"] {
	fill: none;
}

.bl-nav__text {
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.bl-nav__item.is-active .bl-nav__link {
	color: var(--bl-red) !important;
	background: rgba(255, 255, 255, 0.08);
}

.bl-nav__item.is-active .bl-nav__link:hover,
.bl-nav__item.is-active .bl-nav__link:focus-visible {
	color: var(--bl-red) !important;
	background: rgba(255, 255, 255, 0.08);
}

[data-theme="light"] .bl-nav__item.is-active .bl-nav__link,
[data-theme="light"] .bl-nav__item.is-active .bl-nav__link:hover {
	background: rgba(0, 0, 0, 0.06);
}

/* Panel CTA */
.bl-sidebar-panel {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 10px;
	width: 100%;
	min-height: 42px;
	padding: 0 14px;
	border-radius: 12px;
	background: var(--bl-red);
	border: 1px solid var(--bl-red);
	color: #ffffff;
	text-decoration: none !important;
	font-size: 14px;
	font-weight: 500;
	box-sizing: border-box;
}

.bl-sidebar-panel:hover {
	background: #ef1717;
	border-color: #ef1717;
	color: #ffffff;
	text-decoration: none;
}

.bl-sidebar-panel__icon {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	color: #ffffff;
}

.bl-sidebar-panel__icon .bl-icon {
	fill: none;
	stroke: currentColor;
	color: #ffffff;
}

.bl-sidebar-panel__icon .bl-icon path {
	stroke: currentColor;
	fill: none;
}

/* ---------- Topbar — píldora flotante glass (::before) ---------- */

.bl-topbar.mc-topbar {
	position: fixed;
	top: var(--bl-shell-inset);
	left: var(--bl-sidebar-footprint);
	right: var(--bl-shell-inset);
	z-index: var(--z-topbar);

	isolation: isolate;
	display: grid !important;
	grid-template-columns:
		minmax(0, 1fr)
		minmax(280px, 760px)
		minmax(0, 1fr);
	align-items: center;
	align-content: center;
	gap: 18px;

	width: auto;
	height: var(--bl-topbar-height);
	min-height: var(--bl-topbar-height);
	max-height: var(--bl-topbar-height);
	padding: 0 var(--bl-content-gutter);
	box-sizing: border-box;

	background: transparent;
	border: 0;
	border-radius: var(--bl-radius-lg);
	box-shadow: none;

	transition:
		color 0.28s ease,
		border-color 0.28s ease;
}

.bl-topbar.mc-topbar::before {
	content: "";
	position: absolute;
	inset: 0;
	z-index: 0;
	pointer-events: none;
	background: var(--bl-glass-material-bg);
	backdrop-filter: saturate(220%) blur(16px);
	-webkit-backdrop-filter: saturate(220%) blur(16px);
	border: 1px solid var(--bl-border);
	border-radius: inherit;
	box-shadow: 0 10px 40px var(--bl-glass-material-shadow);
	transition:
		background 0.28s ease,
		border-color 0.28s ease,
		box-shadow 0.28s ease;
}

.bl-topbar__left,
.bl-topbar__center,
.bl-topbar__right {
	position: relative;
	z-index: 1;
	display: flex;
	align-items: center;
	align-self: center;
	min-width: 0;
	margin: 0;
	padding: 0;
}

.bl-topbar__center {
	justify-content: center;
	width: 100%;
}

.bl-topbar__right {
	gap: 0.55rem;
	justify-content: flex-end;
}

.bl-mobile-menu-toggle {
	display: none;
	width: 42px;
	height: 42px;
	border: 1px solid var(--bl-border);
	border-radius: 11px;
	background: transparent;
	color: var(--mc-text-muted);
	cursor: pointer;
	align-items: center;
	justify-content: center;
	padding: 0;
}

.bl-mobile-menu-toggle__bars,
.bl-mobile-menu-toggle__bars::before,
.bl-mobile-menu-toggle__bars::after {
	display: block;
	width: 14px;
	height: 2px;
	background: currentColor;
	border-radius: 1px;
	position: relative;
}

.bl-mobile-menu-toggle__bars::before,
.bl-mobile-menu-toggle__bars::after {
	content: "";
	position: absolute;
	left: 0;
}

.bl-mobile-menu-toggle__bars::before {
	top: -5px;
}

.bl-mobile-menu-toggle__bars::after {
	top: 5px;
}

/* Search */
.bl-search {
	position: relative;
	width: min(520px, 100%);
}

.bl-search__icon {
	position: absolute;
	left: 14px;
	top: 50%;
	transform: translateY(-50%);
	color: var(--mc-text-muted);
	pointer-events: none;
	display: inline-flex;
}

.bl-search__input {
	width: 100%;
	height: 36px;
	min-height: 36px;
	padding: 0 16px 0 40px;
	border: 0;
	border-radius: 999px;
	background: var(--bl-input-bg);
	color: var(--mc-text);
	font: inherit;
	font-size: 14px;
	outline: none;
}

.bl-search__input::placeholder {
	color: var(--mc-text-muted);
}

.bl-search__input:focus {
	box-shadow: 0 0 0 2px rgba(217, 12, 12, 0.35);
}

/* Cart + account — flat, no pill / no circle chrome */
.bl-topbar-cart,
.bl-topbar-account {
	display: inline-flex;
	align-items: center;
	gap: 0.35rem;
	min-height: 1.75rem;
	padding: 0;
	border-radius: 0;
	background: transparent;
	color: var(--mc-text);
	text-decoration: none !important;
	font-size: 13px;
	font-weight: 500;
	opacity: 0.92;
}

.bl-topbar-cart:hover,
.bl-topbar-account:hover {
	background: transparent;
	color: var(--bl-red, #d90c0c);
	opacity: 1;
	text-decoration: none;
}

.bl-topbar-cart__icon,
.bl-topbar-account__icon {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	color: inherit;
}

.bl-topbar-cart__icon .bl-icon,
.bl-topbar-account__icon .bl-icon {
	fill: none;
	stroke: currentColor;
	color: inherit;
}

.bl-topbar-account {
	width: auto;
	min-width: 1.75rem;
	justify-content: center;
}

.bl-topbar-account__avatar {
	display: block;
	width: 28px;
	height: 28px;
	border-radius: 50%;
	object-fit: cover;
}

.bl-topbar-account__initials {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 1.5rem;
	height: 1.5rem;
	padding: 0 2px;
	font-size: 12px;
	font-weight: 700;
	letter-spacing: 0.02em;
	line-height: 1;
	color: var(--mc-text);
	background: transparent;
	border-radius: 0;
}

.bl-topbar-account:hover .bl-topbar-account__initials {
	color: var(--bl-red, #d90c0c);
}

/* Overlay móvil */
.bl-sidebar-overlay {
	position: fixed;
	inset: 0;
	z-index: var(--z-overlay);
	background: var(--bl-overlay-bg);
	backdrop-filter: blur(3px);
	-webkit-backdrop-filter: blur(3px);
	opacity: 0;
	visibility: hidden;
	pointer-events: none;
	transition:
		opacity 0.28s ease,
		visibility 0.28s ease;
}

/* Admin bar */
body.admin-bar .bl-sidebar.mc-sidebar {
	top: calc(32px + var(--bl-shell-inset));
	bottom: var(--bl-shell-inset);
}

body.admin-bar .bl-topbar.mc-topbar {
	top: calc(32px + var(--bl-shell-inset));
}

@media (max-width: 782px) {
	body.admin-bar .bl-sidebar.mc-sidebar {
		top: 46px;
		bottom: 0;
	}

	body.admin-bar .bl-topbar.mc-topbar {
		top: 46px;
	}
}

@media (prefers-reduced-motion: reduce) {
	.bl-sidebar.mc-sidebar,
	.bl-topbar.mc-topbar,
	.bl-topbar.mc-topbar::before {
		transition: none;
	}
}

@media (prefers-contrast: more) {
	.bl-sidebar.mc-sidebar,
	.bl-topbar.mc-topbar::before {
		backdrop-filter: none;
		-webkit-backdrop-filter: none;
	}
}

/* ---------- Tablet / móvil ---------- */

@media (max-width: 1024px) {
	:root {
		--bl-topbar-height: 106px;
		--bl-content-offset: calc(var(--bl-topbar-height) + 10px);
	}

	.bl-topbar.mc-topbar {
		top: 0;
		left: 0;
		right: 0;
		width: 100%;
		height: auto;
		min-height: var(--bl-topbar-height);
		max-height: none;
		border-radius: 0;
		grid-template-columns: auto 1fr auto;
		grid-template-rows: auto auto;
		gap: 10px 12px;
		padding: 10px 12px 12px;
	}

	.bl-topbar.mc-topbar::before {
		border: 0;
		border-bottom: 1px solid var(--bl-border);
		border-radius: 0;
	}

	.bl-topbar__left {
		grid-column: 1;
		grid-row: 1;
	}

	.bl-topbar__right {
		grid-column: 3;
		grid-row: 1;
		gap: 4px;
	}

	.bl-topbar__center {
		grid-column: 1 / -1;
		grid-row: 2;
		justify-content: stretch;
	}

	.bl-search {
		width: 100%;
	}

	.bl-mobile-menu-toggle {
		display: inline-flex;
	}

	.bl-topbar-cart__total {
		display: none;
	}

	.bl-sidebar.mc-sidebar {
		top: 0;
		left: 0;
		bottom: 0;
		width: min(280px, 84vw);
		min-width: min(280px, 84vw);
		max-width: min(280px, 84vw);
		height: 100dvh;
		min-height: 100dvh;
		padding: 20px 14px 16px;
		border: 0;
		border-radius: 0;
		border-right: 1px solid rgba(255, 255, 255, 0.1);
		box-shadow: 22px 0 55px rgba(0, 0, 0, 0.52);
		transform: translateX(-105%);
		transition: transform 0.34s var(--bl-ease);
	}

	[data-theme="light"] .bl-sidebar.mc-sidebar {
		border-right-color: rgba(0, 0, 0, 0.08);
		box-shadow: 22px 0 40px rgba(0, 0, 0, 0.18);
	}

	body.bl-mobile-sidebar-open .bl-sidebar.mc-sidebar,
	.mc-app.is-sidebar-open .bl-sidebar.mc-sidebar {
		transform: translateX(0);
	}

	body.bl-mobile-sidebar-open .bl-sidebar-overlay {
		opacity: 1;
		visibility: visible;
		pointer-events: auto;
	}

	body.bl-mobile-sidebar-open {
		overflow: hidden;
	}

	body.admin-bar .bl-topbar.mc-topbar {
		top: 46px;
	}

	body.admin-bar .bl-sidebar.mc-sidebar {
		top: 0;
		height: 100dvh;
		min-height: 100dvh;
	}
}
