/**
 * Scheda singola immobile PVIP – stile ispirato a Gestione Affiti e Vendite
 *
 * @package Immobili_Pubblici
 */

.pvip-single-immobile {
	--pvip-color: #1a1a2e;
	--pvip-color-light: #4a4a6a;
	--pvip-accent: #0d9488;
	--pvip-accent-hover: #0f766e;
	--pvip-link: #0d9488;
	--pvip-link-hover: #0f766e;
	--pvip-bg: #f8fafc;
	--pvip-border: #e2e8f0;
	--pvip-radius: 12px;
	--pvip-shadow: 0 4px 24px rgba(0, 0, 0, 0.06);
	--pvip-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, sans-serif;
	--pvip-max: 1200px;

	font-family: var(--pvip-font);
	color: var(--pvip-color);
	line-height: 1.6;
	max-width: 100%;
	margin: 0;
	padding: 0;
	box-sizing: border-box;
}

.pvip-single-immobile a {
	color: var(--pvip-link);
	text-decoration: none;
}

.pvip-single-immobile a:hover {
	color: var(--pvip-link-hover);
}

.pvip-single-immobile *,
.pvip-single-immobile *::before,
.pvip-single-immobile *::after {
	box-sizing: border-box;
}

/* Hero */
.pvip-single-hero {
	position: relative;
	width: 100%;
	max-width: 100%;
	margin-left: 0;
	margin-right: 0;
	margin-top: 0;
	margin-bottom: 1rem;
	border-radius: 16px;
	overflow: hidden;
	background-color: var(--pvip-bg);
	background-size: cover;
	background-position: center;
	background-repeat: no-repeat;
}

.pvip-single-hero__media {
	position: relative;
	aspect-ratio: 16 / 9;
	max-height: 70vh;
	min-height: 280px;
	background: transparent;
	display: flex;
	align-items: center;
	justify-content: center;
}

/* Header */
.pvip-single-header {
	padding: 1.5rem 1rem 1rem;
	border-bottom: 1px solid var(--pvip-border);
}

.pvip-single-header__inner {
	max-width: var(--pvip-max);
	margin: 0 auto;
	padding: 0 1rem;
}

.pvip-single-header__badges {
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem;
	margin-bottom: 0.75rem;
}

.pvip-badge {
	display: inline-block;
	padding: 0.25rem 0.6rem;
	font-size: 0.75rem;
	font-weight: 600;
	border-radius: 6px;
	background: color-mix(in srgb, var(--pvip-accent) 12%, white);
	color: var(--pvip-accent);
	border: 1px solid color-mix(in srgb, var(--pvip-accent) 25%, transparent);
}

.pvip-badge--natura { background: color-mix(in srgb, var(--pvip-accent) 15%, white); }
.pvip-badge--stato { background: #fef3c7; color: #b45309; border-color: #fde68a; }
.pvip-badge--localita { background: #f0fdfa; color: #0f766e; border-color: #ccfbf1; }

.pvip-single-header__title {
	margin: 0 0 0.5rem;
	font-size: clamp(1.35rem, 3.5vw, 1.75rem);
	font-weight: 700;
	line-height: 1.25;
	color: var(--pvip-color);
}

.pvip-single-header__location {
	margin: 0;
	font-size: 0.9375rem;
	color: var(--pvip-color-light);
	line-height: 1.4;
}

/* Layout principale */
.pvip-single__inner {
	max-width: var(--pvip-max);
	margin: 0 auto;
	padding: 1.25rem 1rem 2rem;
	display: grid;
	grid-template-columns: 1fr;
	gap: 1.25rem;
}

.pvip-single__inner--with-sidebar {
	grid-template-columns: 1fr;
}

@media (min-width: 900px) {
	.pvip-single__inner--with-sidebar {
		grid-template-columns: 1fr 320px;
		gap: 1.5rem;
	}
}

.pvip-single__main {
	order: 0;
	min-width: 0;
}

.pvip-single__sidebar {
	order: 1;
	min-width: 0;
}

/* Sidebar – box Comune (come agenzia/agente nell’altro plugin) */
.pvip-sidebar-box {
	background: #fff;
	border: 1px solid var(--pvip-border);
	border-radius: var(--pvip-radius);
	box-shadow: var(--pvip-shadow);
	padding: 1.25rem;
}

@media (min-width: 900px) {
	.pvip-sidebar-box:first-child {
		position: sticky;
		top: 1.5rem;
		z-index: 10;
	}
}

/* Impedisce al box contatti di sovrapporsi al box comune */
@media (min-width: 900px) {
	.pvip-single__sidebar {
		position: sticky;
		top: 1.5rem;
		align-self: flex-start;
	}
	
	.pvip-sidebar-box:first-child {
		position: static;
	}
}

.pvip-sidebar-box__title {
	margin: 0 0 0.75rem;
	font-size: 1rem;
	font-weight: 700;
	color: var(--pvip-color);
	border-bottom: 2px solid var(--pvip-accent);
	padding-bottom: 0.5rem;
	display: block;
}

.pvip-sidebar-box__content {
	font-size: 0.9375rem;
	line-height: 1.5;
}

.pvip-sidebar-box__comune-logo {
	margin: 0 0 1rem;
	text-align: center;
}

.pvip-sidebar-box__comune-logo img {
	max-width: 80px;
	height: auto;
}

.pvip-sidebar-box__comune-name {
	margin: 0 0 0;
	font-weight: 700;
	font-size: 1.125rem;
	color: var(--pvip-color);
	text-align: center;
	padding-bottom: 1rem;
}

.pvip-sidebar-box__section {
	margin-top: 1rem;
	padding-top: 1rem;
	border-top: 1px solid #f0f0f0;
}

.pvip-sidebar-box__section:first-of-type {
	margin-top: 0;
	padding-top: 0;
	border-top: none;
}

.pvip-sidebar-box__section-title {
	margin: 0 0 0.75rem;
	font-size: 0.875rem;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.5px;
	color: var(--pvip-accent);
}

.pvip-sidebar-box__meta {
	margin: 0.35rem 0 0;
	color: var(--pvip-color-light);
	font-size: 0.875rem;
}

.pvip-sidebar-box--contatti {
	margin-top: 2rem;
}

.pvip-contatti-content {
	padding: 0;
}

.pvip-sidebar-box__meta--with-icon {
	display: flex;
	align-items: flex-start;
	gap: 0.5rem;
	padding: 0.75rem 0.75rem 0.75rem 0.5rem;
	margin: 0;
	background: #fff;
	border-bottom: 1px solid rgba(0, 0, 0, 0.05);
	transition: background 0.2s ease;
}

.pvip-sidebar-box__meta--with-icon:hover {
	background: #f8f9fa;
}

.pvip-sidebar-box__meta--with-icon:last-child {
	border-bottom: none;
}

.pvip-contact-icon {
	flex-shrink: 0;
	margin-top: 0.1rem;
	color: var(--pvip-accent);
	opacity: 0.85;
}

.pvip-sidebar-box__meta--with-icon a {
	color: var(--pvip-accent);
	text-decoration: none;
	transition: all 0.2s ease;
	font-weight: 500;
}

.pvip-sidebar-box__meta--with-icon a:hover {
	color: var(--pvip-accent-hover);
}

.pvip-sidebar-box__label {
	font-weight: 600;
	color: var(--pvip-color);
	margin-right: 0.25rem;
}

/* Sezioni */
.pvip-single-section {
	margin-bottom: 1.25rem;
	padding: 1.25rem;
	background: #fff;
	border-radius: var(--pvip-radius);
	box-shadow: var(--pvip-shadow);
	border: 1px solid var(--pvip-border);
}

.pvip-single-section:last-child {
	margin-bottom: 0;
}

.pvip-single-section__title {
	margin: 0 0 0.75rem;
	font-size: 1.125rem;
	font-weight: 600;
	color: var(--pvip-color);
	border-bottom: 2px solid var(--pvip-accent);
	padding-bottom: 0.5rem;
	display: inline-block;
}

/* Griglia info (label + value) */
.pvip-info-grid {
	list-style: none;
	margin: 0;
	padding: 0;
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
	gap: 1rem;
}

@media (min-width: 600px) {
	.pvip-info-grid {
		grid-template-columns: repeat(2, 1fr);
	}
}

@media (min-width: 900px) {
	.pvip-info-grid {
		grid-template-columns: repeat(3, 1fr);
	}
}

.pvip-info-item {
	display: flex;
	flex-direction: column;
	gap: 0.35rem;
	padding: 0.9rem 1rem;
	background: var(--pvip-bg);
	border: 1px solid var(--pvip-border);
	border-radius: 10px;
}

.pvip-info-item__label {
	font-size: 0.8125rem;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 0.04em;
	color: var(--pvip-color-light);
	line-height: 1.2;
}

.pvip-info-item__value {
	font-weight: 600;
	font-size: 1rem;
	color: var(--pvip-color);
	line-height: 1.3;
}

/* Mappa (Leaflet) */
.pvip-single-map-section {
	padding-bottom: 1.25rem;
}

.pvip-single-map-section .pvip-single-section__title {
	display: block;
	margin-bottom: 0.75rem;
}

.pvip-single-map {
	width: 100%;
	height: 360px;
	min-height: 280px;
	border-radius: 10px;
	overflow: hidden;
	border: 1px solid var(--pvip-border);
	background: var(--pvip-bg);
}

.pvip-single-map.leaflet-container {
	font-family: var(--pvip-font);
}

/* ----- Descrizione ----- */
.pvip-single-desc__content {
	font-size: 1rem;
	line-height: 1.65;
	color: var(--pvip-color);
	overflow-x: auto;
}
.pvip-single-desc__content p:last-child {
	margin-bottom: 0;
}

/* Tabelle nella descrizione */
.pvip-single-desc__content table {
	width: 100%;
	margin: 1.5rem 0;
	border-collapse: collapse;
	border: 1px solid #e2e8f0;
	background: #fff;
	font-size: 0.95rem;
	box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
	table-layout: auto;
}

.pvip-single-desc__content thead {
	background: linear-gradient(135deg, #0d9488 0%, #14b8a6 100%);
	color: #fff;
}

.pvip-single-desc__content th {
	padding: 0.875rem 1rem;
	text-align: left;
	font-weight: 600;
	border-bottom: 2px solid #0d9488;
	font-size: 0.9rem;
	text-transform: uppercase;
	letter-spacing: 0.025em;
	white-space: nowrap;
	min-width: 100px;
}

.pvip-single-desc__content td {
	padding: 0.75rem 1rem;
	border-bottom: 1px solid #f1f5f9;
}

.pvip-single-desc__content tbody tr {
	transition: background-color 0.2s;
}

.pvip-single-desc__content tbody tr:nth-child(even) {
	background-color: #f8fafc;
}

.pvip-single-desc__content tbody tr:hover {
	background-color: #f0fdfa;
}

/* Mobile: riduci padding */
@media (max-width: 768px) {
	.pvip-single-desc__content th,
	.pvip-single-desc__content td {
		padding: 0.5rem 0.75rem;
		font-size: 0.85rem;
	}
	
	.pvip-single-desc__content th {
		min-width: 80px;
	}
}

/* ----- Galleria (come GAV) ----- */
.pvip-gallery {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
	gap: 0.75rem;
}

.pvip-gallery__item {
	display: block;
	width: 100%;
	margin: 0;
	padding: 0;
	border: 1px solid var(--pvip-border);
	border-radius: 8px;
	overflow: hidden;
	background: var(--pvip-border);
	cursor: pointer;
	aspect-ratio: 4 / 3;
	transition: opacity 0.2s ease, transform 0.2s ease;
}

.pvip-gallery__item:hover {
	opacity: 0.9;
	transform: scale(1.02);
}

.pvip-gallery__item:focus {
	outline: 2px solid var(--pvip-accent);
	outline-offset: 2px;
}

.pvip-gallery__item img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
	pointer-events: none;
}

.pvip-gallery__item--more {
	display: none;
}
.pvip-gallery.pvip-gallery--show-all .pvip-gallery__item--more {
	display: block;
}

@media (max-width: 599px) {
	.pvip-gallery__item--more-mobile {
		display: none;
	}
	.pvip-gallery.pvip-gallery--show-all .pvip-gallery__item--more-mobile {
		display: block;
	}
}

.pvip-gallery-actions {
	margin-top: 1rem;
	text-align: center;
}

.pvip-gallery-load-more {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	padding: 0.6rem 1.25rem;
	font-size: 0.95rem;
	font-weight: 600;
	color: var(--pvip-accent);
	background: #fff;
	border: 2px solid var(--pvip-accent);
	border-radius: var(--pvip-radius);
	cursor: pointer;
	transition: color 0.2s ease, background 0.2s ease, border-color 0.2s ease;
}

.pvip-gallery-load-more:hover,
.pvip-gallery-load-more:focus {
	color: #fff;
	background: var(--pvip-accent);
	outline: none;
}

.pvip-gallery-load-more[aria-pressed="true"],
.pvip-gallery-load-more.pvip-gallery-load-more--expanded {
	color: var(--pvip-color);
	background: var(--pvip-border);
	border-color: var(--pvip-border);
}

.pvip-gallery-load-more[aria-pressed="true"]:hover,
.pvip-gallery-load-more.pvip-gallery-load-more--expanded:hover {
	background: var(--pvip-color-light);
	border-color: var(--pvip-color-light);
	color: #fff;
}

/* Modal lightbox galleria */
.pvip-gallery-modal {
	position: fixed;
	inset: 0;
	z-index: 100000;
	display: flex;
	align-items: center;
	justify-content: center;
	visibility: hidden;
	opacity: 0;
	transition: visibility 0.2s, opacity 0.2s ease;
}

.pvip-gallery-modal--open {
	visibility: visible;
	opacity: 1;
}

.pvip-gallery-modal__backdrop {
	position: absolute;
	inset: 0;
	background: rgba(0, 0, 0, 0.92);
	cursor: pointer;
}

.pvip-gallery-modal__inner {
	position: relative;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 100%;
	height: 100%;
	max-width: 100vw;
	max-height: 100vh;
	padding: 3rem 4rem;
	box-sizing: border-box;
}

.pvip-gallery-modal__img-wrap {
	flex: 1;
	display: flex;
	align-items: center;
	justify-content: center;
	max-width: 100%;
	max-height: 100%;
}

.pvip-gallery-modal__img {
	max-width: 100%;
	max-height: calc(100vh - 6rem);
	width: auto;
	height: auto;
	object-fit: contain;
	display: block;
}

.pvip-gallery-modal__close {
	position: absolute;
	top: 1rem;
	right: 1rem;
	z-index: 2;
	width: 2.5rem;
	height: 2.5rem;
	padding: 0;
	border: none;
	background: rgba(255, 255, 255, 0.15);
	color: #fff;
	font-size: 1.75rem;
	line-height: 1;
	cursor: pointer;
	border-radius: 50%;
	transition: background 0.2s ease;
}

.pvip-gallery-modal__close:hover,
.pvip-gallery-modal__close:focus {
	background: rgba(255, 255, 255, 0.3);
	outline: none;
}

.pvip-gallery-modal__prev,
.pvip-gallery-modal__next {
	position: absolute;
	top: 50%;
	transform: translateY(-50%);
	z-index: 2;
	width: 3rem;
	height: 3rem;
	padding: 0;
	border: none;
	background: rgba(255, 255, 255, 0.15);
	color: #fff;
	font-size: 2rem;
	line-height: 1;
	cursor: pointer;
	border-radius: 50%;
	transition: background 0.2s ease;
}

.pvip-gallery-modal__prev:hover,
.pvip-gallery-modal__prev:focus,
.pvip-gallery-modal__next:hover,
.pvip-gallery-modal__next:focus {
	background: rgba(255, 255, 255, 0.3);
	outline: none;
}

.pvip-gallery-modal__prev {
	left: 1rem;
}

.pvip-gallery-modal__next {
	right: 1rem;
}

.pvip-gallery-modal__counter {
	position: absolute;
	bottom: 1rem;
	left: 50%;
	transform: translateX(-50%);
	z-index: 2;
	padding: 0.35rem 0.75rem;
	background: rgba(0, 0, 0, 0.5);
	color: #fff;
	font-size: 0.875rem;
	border-radius: 4px;
}

@media (max-width: 599px) {
	.pvip-gallery-modal__inner {
		padding: 1rem;
		padding-left: max(1rem, env(safe-area-inset-left));
		padding-right: max(1rem, env(safe-area-inset-right));
	}
	.pvip-gallery-modal__img {
		max-height: calc(100vh - 2rem);
		max-height: calc(100dvh - 2rem);
	}
	.pvip-gallery-modal__close {
		top: max(0.5rem, env(safe-area-inset-top));
		right: max(0.5rem, env(safe-area-inset-right));
		width: 44px;
		height: 44px;
		min-width: 44px;
		min-height: 44px;
		font-size: 1.5rem;
	}
	.pvip-gallery-modal__prev,
	.pvip-gallery-modal__next {
		width: 44px;
		height: 44px;
		min-width: 44px;
		min-height: 44px;
		font-size: 1.5rem;
	}
	.pvip-gallery-modal__prev {
		left: max(0.5rem, env(safe-area-inset-left));
	}
	.pvip-gallery-modal__next {
		right: max(0.5rem, env(safe-area-inset-right));
	}
	.pvip-gallery-modal__counter {
		bottom: max(0.5rem, env(safe-area-inset-bottom));
	}
}

/* ----- Video (come GAV) ----- */
.pvip-single-video__embed {
	position: relative;
	padding-bottom: 56.25%;
	height: 0;
	overflow: hidden;
	border-radius: 8px;
	background: var(--pvip-bg);
}

.pvip-single-video__embed iframe {
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
}

.pvip-video-link,
.pvip-single-video__embed .pvip-video-link {
	display: inline-flex;
	align-items: center;
	padding: 0.75rem 1.25rem;
	background: var(--pvip-accent);
	color: #fff;
	text-decoration: none;
	border-radius: 8px;
	font-weight: 500;
	transition: background 0.2s;
}

.pvip-video-link:hover,
.pvip-single-video__embed .pvip-video-link:hover {
	background: var(--pvip-accent-hover);
	color: #fff;
}

/* Allegati */
.pvip-allegati-list {
	list-style: none;
	margin: 0;
	padding: 0;
	display: flex;
	flex-direction: column;
	gap: 0.75rem;
}

.pvip-allegato-item {
	margin: 0;
	padding: 0;
}

.pvip-allegato-link {
	display: flex;
	align-items: center;
	padding: 1rem;
	background: #f9f9f9;
	border: 1px solid #e0e0e0;
	border-radius: 8px;
	text-decoration: none;
	color: var(--pvip-text);
	transition: all 0.2s;
	gap: 1rem;
}

.pvip-allegato-link:hover {
	background: #fff;
	border-color: var(--pvip-accent);
	box-shadow: 0 2px 8px rgba(0,0,0,0.08);
	transform: translateY(-1px);
}

.pvip-allegato-icon {
	flex-shrink: 0;
	width: 40px;
	height: 40px;
	display: flex;
	align-items: center;
	justify-content: center;
	background: var(--pvip-accent);
	color: #fff;
	border-radius: 6px;
}

.pvip-allegato-info {
	flex: 1;
	min-width: 0;
	display: flex;
	flex-direction: column;
	gap: 0.25rem;
}

.pvip-allegato-name {
	font-weight: 500;
	font-size: 0.95rem;
	color: var(--pvip-text);
	word-break: break-word;
}

.pvip-allegato-meta {
	font-size: 0.85rem;
	color: #666;
}

.pvip-allegato-download {
	flex-shrink: 0;
	width: 32px;
	height: 32px;
	display: flex;
	align-items: center;
	justify-content: center;
	background: var(--pvip-accent);
	color: #fff;
	border-radius: 50%;
	transition: background 0.2s;
}

.pvip-allegato-link:hover .pvip-allegato-download {
	background: var(--pvip-accent-hover);
}

/* Responsive */
@media (max-width: 640px) {
	.pvip-single-header {
		padding: 1rem 0.75rem;
	}

	.pvip-single-header__inner {
		padding: 0 0.5rem;
	}

	.pvip-single__inner {
		padding-left: 0.75rem;
		padding-right: 0.75rem;
	}

	.pvip-single-section {
		padding: 1rem;
	}

	.pvip-info-grid {
		grid-template-columns: 1fr;
		gap: 0.75rem;
	}
}
