/**
 * Leftbar (menu sinistro) interattivo: modalità compressa/espansa.
 * Ispirato ai Codepen richiesti, adattato al markup blastertheme.
 *
 * @package blastertheme
 */

:root {
	--bt-leftbar-collapsed: 60px;
	--bt-leftbar-expanded-min: 220px;
	--bt-leftbar-expanded-max: 380px;
	--bt-leftbar-mobile-expanded: min(85vw, 320px);
	--bt-leftbar-bg: #16213e;
	/* leggermente più chiaro per gradient e header sticky mobile */
	--bt-leftbar-bg-2: #1b2a52;
	--bt-leftbar-accent: var(--bt-color-primary, #2f89fc);
	/* hover/active più chiaro del bg ma coerente (testi restano bianchi) */
	--bt-leftbar-fx: rgba(255, 255, 255, 0.12);
	--bt-leftbar-fx-strong: rgba(255, 255, 255, 0.18);
}

/* 1) Elimina linee nere (bordo + linea fissa) */
.bt-layout::before { display: none !important; }
.bt-sidebar-left { border-right: 0 !important; }

/* Desktop layout spacing driven by leftbar width */
@media (min-width: 993px) {
	/* Il contenuto centrale NON deve spostarsi quando la leftbar si espande */
	.bt-layout { padding-left: var(--bt-leftbar-collapsed) !important; }
}

/* Leftbar container */
.bt-sidebar-left {
	background: linear-gradient(180deg, var(--bt-leftbar-bg-2), var(--bt-leftbar-bg));
	color: #fff;
	padding: 10px 8px;
	box-shadow: 0 0 0 rgba(0,0,0,0);
	transition: width 0.28s ease, box-shadow 0.28s ease, background 0.28s ease;
	overflow: hidden; /* gestiamo scroll sul contenuto interno */
	border-radius: 0;
}

/* Allineamento: sempre subito sotto header, anche sticky */
.bt-sidebar-left { top: var(--bt-header-height, 40px); }
body.bt-header-stuck .bt-sidebar-left { top: var(--bt-header-height-sticky, 70px); }
body.admin-bar .bt-sidebar-left { top: calc(var(--bt-header-height, 40px) + 32px); }
body.bt-header-stuck.admin-bar .bt-sidebar-left { top: calc(var(--bt-header-height-sticky, 70px) + 32px); }

.bt-leftbar {
	height: 100%;
	display: flex;
	flex-direction: column;
	min-height: 200px;
}

/* Header (hamburger + title + X) */
.bt-leftbar__top {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 4px 4px 8px;
	border-bottom: 1px solid rgba(255,255,255,0.12);
	margin-bottom: 8px;
}

.bt-leftbar__title {
	font-weight: 700;
	font-size: 0.95rem;
	letter-spacing: 0.2px;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	opacity: 1;
	transition: opacity 0.2s ease;
}

.bt-leftbar__open,
.bt-leftbar__close {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 36px;
	height: 36px;
	padding: 0;
	border: 0;
	border-radius: 2px;
	background: rgba(255, 255, 255, 0.10);
	color: #fff;
	cursor: pointer;
	flex-shrink: 0;
	transition: background 0.2s ease, transform 0.08s ease;
}
.bt-leftbar__open:hover,
.bt-leftbar__close:hover { background: var(--bt-leftbar-fx-strong); }
.bt-leftbar__open:active,
.bt-leftbar__close:active { transform: translateY(1px); }
.bt-leftbar__open svg,
.bt-leftbar__close svg { width: 18px; height: 18px; }

/* X mostrata solo quando aperta */
.bt-leftbar__close { display: none; }
body.bt-leftbar-open .bt-leftbar__close { display: inline-flex; }

/* Filtro data + categoria (due colonne, pulsante Go) */
.bt-leftbar-filter {
	display: grid;
	grid-template-columns: 1fr auto;
	gap: 8px;
	align-items: stretch;
	margin-bottom: 12px;
	padding-bottom: 12px;
	border-bottom: 1px solid rgba(255,255,255,0.12);
}
.bt-leftbar-filter__col1 {
	display: flex;
	flex-direction: column;
	gap: 8px;
	min-width: 0;
}
.bt-leftbar-filter__row { min-width: 0; }
.bt-leftbar-filter__date,
.bt-leftbar-filter__cat {
	width: 100%;
	padding: 8px 10px;
	font-size: 0.85rem;
	border: 1px solid rgba(255,255,255,0.25);
	border-radius: 8px;
	background: rgba(255,255,255,0.08);
	color: #fff;
	box-sizing: border-box;
}
.bt-leftbar-filter__date::-webkit-calendar-picker-indicator { filter: invert(1); opacity: 0.7; cursor: pointer; }
.bt-leftbar-filter__date:focus,
.bt-leftbar-filter__cat:focus {
	outline: none;
	border-color: var(--bt-leftbar-accent);
	box-shadow: 0 0 0 2px rgba(47, 137, 252, 0.25);
}
.bt-leftbar-filter__cat { cursor: pointer; }
.bt-leftbar-filter__cat option { background: #16213e; color: #fff; }
.bt-leftbar-filter__col2 {
	display: flex;
	align-items: stretch;
}
.bt-leftbar-filter__go {
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 0 14px;
	font-size: 0.9rem;
	font-weight: 700;
	color: #fff;
	background: var(--bt-color-primary, #2f89fc);
	border: none;
	border-radius: 8px;
	cursor: pointer;
	transition: background 0.2s ease, transform 0.08s ease;
	white-space: nowrap;
}
.bt-leftbar-filter__go:hover {
	background: #3d96ff;
	transform: translateY(-1px);
}
.bt-leftbar-filter__go:active { transform: translateY(0); }

/* Bottom controls (solo mobile): duplicati per uso col pollice */
.bt-leftbar__bottom { display: none; }

/* Default: collapsed – stile tipo Codepen Pixelsultan (icone + tooltip) */
@media (min-width: 993px) {
	.bt-sidebar-left {
		width: var(--bt-leftbar-collapsed) !important;
		min-width: var(--bt-leftbar-collapsed) !important;
		max-width: var(--bt-leftbar-collapsed) !important;
	}
	body.bt-leftbar-open .bt-sidebar-left {
		width: auto !important;
		min-width: var(--bt-leftbar-expanded-min) !important;
		max-width: var(--bt-leftbar-expanded-max) !important;
		box-shadow: 6px 0 22px rgba(0,0,0,0.18);
	}

	/* In collapsed: nascondi label/count/menu slot/filtro, ma mostra tooltip */
	.bt-sidebar-left .bt-nav-left__label,
	.bt-sidebar-left .bt-nav-left__count,
	.bt-sidebar-left .bt-nav-left__menu-slot,
	.bt-sidebar-left .bt-leftbar__title,
	.bt-sidebar-left .bt-leftbar-filter { display: none; }

	body.bt-leftbar-open .bt-sidebar-left .bt-leftbar-filter { display: grid; }
	body.bt-leftbar-open .bt-sidebar-left .bt-nav-left__label,
	body.bt-leftbar-open .bt-sidebar-left .bt-nav-left__count,
	body.bt-leftbar-open .bt-sidebar-left .bt-nav-left__menu-slot { display: block; }
	body.bt-leftbar-open .bt-sidebar-left .bt-leftbar__title { display: block; }
	body.bt-leftbar-open .bt-sidebar-left .bt-nav-left__label,
	body.bt-leftbar-open .bt-sidebar-left .bt-nav-left__count { display: inline; }

	.bt-nav-left__list { display: flex; flex-direction: column; align-items: center; gap: 0; }
	body.bt-leftbar-open .bt-nav-left__list { align-items: stretch; }
}

/* Nav items */
.bt-nav-left__categories { flex: 1 1 auto; overflow: auto; padding-right: 4px; }
.bt-nav-left__categories::-webkit-scrollbar { width: 6px; }
.bt-nav-left__categories::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.18); border-radius: 10px; }

.bt-nav-left__list { list-style: none; margin: 0; padding: 0; }
.bt-nav-left__item { margin: 0; }

.bt-nav-left__link {
	position: relative;
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 10px 8px;
	color: rgba(255,255,255,0.92);
	text-decoration: none;
	border-radius: 14px;
	transition: background 0.2s ease, color 0.2s ease;
}

/* Desktop expanded: testo completo (wrap) + icona allineata */
@media (min-width: 993px) {
	body.bt-leftbar-open .bt-sidebar-left .bt-nav-left__link {
		align-items: flex-start;
	}
	body.bt-leftbar-open .bt-sidebar-left .bt-nav-left__icon {
		margin-top: 2px;
	}
	body.bt-leftbar-open .bt-sidebar-left .bt-nav-left__label {
		white-space: normal !important;
		overflow: hidden;
		display: block;
		line-height: 1.2;
		overflow-wrap: anywhere;
	}
}

.bt-nav-left__icon {
	width: 40px;
	height: 40px;
	border-radius: 14px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	background: rgba(255,255,255,0.10);
	color: rgba(255,255,255,0.86);
	flex-shrink: 0;
	transition: background 0.2s ease, color 0.2s ease;
}
.bt-nav-left__icon svg { width: 20px; height: 20px; }

.bt-nav-left__label { font-weight: 600; }
.bt-nav-left__count {
	margin-left: auto;
	font-size: 0.75rem;
	color: rgba(255,255,255,0.8);
	background: rgba(255,255,255,0.10);
	padding: 2px 8px;
	border-radius: 999px;
}

.bt-nav-left__link:hover {
	background: var(--bt-leftbar-fx);
	color: #fff;
}
.bt-nav-left__link:hover .bt-nav-left__icon {
	background: var(--bt-leftbar-fx-strong);
	color: var(--bt-leftbar-accent);
}
.bt-nav-left__link.is-active {
	background: var(--bt-leftbar-fx-strong);
}
.bt-nav-left__link.is-active .bt-nav-left__icon {
	color: var(--bt-leftbar-accent);
}

/* Tooltip (solo collapsed desktop) */
@media (min-width: 993px) {
	/* quando aperta, non servono tooltip */
	body:not(.bt-leftbar-open) .bt-sidebar-left .bt-nav-left__link::after {
		content: attr(data-tooltip);
		position: absolute;
		left: calc(var(--bt-leftbar-collapsed) - 4px);
		top: 50%;
		transform: translateY(-50%);
		background: rgba(49, 52, 67, 0.98);
		padding: 8px 12px;
		border-radius: 10px;
		font-size: 13px;
		letter-spacing: 0.2px;
		opacity: 0;
		visibility: hidden;
		white-space: nowrap;
		pointer-events: none;
		box-shadow: 0 8px 24px rgba(0,0,0,0.25);
	}
	body:not(.bt-leftbar-open) .bt-sidebar-left .bt-nav-left__link::before {
		content: "";
		position: absolute;
		left: calc(var(--bt-leftbar-collapsed) - 10px);
		top: 50%;
		transform: translateY(-50%) rotate(45deg);
		width: 10px;
		height: 10px;
		background: rgba(49, 52, 67, 0.98);
		opacity: 0;
		visibility: hidden;
	}
	body:not(.bt-leftbar-open) .bt-sidebar-left .bt-nav-left__link:hover::after,
	body:not(.bt-leftbar-open) .bt-sidebar-left .bt-nav-left__link:hover::before {
		opacity: 1;
		visibility: visible;
	}
}

/* Menu slot (solo expanded) – richiama un look “demo 2” */
.bt-nav-left__menu-slot {
	margin-top: 14px;
	padding-top: 12px;
	border-top: 1px solid rgba(255,255,255,0.12);
}
.bt-nav-left__menu-slot .bt-nav-left__menu,
.bt-nav-left__menu-slot .menu { list-style: none; padding: 0; margin: 0; }
.bt-nav-left__menu-slot a {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 10px 12px;
	border-radius: 14px;
	color: rgba(255,255,255,0.82);
	text-decoration: none;
	transition: background 0.2s ease, color 0.2s ease;
}
.bt-nav-left__menu-slot a:hover {
	background: rgba(255,255,255,0.10);
	color: #fff;
}

/* Mobile: drawer apribile con backdrop e X */
@media (max-width: 992px) {
	/* Stato collassato: strip sottile come prima */
	.bt-sidebar-left {
		width: 28px !important;
		min-width: 28px !important;
		max-width: 28px !important;
		padding: 10px 0;
		border-radius: 0;
		box-shadow: none;
	}
	.bt-leftbar__top {
		border-bottom: 0;
		margin: 0;
		padding: 0;
		justify-content: center;
	}
	.bt-leftbar__title,
	.bt-leftbar__close { display: none !important; }
	.bt-leftbar__open { width: 24px; height: 24px; border-radius: 8px; }
	.bt-leftbar__open svg { width: 16px; height: 16px; }
	.bt-leftbar__bottom {
		display: flex;
		justify-content: center;
		gap: 10px;
		padding: 10px 0 0;
		margin-top: 10px;
		border-top: 1px solid rgba(255,255,255,0.12);
	}
	.bt-leftbar__bottom .bt-leftbar__open,
	.bt-leftbar__bottom .bt-leftbar__close {
		width: 28px;
		height: 28px;
		border-radius: 8px;
	}
	.bt-leftbar__bottom .bt-leftbar__open svg,
	.bt-leftbar__bottom .bt-leftbar__close svg {
		width: 16px;
		height: 16px;
	}
	/* In collapsed: mostra solo open in fondo */
	body:not(.bt-leftbar-open) .bt-leftbar__bottom .bt-leftbar__close { display: none !important; }
	/* In open: mostra solo close in fondo */
	body.bt-leftbar-open .bt-leftbar__bottom .bt-leftbar__open { display: none !important; }

	.bt-sidebar-left .bt-nav-left__label,
	.bt-sidebar-left .bt-nav-left__count,
	.bt-sidebar-left .bt-nav-left__menu-slot { display: none !important; }
	.bt-sidebar-left .bt-nav-left__link { padding: 10px 0; justify-content: center; border-radius: 0; }
	.bt-sidebar-left .bt-nav-left__icon { width: 24px; height: 24px; border-radius: 8px; background: rgba(255,255,255,0.10); }
	.bt-sidebar-left .bt-nav-left__list { display: flex; flex-direction: column; align-items: center; }

	/* Aperta: diventa drawer */
	body.bt-leftbar-open .bt-sidebar-left {
		top: var(--bt-header-height, 40px);
		bottom: var(--bt-footer-bar-height, 40px);
		width: var(--bt-leftbar-mobile-expanded) !important;
		min-width: var(--bt-leftbar-mobile-expanded) !important;
		max-width: var(--bt-leftbar-mobile-expanded) !important;
		padding: 12px 12px;
		z-index: 99999; /* sotto postshow 100000 */
		box-shadow: 6px 0 22px rgba(0,0,0,0.25);
	}
	body.bt-leftbar-open .bt-leftbar__top {
		position: sticky;
		top: 0;
		z-index: 1;
		background: linear-gradient(180deg, var(--bt-leftbar-bg-2), var(--bt-leftbar-bg));
		justify-content: space-between;
		padding: 6px 4px 10px;
		border-bottom: 1px solid rgba(255,255,255,0.12);
		margin-bottom: 10px;
	}
	body.bt-leftbar-open .bt-leftbar__title { display: block !important; }
	body.bt-leftbar-open .bt-leftbar__close { display: inline-flex !important; width: 32px; height: 32px; }
	body.bt-leftbar-open .bt-leftbar__open { display: none; }

	body.bt-leftbar-open .bt-sidebar-left .bt-nav-left__label,
	body.bt-leftbar-open .bt-sidebar-left .bt-nav-left__count,
	body.bt-leftbar-open .bt-sidebar-left .bt-nav-left__menu-slot { display: block !important; }
	body.bt-leftbar-open .bt-sidebar-left .bt-nav-left__label,
	body.bt-leftbar-open .bt-sidebar-left .bt-nav-left__count { display: inline; }
	body.bt-leftbar-open .bt-sidebar-left .bt-nav-left__list { align-items: stretch; }
	body.bt-leftbar-open .bt-sidebar-left .bt-nav-left__link { padding: 12px 10px; justify-content: flex-start; border-radius: 14px; }
	body.bt-leftbar-open .bt-sidebar-left .bt-nav-left__icon { width: 40px; height: 40px; border-radius: 14px; }

	/* In open su mobile: testo completo */
	body.bt-leftbar-open .bt-sidebar-left .bt-nav-left__label {
		white-space: normal !important;
		overflow-wrap: anywhere;
		line-height: 1.2;
	}
}

/* Backdrop (iniettato via JS) */
.bt-leftbar-backdrop {
	position: fixed;
	inset: 0;
	background: rgba(0,0,0,0.35);
	z-index: 99998;
	opacity: 0;
	visibility: hidden;
	pointer-events: none;
	transition: opacity 0.22s ease, visibility 0.22s ease;
}
body.bt-leftbar-open .bt-leftbar-backdrop {
	opacity: 1;
	visibility: visible;
	pointer-events: auto;
}

/* Desktop: niente maschera/backdrop (non deve bloccare il click) */
@media (min-width: 993px) {
	.bt-leftbar-backdrop { display: none !important; }
}

