/* Fioreimmo header */
.fi-header {
	--fi-header-bg: #ffffff;
	--fi-header-color: #1f2937;
	--fi-header-primary: var(--fi-btn, #41668d);
	position: relative;
	z-index: 100;
	background: var(--fi-header-bg);
	color: var(--fi-header-color);
	box-shadow: 0 1px 0 rgba(0, 0, 0, 0.06);
}
.fi-header--dark {
	--fi-header-bg: #1f2937;
	--fi-header-color: #ffffff;
}
.fi-header--sticky { position: sticky; top: 0; }
.admin-bar .fi-header--sticky { top: 32px; }
@media (max-width: 782px) { .admin-bar .fi-header--sticky { top: 46px; } }

/* Desktop: tre colonne, logo a sinistra, menu centrato, azioni (lingua, bottone) a destra. */
.fi-header__inner {
	display: grid;
	grid-template-columns: 1fr auto 1fr;
	align-items: center;
	gap: 1.5rem;
	max-width: var(--fi-container, 1300px);
	margin-inline: auto;
	padding: 0.85rem var(--fi-gutter, 1.25rem);
	box-sizing: border-box;
}
.fi-header__logo { display: inline-flex; align-items: center; text-decoration: none; color: inherit; justify-self: start; }
.fi-header__logo img { display: block; height: auto; max-width: 100%; }
.fi-header__name { font-size: 1.4rem; font-weight: 700; letter-spacing: -0.01em; }

/* Il contenitore del pannello mobile non partecipa alla griglia: menu e azioni sono figli diretti. */
.fi-header__nav { display: contents; }
.fi-header__nav > nav { justify-self: center; min-width: 0; }
.fi-header__menu, .fi-header__menu ul { list-style: none; margin: 0; padding: 0; }
.fi-header__menu { display: flex; align-items: center; gap: 0.25rem; }
.fi-header__menu li { position: relative; }
.fi-header__menu a {
	display: block;
	padding: 0.5rem 0.75rem;
	color: inherit;
	text-decoration: none;
	font-weight: 500;
	border-radius: 4px;
	transition: background 0.15s ease;
}
.fi-header__menu a:hover,
.fi-header__menu .current-menu-item > a,
.fi-header__menu .current-menu-ancestor > a { background: rgba(127, 127, 127, 0.12); }

/* Sottomenu (desktop) */
.fi-header__menu .sub-menu {
	position: absolute;
	top: 100%;
	left: 0;
	min-width: 280px;
	padding: 0.4rem;
	background: var(--fi-header-bg);
	border-radius: 6px;
	box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
	opacity: 0;
	visibility: hidden;
	transform: translateY(6px);
	transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s;
}
.fi-header__menu li:hover > .sub-menu,
.fi-header__menu li:focus-within > .sub-menu { opacity: 1; visibility: visible; transform: none; }
/* La tendina si allinea al bordo sinistro della voce; .is-flip (header.js) la allinea a destra se sforerebbe. */
.fi-header__menu > li > .sub-menu.is-flip { left: auto; right: 0; }
/* Tendine lunghe senza terzo livello: non escono dallo schermo, scorrono. */
.fi-header__menu > li > .sub-menu:not(:has(.sub-menu)) {
	max-height: calc(100vh - var(--fi-header-h, 80px) - 1rem);
	overflow-y: auto;
}

/* Terzo livello (Services -> categoria -> sezioni): tendina a lato della categoria.
   La categoria è un <button> (aria-expanded): si apre con hover, focus, click o tap. */
.fi-header__menu .sub-menu .sub-menu {
	top: -0.4rem;
	left: 100%;
	margin-left: 0.25rem;
}
/* .is-flip (header.js): a destra non c'è spazio, la tendina si apre a sinistra. */
.fi-header__menu .sub-menu .sub-menu.is-flip {
	left: auto;
	right: 100%;
	margin-left: 0;
	margin-right: 0.25rem;
}
.fi-header__menu li.is-open > .sub-menu { opacity: 1; visibility: visible; transform: none; }
.fi-header__menu-heading {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 0.75rem;
	width: 100%;
	padding: 0.5rem 0.75rem;
	border: 0;
	border-radius: 4px;
	background: none;
	color: inherit;
	font: inherit;
	font-weight: 500;
	text-align: left;
	white-space: nowrap;
	cursor: pointer;
	transition: background 0.15s ease;
}
.fi-header__menu-heading::after {
	content: "";
	flex: none;
	width: 0.45em;
	height: 0.45em;
	border: solid currentColor;
	border-width: 0 2px 2px 0;
	transform: rotate(-45deg);
	opacity: 0.6;
}
.fi-header__menu li:has(> .sub-menu.is-flip) > .fi-header__menu-heading::after { transform: rotate(135deg); order: -1; }
.fi-header__menu li:has(> .sub-menu.is-flip) > .fi-header__menu-heading { justify-content: flex-start; }
/* color: inherit anche su hover/focus/active: il tema (GeneratePress) mette
   testo bianco su fondo scuro a tutti i button:hover e button:focus. */
.fi-header__menu-heading:hover,
.fi-header__menu-heading:focus,
.fi-header__menu-heading:active,
.fi-header__menu li:hover > .fi-header__menu-heading,
.fi-header__menu li.is-open > .fi-header__menu-heading {
	background: rgba(127, 127, 127, 0.12);
	color: inherit;
	border: 0;
}
.fi-header__menu-heading:focus-visible { outline: 2px solid currentColor; outline-offset: -2px; }


.fi-header__actions { display: flex; align-items: center; gap: 1rem; justify-self: end; }
.fi-header__phone { color: inherit; text-decoration: none; font-weight: 600; white-space: nowrap; }
/* Bottone: stili completi qui perché shortcodes.css non è sempre caricato. */
.fi-header .fi-btn {
	display: inline-block;
	padding: 0.6em 1.25em;
	border-radius: var(--fi-radius, 6px);
	background: var(--fi-header-primary);
	color: #fff;
	font-weight: 600;
	line-height: 1.2;
	text-decoration: none;
	white-space: nowrap;
	transition: opacity 0.15s ease;
}
.fi-header .fi-btn:hover { opacity: 0.9; color: #fff; text-decoration: none; }

/* Selettore lingua */
.fi-header__lang {
	display: flex;
	align-items: center;
	gap: 0.15rem;
	list-style: none;
	margin: 0;
	padding: 0;
}
.fi-header__lang a {
	display: inline-flex;
	align-items: center;
	gap: 0.35rem;
	padding: 0.35rem 0.5rem;
	border-radius: 4px;
	color: inherit;
	text-decoration: none;
	font-size: 0.85rem;
	font-weight: 600;
	letter-spacing: 0.04em;
	opacity: 0.7;
	transition: opacity 0.15s ease, background 0.15s ease;
}
.fi-header__lang a:hover { opacity: 1; background: rgba(127, 127, 127, 0.12); }
.fi-header__lang .is-current a { opacity: 1; text-decoration: underline; text-underline-offset: 4px; }
.fi-header__lang-flag img { display: block; width: 18px; height: auto; }
.fi-header__lang--flags a { padding: 0.35rem; }

/* Hamburger */
.fi-header__toggle {
	display: none;
	width: 44px;
	height: 44px;
	padding: 10px;
	border: 0;
	background: none;
	cursor: pointer;
	flex-direction: column;
	justify-content: space-between;
}
.fi-header__toggle span {
	display: block;
	height: 2px;
	background: currentColor;
	border-radius: 2px;
	transition: transform 0.2s ease, opacity 0.2s ease;
}
.fi-header__toggle[aria-expanded="true"] span:nth-child(1) { transform: translateY(11px) rotate(45deg); }
.fi-header__toggle[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.fi-header__toggle[aria-expanded="true"] span:nth-child(3) { transform: translateY(-11px) rotate(-45deg); }

/* Mobile */
@media (max-width: 900px) {
	.fi-header__inner { display: flex; justify-content: space-between; }
	.fi-header__toggle { display: flex; color: inherit; }
	.fi-header__nav {
		display: none;
		position: absolute;
		top: 100%;
		left: 0;
		right: 0;
		flex-direction: column;
		align-items: stretch;
		gap: 0.5rem;
		padding: 0.75rem var(--fi-gutter, 1.25rem) 1.25rem;
		background: var(--fi-header-bg);
		box-shadow: 0 12px 24px rgba(0, 0, 0, 0.12);
		/* Con l'header sticky il pannello resta fisso: deve scorrere da solo. */
		max-height: calc(100vh - var(--fi-header-h, 80px));
		overflow-y: auto;
	}
	.fi-header.is-open .fi-header__nav { display: flex; }
	.fi-header__menu { flex-direction: column; align-items: stretch; gap: 0; }
	.fi-header__menu a { padding: 0.75rem 0.5rem; }
	.fi-header__menu .sub-menu {
		position: static;
		opacity: 1;
		visibility: visible;
		transform: none;
		box-shadow: none;
		padding: 0 0 0 1rem;
	}
	.fi-header__menu .sub-menu .sub-menu { display: none; margin: 0; }
	.fi-header__menu li.is-open > .sub-menu { display: block; }
	.fi-header__menu-heading { padding: 0.75rem 0.5rem; white-space: normal; }
	.fi-header__menu-heading::after,
	.fi-header__menu li:has(> .sub-menu.is-flip) > .fi-header__menu-heading::after { transform: rotate(45deg); order: 0; }
	.fi-header__menu li:has(> .sub-menu.is-flip) > .fi-header__menu-heading { justify-content: space-between; }
	.fi-header__menu li.is-open > .fi-header__menu-heading::after { transform: rotate(-135deg); }
	.fi-header__actions { flex-direction: column; align-items: stretch; gap: 0.75rem; padding-top: 0.5rem; }
	.fi-header__phone, .fi-header__cta { text-align: center; }
	.fi-header__lang { justify-content: center; }
}
