/*
 * left&right Dropbox Portal - stili frontend
 * Nessuna dipendenza esterna. Le variabili possono essere sovrascritte dal tema.
 */

.lrdbp-portal {
	--lrdbp-accent: #1f2a44;
	--lrdbp-bg: #ffffff;
	--lrdbp-surface: #f7f8fa;
	--lrdbp-border: #e3e6ec;
	--lrdbp-text: #1b1f27;
	--lrdbp-muted: #6b7280;
	--lrdbp-radius: 10px;

	box-sizing: border-box;
	color: var(--lrdbp-text);
	font-size: 15px;
	line-height: 1.5;
	background: var(--lrdbp-bg);
	border: 1px solid var(--lrdbp-border);
	border-radius: var(--lrdbp-radius);
	overflow: hidden;
}

.lrdbp-portal *,
.lrdbp-portal *::before,
.lrdbp-portal *::after {
	box-sizing: inherit;
}

.lrdbp-portal svg {
	width: 18px;
	height: 18px;
	fill: none;
	stroke: currentColor;
	stroke-width: 1.8;
	stroke-linecap: round;
	stroke-linejoin: round;
}

.lrdbp-title {
	margin: 0;
	padding: 18px 18px 0;
	font-size: 1.15em;
}

/* ---------- Toolbar ---------- */

.lrdbp-toolbar {
	display: flex;
	flex-wrap: wrap;
	gap: 10px;
	align-items: center;
	padding: 14px 18px;
	background: var(--lrdbp-surface);
	border-bottom: 1px solid var(--lrdbp-border);
}

.lrdbp-field {
	position: relative;
	display: flex;
	align-items: center;
}

.lrdbp-field-search {
	flex: 1 1 220px;
	min-width: 180px;
}

.lrdbp-search-input,
.lrdbp-root-select {
	width: 100%;
	padding: 8px 12px;
	font: inherit;
	color: inherit;
	background: var(--lrdbp-bg);
	border: 1px solid var(--lrdbp-border);
	border-radius: 8px;
	outline-offset: 2px;
}

.lrdbp-search-input:focus,
.lrdbp-root-select:focus,
.lrdbp-btn:focus-visible,
.lrdbp-row:focus-visible {
	outline: 2px solid var(--lrdbp-accent);
}

.lrdbp-search-clear {
	position: absolute;
	right: 6px;
	width: 26px;
	height: 26px;
	padding: 0;
	font-size: 18px;
	line-height: 1;
	color: var(--lrdbp-muted);
	background: none;
	border: 0;
	border-radius: 50%;
	cursor: pointer;
}

.lrdbp-toolbar-actions {
	display: flex;
	gap: 6px;
	margin-left: auto;
}

.lrdbp-btn {
	display: inline-flex;
	gap: 6px;
	align-items: center;
	justify-content: center;
	padding: 8px 12px;
	font: inherit;
	color: inherit;
	text-decoration: none;
	background: var(--lrdbp-bg);
	border: 1px solid var(--lrdbp-border);
	border-radius: 8px;
	cursor: pointer;
	transition: background .15s ease, border-color .15s ease;
}

.lrdbp-btn:hover {
	background: var(--lrdbp-surface);
	border-color: var(--lrdbp-accent);
}

.lrdbp-btn-icon {
	width: 36px;
	height: 36px;
	padding: 0;
}

.lrdbp-btn-icon.is-active {
	color: #fff;
	background: var(--lrdbp-accent);
	border-color: var(--lrdbp-accent);
}

.lrdbp-btn-primary {
	color: #fff;
	background: var(--lrdbp-accent);
	border-color: var(--lrdbp-accent);
}

.lrdbp-btn-primary:hover {
	filter: brightness(1.12);
	background: var(--lrdbp-accent);
}

/* ---------- Breadcrumb ---------- */

.lrdbp-breadcrumbs {
	display: flex;
	flex-wrap: wrap;
	gap: 4px;
	align-items: center;
	padding: 10px 18px;
	font-size: .92em;
	color: var(--lrdbp-muted);
	border-bottom: 1px solid var(--lrdbp-border);
}

.lrdbp-breadcrumbs:empty {
	display: none;
}

.lrdbp-crumb {
	padding: 2px 4px;
	color: var(--lrdbp-accent);
	background: none;
	border: 0;
	border-radius: 4px;
	font: inherit;
	cursor: pointer;
}

.lrdbp-crumb[aria-current="page"] {
	color: var(--lrdbp-muted);
	cursor: default;
}

.lrdbp-crumb-sep {
	opacity: .5;
}

/* ---------- Stato ---------- */

.lrdbp-status {
	padding: 0 18px;
}

.lrdbp-status:not(:empty) {
	padding: 14px 18px;
}

.lrdbp-status .lrdbp-error {
	padding: 10px 14px;
	color: #7f1d1d;
	background: #fef2f2;
	border: 1px solid #fecaca;
	border-radius: 8px;
}

.lrdbp-spinner {
	display: inline-block;
	width: 16px;
	height: 16px;
	margin-right: 8px;
	vertical-align: -3px;
	border: 2px solid var(--lrdbp-border);
	border-top-color: var(--lrdbp-accent);
	border-radius: 50%;
	animation: lrdbp-spin .7s linear infinite;
}

@keyframes lrdbp-spin {
	to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
	.lrdbp-spinner { animation-duration: 2s; }
}

/* ---------- Contenuto ---------- */

.lrdbp-content {
	overflow: auto;
}

/* L'altezza massima si attiva solo se lo shortcode passa l'attributo height. */
.lrdbp-portal[style*="--lrdbp-height"] .lrdbp-content {
	max-height: var(--lrdbp-height);
}

.lrdbp-empty {
	padding: 34px 18px;
	color: var(--lrdbp-muted);
	text-align: center;
}

/* Vista elenco */

.lrdbp-table {
	width: 100%;
	border-collapse: collapse;
}

.lrdbp-table th {
	padding: 10px 18px;
	font-size: .82em;
	font-weight: 600;
	color: var(--lrdbp-muted);
	text-align: left;
	text-transform: uppercase;
	letter-spacing: .04em;
	border-bottom: 1px solid var(--lrdbp-border);
}

.lrdbp-table td {
	padding: 10px 18px;
	border-bottom: 1px solid var(--lrdbp-border);
	vertical-align: middle;
}

.lrdbp-row:hover {
	background: var(--lrdbp-surface);
}

.lrdbp-cell-name {
	display: flex;
	gap: 10px;
	align-items: center;
	min-width: 0;
}

.lrdbp-name-btn {
	padding: 0;
	overflow: hidden;
	font: inherit;
	color: inherit;
	text-align: left;
	text-overflow: ellipsis;
	white-space: nowrap;
	background: none;
	border: 0;
	cursor: pointer;
}

.lrdbp-name-btn:hover {
	color: var(--lrdbp-accent);
	text-decoration: underline;
}

.lrdbp-cell-meta {
	color: var(--lrdbp-muted);
	font-size: .9em;
	white-space: nowrap;
}

.lrdbp-cell-actions {
	text-align: right;
	white-space: nowrap;
}

.lrdbp-cell-actions .lrdbp-btn {
	padding: 5px 10px;
	font-size: .88em;
}

.lrdbp-icon {
	flex: 0 0 auto;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 32px;
	height: 32px;
	color: var(--lrdbp-accent);
	background: var(--lrdbp-surface);
	border-radius: 7px;
	overflow: hidden;
}

.lrdbp-icon img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}

/* Vista griglia */

.lrdbp-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
	gap: 14px;
	padding: 18px;
}

.lrdbp-card {
	display: flex;
	flex-direction: column;
	overflow: hidden;
	background: var(--lrdbp-bg);
	border: 1px solid var(--lrdbp-border);
	border-radius: var(--lrdbp-radius);
}

.lrdbp-card-thumb {
	position: relative;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 100%;
	padding: 0;
	aspect-ratio: 4 / 3;
	color: var(--lrdbp-accent);
	background: var(--lrdbp-surface);
	border: 0;
	cursor: pointer;
}

.lrdbp-card-thumb img {
	width: 100%;
	height: 100%;
	object-fit: cover;
}

.lrdbp-card-thumb svg {
	width: 34px;
	height: 34px;
}

.lrdbp-card-body {
	display: flex;
	flex-direction: column;
	gap: 4px;
	padding: 10px 12px;
}

.lrdbp-card-name {
	overflow: hidden;
	font-size: .92em;
	font-weight: 600;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.lrdbp-card-meta {
	font-size: .82em;
	color: var(--lrdbp-muted);
}

.lrdbp-card-actions {
	display: flex;
	gap: 6px;
	margin-top: 6px;
}

.lrdbp-card-actions .lrdbp-btn {
	flex: 1;
	padding: 5px 8px;
	font-size: .85em;
}

/* ---------- Modale anteprima ---------- */

.lrdbp-modal {
	position: fixed;
	inset: 0;
	z-index: 100000;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 24px;
}

.lrdbp-modal[hidden] {
	display: none;
}

.lrdbp-modal-backdrop {
	position: absolute;
	inset: 0;
	background: rgba(15, 18, 25, .72);
}

.lrdbp-modal-dialog {
	position: relative;
	display: flex;
	flex-direction: column;
	width: min(1100px, 100%);
	height: min(90vh, 100%);
	overflow: hidden;
	background: var(--lrdbp-bg);
	border-radius: var(--lrdbp-radius);
	box-shadow: 0 24px 60px rgba(0, 0, 0, .35);
}

.lrdbp-modal-head {
	display: flex;
	gap: 12px;
	align-items: center;
	padding: 12px 16px;
	border-bottom: 1px solid var(--lrdbp-border);
}

.lrdbp-modal-title {
	flex: 1;
	margin: 0;
	overflow: hidden;
	font-size: 1em;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.lrdbp-modal-tools {
	display: flex;
	gap: 6px;
	align-items: center;
}

.lrdbp-modal-body {
	flex: 1;
	display: flex;
	align-items: center;
	justify-content: center;
	overflow: auto;
	background: #12151c;
}

.lrdbp-modal-body img {
	max-width: 100%;
	max-height: 100%;
	object-fit: contain;
}

.lrdbp-modal-body iframe {
	width: 100%;
	height: 100%;
	border: 0;
	background: #fff;
}

/* ---------- Avvisi ---------- */

.lrdbp-notice {
	padding: 18px;
	color: #334155;
	background: #f8fafc;
	border: 1px solid #e2e8f0;
	border-left: 4px solid var(--lrdbp-accent, #1f2a44);
	border-radius: 8px;
}

.lrdbp-notice p {
	margin: 0;
}

/* ---------- Accessibilita ---------- */

.lrdbp-portal .screen-reader-text {
	position: absolute !important;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	border: 0;
	white-space: nowrap;
}

/* ---------- Responsive ---------- */

@media (max-width: 640px) {
	.lrdbp-table thead {
		display: none;
	}

	.lrdbp-table,
	.lrdbp-table tbody,
	.lrdbp-table tr,
	.lrdbp-table td {
		display: block;
		width: 100%;
	}

	.lrdbp-table tr {
		padding: 8px 0;
		border-bottom: 1px solid var(--lrdbp-border);
	}

	.lrdbp-table td {
		padding: 4px 16px;
		border: 0;
	}

	.lrdbp-cell-actions {
		text-align: left;
	}
}

@media (prefers-color-scheme: dark) {
	.lrdbp-portal.lrdbp-auto-dark {
		--lrdbp-bg: #171a21;
		--lrdbp-surface: #1f232c;
		--lrdbp-border: #2c313c;
		--lrdbp-text: #e6e8ec;
		--lrdbp-muted: #9aa2b1;
	}
}
