/* ============================================================
   Giardino Incantato – Mappa & Registro Camelie
   Stile frontend. I colori derivano da variabili impostabili
   dall'area di amministrazione (vedi class-gim-plugin.php).
   ============================================================ */

:root {
	--gim-bg: #f7f2ea;
	--gim-surface: #ffffff;
	--gim-accent: #c85b97;
	--gim-text: #3b3b3b;
	--gim-heading: #2f5d54;
	--gim-border: #e7ded0;
	--gim-row-alt: #faf6ef;
	--gim-radius: 12px;
}

/* ---------- Wrapper comuni ---------- */
.gim-table-wrap,
.gim-map-wrap {
	color: var(--gim-text);
	box-sizing: border-box;
	max-width: 100%;
}
.gim-table-wrap *,
.gim-map-wrap * {
	box-sizing: border-box;
}

/* ============================================================
   MAPPA
   ============================================================ */
.gim-map-wrap {
	width: 100%;
	max-width: var(--gim-map-maxw, 1000px);
	margin: 0 auto;
}
.gim-map {
	position: relative;
	width: 100%;
	line-height: 0;
}
.gim-map__bg {
	width: 100%;
	height: auto;
	display: block;
}
.gim-map__svg {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	pointer-events: auto;
}
.gim-map__caption {
	text-align: center;
	font-style: italic;
	color: var(--gim-heading);
	margin: 0.6em 0 0;
}

/* ============================================================
   TABELLA – contenitore
   ============================================================ */
.gim-table-wrap {
	position: relative;
	background: var(--gim-bg);
	border: 2px solid var(--gim-accent);
	border-radius: var(--gim-radius);
	padding: clamp(14px, 2.5vw, 26px);
	margin: 1.2em auto;
}

/* ---------- Toolbar (contatore + sort + ricerca) ---------- */
.gim-toolbar {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	margin-bottom: 14px;
}
.gim-count {
	font-weight: 700;
	font-size: 1.05rem;
	color: var(--gim-heading);
}
.gim-toolbar__right {
	display: flex;
	gap: 10px;
	align-items: center;
	flex-wrap: wrap;
}

.gim-sort__select {
	appearance: none;
	-webkit-appearance: none;
	background: var(--gim-surface);
	border: 1px solid var(--gim-border);
	border-radius: 999px;
	padding: 8px 34px 8px 16px;
	font: inherit;
	color: var(--gim-text);
	cursor: pointer;
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%23999' d='M6 8L0 0h12z'/%3E%3C/svg%3E");
	background-repeat: no-repeat;
	background-position: right 14px center;
}

.gim-search {
	position: relative;
	display: flex;
	align-items: center;
}
.gim-search__input {
	background: var(--gim-surface);
	border: 1px solid var(--gim-border);
	border-radius: 999px;
	padding: 8px 38px 8px 16px;
	font: inherit;
	color: var(--gim-text);
	min-width: 200px;
}
.gim-search__input:focus {
	outline: none;
	border-color: var(--gim-accent);
	box-shadow: 0 0 0 3px color-mix(in srgb, var(--gim-accent) 22%, transparent);
}
.gim-search__icon {
	position: absolute;
	right: 14px;
	font-size: 1.2rem;
	color: var(--gim-accent);
	pointer-events: none;
}

/* ---------- Filtri (pill + dropdown) ---------- */
.gim-filters {
	display: flex;
	flex-wrap: wrap;
	gap: 10px;
	margin-bottom: 18px;
}
.gim-filter {
	position: relative;
}
.gim-filter__btn {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	background: var(--gim-surface);
	border: 1px solid var(--gim-border);
	border-radius: 999px;
	padding: 8px 16px;
	font: inherit;
	color: var(--gim-text);
	cursor: pointer;
	transition: border-color .15s, box-shadow .15s, background .15s;
	max-width: 280px;
}
.gim-filter__btn:hover {
	border-color: var(--gim-accent);
}
.gim-filter__text {
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}
.gim-filter__chev {
	font-size: .8em;
	color: var(--gim-accent);
	transition: transform .15s;
}
.gim-filter.is-open .gim-filter__chev {
	transform: rotate(180deg);
}
.gim-filter.is-active .gim-filter__btn {
	background: var(--gim-accent);
	border-color: var(--gim-accent);
	color: #fff;
}
.gim-filter.is-active .gim-filter__chev {
	color: #fff;
}

.gim-filter__panel {
	position: absolute;
	z-index: 50;
	top: calc(100% + 6px);
	left: 0;
	min-width: 220px;
	max-width: 320px;
	max-height: 300px;
	overflow-y: auto;
	background: var(--gim-surface);
	border: 1px solid var(--gim-border);
	border-radius: calc(var(--gim-radius) - 2px);
	box-shadow: 0 10px 30px rgba(0, 0, 0, .12);
	display: none;
}
.gim-filter.is-open .gim-filter__panel {
	display: block;
}
.gim-filter__list {
	list-style: none;
	margin: 0;
	padding: 6px;
}
.gim-opt {
	padding: 8px 12px;
	border-radius: 8px;
	cursor: pointer;
	font-size: .95rem;
	line-height: 1.3;
}
.gim-opt:hover {
	background: var(--gim-bg);
}
.gim-opt.is-selected {
	background: color-mix(in srgb, var(--gim-accent) 16%, transparent);
	color: var(--gim-heading);
	font-weight: 600;
}

.gim-reset {
	background: transparent;
	border: 1px dashed var(--gim-accent);
	color: var(--gim-accent);
	border-radius: 999px;
	padding: 8px 16px;
	font: inherit;
	cursor: pointer;
}
.gim-reset:hover {
	background: color-mix(in srgb, var(--gim-accent) 12%, transparent);
}

/* ---------- Tabella ---------- */
.gim-table-scroll {
	position: relative;
	overflow-x: auto;
	border-radius: calc(var(--gim-radius) - 2px);
}
.gim-table {
	width: 100%;
	border-collapse: collapse;
	background: transparent;
	font-size: .98rem;
}
.gim-table thead th {
	text-align: left;
	color: var(--gim-heading);
	font-weight: 700;
	padding: 12px 14px;
	border-bottom: 2px solid var(--gim-border);
	white-space: nowrap;
}
.gim-table tbody td {
	padding: 12px 14px;
	border-bottom: 1px solid var(--gim-border);
	vertical-align: middle;
}
.gim-table tbody tr {
	background: var(--gim-surface);
}
.gim-table tbody tr:nth-child(even) {
	background: var(--gim-row-alt);
}
.gim-table tbody tr:hover {
	background: color-mix(in srgb, var(--gim-accent) 8%, var(--gim-surface));
}
.gim-col--image { width: 80px; }
.gim-col--title { font-weight: 600; color: var(--gim-heading); }
img.gim-thumb {
	width: 64px;
	height: 64px;
	object-fit: cover;
	border-radius: 8px;
	display: block;
}
.gim-detail-link {
	color: var(--gim-accent);
	font-weight: 600;
	text-decoration: none;
	white-space: nowrap;
}
.gim-detail-link:hover {
	text-decoration: underline;
}
.gim-empty { color: #b9b1a3; }
.gim-norows td {
	text-align: center;
	padding: 40px 14px;
	color: var(--gim-heading);
	font-style: italic;
}

/* ---------- Overlay di caricamento ---------- */
.gim-loading {
	position: absolute;
	inset: 0;
	background: color-mix(in srgb, var(--gim-bg) 70%, transparent);
	display: none;
	align-items: center;
	justify-content: center;
	border-radius: inherit;
}
.gim-table-wrap.is-loading .gim-loading {
	display: flex;
}
.gim-spinner {
	width: 38px;
	height: 38px;
	border: 4px solid color-mix(in srgb, var(--gim-accent) 25%, transparent);
	border-top-color: var(--gim-accent);
	border-radius: 50%;
	animation: gim-spin .8s linear infinite;
}
@keyframes gim-spin { to { transform: rotate(360deg); } }

/* ---------- Paginazione ---------- */
.gim-pagination-wrap {
	margin-top: 18px;
	display: flex;
	justify-content: center;
}
.gim-pagination {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
	align-items: center;
}
.gim-page {
	min-width: 38px;
	height: 38px;
	padding: 0 10px;
	background: var(--gim-surface);
	border: 1px solid var(--gim-border);
	border-radius: 8px;
	font: inherit;
	color: var(--gim-text);
	cursor: pointer;
	transition: background .15s, color .15s, border-color .15s;
}
.gim-page:hover:not(.is-disabled):not(.is-active) {
	border-color: var(--gim-accent);
	color: var(--gim-accent);
}
.gim-page.is-active {
	background: var(--gim-accent);
	border-color: var(--gim-accent);
	color: #fff;
	font-weight: 700;
	cursor: default;
}
.gim-page.is-disabled {
	opacity: .45;
	cursor: not-allowed;
}
.gim-page-dots {
	padding: 0 4px;
	color: var(--gim-heading);
}

/* highlight della zona attiva sulla mappa (applicato via JS sull'SVG) */

/* ============================================================
   RESPONSIVE – tabella a "schede" su mobile
   ============================================================ */
@media (max-width: 720px) {
	.gim-toolbar { justify-content: stretch; }
	.gim-toolbar__right { width: 100%; }
	.gim-search__input { flex: 1; min-width: 0; }

	.gim-table thead { display: none; }
	.gim-table, .gim-table tbody, .gim-table tr, .gim-table td { display: block; width: 100%; }
	.gim-table tbody tr {
		border: 1px solid var(--gim-border);
		border-radius: calc(var(--gim-radius) - 2px);
		margin-bottom: 12px;
		padding: 6px 4px;
	}
	.gim-table tbody td {
		display: flex;
		justify-content: space-between;
		gap: 16px;
		border-bottom: 1px solid var(--gim-border);
		text-align: right;
	}
	.gim-table tbody tr td:last-child { border-bottom: none; }
	.gim-table tbody td::before {
		content: attr(data-label);
		font-weight: 700;
		color: var(--gim-heading);
		text-align: left;
	}
	.gim-col--image { width: auto; }
	.gim-col--image::before { align-self: center; }
}
