/**
 * Allegati.css - Stili per il sistema di gestione allegati
 * Utilizza le variabili CSS del tema
 */

/* ===== SEZIONE ALLEGATI ===== */

.allegati-section {
	width: 100%;
	max-width: 100%;
	padding: 0;
	margin: 0;
	overflow: visible;
	scrollbar-gutter: stable;
}

.allegati-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 8px 12px;
	margin-top: 0;
	margin-bottom: 8px;
	border-bottom: 2px solid var(--colore2, #7E98BF);
	position: sticky;
	top: 0;
	background: white;
	z-index: 100;
	margin-left: 0;
	margin-right: 0;
	box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.allegati-header-left {
	display: flex;
	align-items: center;
	gap: 12px;
}

.allegati-toggle-btn {
	width: 32px;
	height: 32px;
	padding: 0;
	border: none;
	background: var(--colore2, #7E98BF);
	color: white;
	border-radius: 4px;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: all 0.3s ease;
}

.allegati-toggle-btn:hover {
	background: var(--colore3, #7E98BF);
	transform: scale(1.05);
}

.allegati-toggle-btn svg {
	width: 20px;
	height: 20px;
	transition: transform 0.3s ease;
}

.allegati-toggle-btn.collapsed svg {
	transform: rotate(-90deg);
}

/* Pulsanti vista */
.allegati-view-buttons {
	display: flex;
	gap: 4px;
	background: #f0f0f0;
	padding: 2px;
	border-radius: 6px;
}

.allegati-view-btn {
	width: 32px;
	height: 32px;
	padding: 0;
	border: none;
	background: transparent;
	color: #666;
	border-radius: 4px;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: all 0.2s ease;
}

.allegati-view-btn svg {
	width: 18px;
	height: 18px;
}

.allegati-view-btn:hover {
	background: rgba(0, 0, 0, 0.05);
}

.allegati-view-btn.active {
	background: white;
	color: var(--colore2, #7E98BF);
	box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.allegati-title {
	margin: 0;
	font-size: 18px;
	font-weight: 600;
	color: var(--colore1, #7E98BF);
}

.allegati-count {
	font-size: 14px;
	color: #666;
	font-weight: normal;
}

.allegati-header-right {
	display: flex;
	gap: 8px;
}

.allegati-upload-btn {
	display: flex;
	align-items: center;
	gap: 6px;
	padding: 8px 16px;
	border: none;
	background: var(--colore2, #7E98BF);
	color: white;
	border-radius: 6px;
	font-size: 13px;
	font-weight: 600;
	cursor: pointer;
	transition: all 0.2s ease;
}

.allegati-upload-btn:hover {
	background: var(--colore3, #7E98BF);
	transform: translateY(-1px);
}

.allegati-upload-btn svg {
	width: 18px;
	height: 18px;
}

.allegati-grid {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(200px, 240px));
	gap: 8px;
	width: 100%;
	max-width: 100%;
	margin: 0;
	padding: 0;
	transition: all 0.3s ease;
}

@media (min-width: 1920px) {
	.allegati-grid {
		grid-template-columns: repeat(auto-fit, minmax(192px, 230px));
	}
}

@media (max-width: 1200px) {
	.allegati-grid {
		grid-template-columns: repeat(auto-fit, minmax(176px, 211px));
	}
}

@media (max-width: 768px) {
	.allegati-grid {
		grid-template-columns: repeat(auto-fit, minmax(144px, 173px));
		gap: 6px;
	}
}

/* ===== ITEM ALLEGATO ===== */

.allegato-item {
	background: white;
	border: 1px solid #e0e0e0;
	border-radius: 8px;
	overflow: hidden;
	transition: all 0.3s ease;
	display: flex;
	flex-direction: column;
	box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
	height: 100%;
	position: relative;
}

.allegato-item:hover {
	transform: translateY(-4px);
	box-shadow: 0 6px 12px rgba(0, 0, 0, 0.1);
	border-color: var(--colore2, #7E98BF);
}

/* ===== THUMBNAIL ===== */

.allegato-thumbnail {
	width: 100%;
	height: 160px;
	background: #f8f8f8;
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	overflow: hidden;
	position: relative;
	padding: 12px;
	box-sizing: border-box;
}

.allegato-thumbnail img {
	max-width: 100%;
	max-height: 100%;
	width: auto;
	height: auto;
	object-fit: contain;
	transition: all 0.3s ease;
	border: 1px solid #e0e0e0;
	border-radius: 2px;
}

.allegato-thumbnail img.lazy-thumbnail {
	opacity: 0;
	min-height: 120px;
}

.allegato-thumbnail img.loaded-thumbnail {
	opacity: 1;
	animation: fadeIn 0.3s ease-in;
}

@keyframes fadeIn {
	from { opacity: 0; }
	to { opacity: 1; }
}

.allegato-thumbnail:hover img {
	transform: scale(1.08);
	border-color: var(--colore2, #7E98BF);
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.allegato-icon {
	color: var(--colore1, #7E98BF);
	opacity: 0.6;
	transition: all 0.3s ease;
	width: 48px;
	height: 48px;
	display: flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
}

.allegato-icon svg {
	width: 100%;
	height: 100%;
	display: block;
}

.allegato-thumbnail:hover .allegato-icon {
	opacity: 0.8;
	transform: scale(1.1);
}

/* Icone per tipo di file */
.allegato-icon-pdf { color: #D32F2F; }
.allegato-icon-video { color: #7B1FA2; }
.allegato-icon-audio { color: #F57C00; }
.allegato-icon-text { color: #455A64; }
.allegato-icon-document { color: #1976D2; }
.allegato-icon-archive { color: #5D4037; }
.allegato-icon-other { color: #616161; }
.allegato-icon-broken { color: #F44336; }
.allegato-icon-image { color: #43A047; }

/* ===== INFO ALLEGATO ===== */

.allegato-info {
	padding: 12px;
	flex: 1;
	display: flex;
	flex-direction: column;
	gap: 6px;
}

/* Footer con meta e actions affiancati */
.allegato-info > .allegato-meta,
.allegato-info > .allegato-actions {
	margin-top: auto;
}

.allegato-info > .allegato-meta {
	width: auto;
	flex: 1;
	margin-bottom: 0;
}

.allegato-info > .allegato-actions {
	position: absolute;
	bottom: 12px;
	right: 12px;
}

.allegato-filename {
	font-size: 11px;
	font-weight: 600;
	color: var(--colore1, #7E98BF);
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	line-height: 1.4;
	cursor: pointer;
	transition: color 0.2s ease;
}

.allegato-filename:hover {
	color: var(--colore2, #7E98BF);
}

.allegato-descrizione {
	font-size: 11px;
	color: #666;
	overflow: hidden;
	text-overflow: ellipsis;
	display: -webkit-box;
	-webkit-line-clamp: 2;
	line-clamp: 2;
	-webkit-box-orient: vertical;
	line-height: 1.4;
}

.allegato-meta {
	font-size: 11px;
	color: #999;
	display: flex;
	align-items: center;
	gap: 8px;
	min-height: 24px;
}

.allegato-size,
.allegato-date {
	white-space: nowrap;
	line-height: 1.3;
}

/* ===== AZIONI ALLEGATO ===== */

.allegato-actions {
	display: flex;
	flex-direction: row;
	gap: 4px;
	flex-shrink: 0;
	align-items: center;
}

.allegato-btn {
	width: 24px;
	height: 24px;
	padding: 0;
	border: none;
	background: transparent;
	color: #333;
	border-radius: 4px;
	cursor: pointer;
	transition: all 0.2s ease;
	display: flex;
	align-items: center;
	justify-content: center;
	text-decoration: none;
	opacity: 0.7;
}

.allegato-btn svg {
	width: 16px;
	height: 16px;
	stroke: currentColor;
	display: block;
}

.allegato-btn:hover {
	opacity: 1;
}

.allegato-btn-delete {
	color: #d32f2f;
}

.allegato-btn-delete:hover {
	opacity: 1;
}

/* Spinner per la cancellazione */
.allegato-btn-delete.deleting svg {
	display: none;
}

.allegato-btn-delete.deleting::after {
	content: '';
	display: block;
	width: 14px;
	height: 14px;
	border: 2px solid #d32f2f;
	border-top-color: transparent;
	border-radius: 50%;
	animation: allegato-spinner 0.6s linear infinite;
}

@keyframes allegato-spinner {
	0% { transform: rotate(0deg); }
	100% { transform: rotate(360deg); }
}

/* ===== MODAL ===== */

.allegati-modal {
	position: fixed;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	z-index: 10000;
	visibility: hidden;
	opacity: 0;
	align-items: center;
	justify-content: center;
	background: rgba(0, 0, 0, 0);
	transition: background 0.3s ease, opacity 0.3s ease;
}

.allegati-modal.allegati-modal-open {
	visibility: visible;
	opacity: 1;
	background: rgba(0, 0, 0, 0.9);
}

.allegati-modal-overlay {
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	z-index: 1;
}

.allegati-modal-container {
	position: relative;
	width: 90%;
	height: 90%;
	max-width: 1400px;
	max-height: 900px;
	z-index: 2;
	display: flex;
	flex-direction: column;
	background: white;
	border-radius: 12px;
	overflow: hidden;
	transform: scale(0.9);
	opacity: 0;
	transition: all 0.3s ease;
}

.allegati-modal-open .allegati-modal-container {
	transform: scale(1);
	opacity: 1;
}

/* ===== CONTROLLI MODAL ===== */

.allegati-modal-close {
	position: fixed;
	top: 10px;
	right: 10px;
	width: 32px;
	height: 32px;
	border: none;
	background: rgba(0, 0, 0, 0.5);
	color: white;
	border-radius: 50%;
	cursor: pointer;
	z-index: 10001;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: all 0.2s ease;
}

.allegati-modal-close:hover {
	background: var(--colore1, #7E98BF);
	transform: rotate(90deg);
}

/* Pulsanti zoom */
.allegati-modal-zoom {
	position: fixed;
	right: 10px;
	width: 32px;
	height: 32px;
	border: none;
	background: rgba(0, 0, 0, 0.5);
	color: white;
	border-radius: 50%;
	cursor: pointer;
	z-index: 10001;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: all 0.2s ease;
}

.allegati-modal-zoom:hover {
	background: var(--colore2, #7E98BF);
	transform: scale(1.1);
}

.allegati-modal-zoom-in {
	top: 94px;
}

.allegati-modal-zoom-out {
	top: 136px;
}

/* Indicatore livello zoom */
.allegati-zoom-indicator {
	position: fixed;
	top: 178px;
	right: 10px;
	background: rgba(0, 0, 0, 0.7);
	color: white;
	padding: 6px 10px;
	border-radius: 4px;
	font-size: 12px;
	font-weight: 600;
	z-index: 10001;
	opacity: 0;
	transition: opacity 0.3s ease;
	pointer-events: none;
}

.allegati-zoom-indicator.visible {
	opacity: 1;
}

.allegati-modal-nav {
	position: fixed;
	top: 50%;
	transform: translateY(-50%);
	width: 32px;
	height: 32px;
	border: none;
	background: rgba(0, 0, 0, 0.5);
	color: white;
	border-radius: 50%;
	cursor: pointer;
	z-index: 10001;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: all 0.2s ease;
}

.allegati-modal-nav:hover {
	background: var(--colore2, #7E98BF);
	transform: translateY(-50%) scale(1.1);
}

.allegati-modal-prev {
	left: 20px;
}

.allegati-modal-next {
	right: 10px;
}

/* ===== CONTENUTO MODAL ===== */

.allegati-modal-content {
	flex: 1;
	display: flex;
	align-items: center;
	justify-content: center;
	overflow: hidden;
	background: #f5f5f5;
	position: relative;
}

.allegati-modal-loading {
	text-align: center;
	color: #999;
	font-size: 18px;
	padding: 40px;
}

/* Contenitore immagine */
.allegati-modal-image-container {
	width: 100%;
	height: 100%;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 20px;
	opacity: 0;
	transition: opacity 0.3s ease;
}

.allegati-modal-image-container.loaded {
	opacity: 1;
}

/* Canvas wrapper per panning */
.allegati-image-canvas-wrapper {
	position: relative;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 100%;
	height: 100%;
	overflow: hidden;
}

.allegati-modal-image {
	max-width: 100%;
	max-height: 100%;
	object-fit: contain;
	border-radius: 4px;
	box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

/* Contenitore PDF */
.allegati-modal-pdf-container {
	width: 100%;
	height: 100%;
	padding: 20px;
}

.allegati-modal-iframe {
	width: 100%;
	height: 100%;
	border: none;
	border-radius: 4px;
	background: white;
}

/* Contenitore video */
.allegati-modal-video-container {
	width: 100%;
	height: 100%;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 20px;
}

.allegati-modal-video {
	max-width: 100%;
	max-height: 100%;
	border-radius: 4px;
	box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

/* Contenitore audio */
.allegati-modal-audio-container {
	width: 100%;
	height: 100%;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	padding: 40px;
	gap: 30px;
}

.allegati-modal-audio-info {
	text-align: center;
	color: var(--colore1, #7E98BF);
	font-size: 48px;
}

/* Removed SVG rule */

.allegati-modal-audio-info p {
	font-size: 18px;
	font-weight: 600;
	margin: 0;
}

.allegati-modal-audio {
	width: 100%;
	max-width: 500px;
	border-radius: 50px;
}

/* Contenitore testo */
.allegati-modal-text-container {
	width: 100%;
	height: 100%;
	overflow: auto;
	padding: 20px;
}

.allegati-modal-text {
	background: white;
	padding: 20px;
	border-radius: 4px;
	font-family: 'Courier New', monospace !important;
	font-size: 13px;
	line-height: 1.6;
	color: #333;
	white-space: pre-wrap;
	word-wrap: break-word;
	margin: 0;
}

/* Contenitore generico */
.allegati-modal-generic-container {
	text-align: center;
	padding: 60px 40px;
	color: var(--colore1, #7E98BF);
}

.allegati-modal-generic-icon {
	margin-bottom: 30px;
	opacity: 0.4;
}

.allegati-modal-generic-filename {
	font-size: 20px;
	font-weight: 600;
	margin: 0 0 10px 0;
	word-wrap: break-word;
}

.allegati-modal-generic-message {
	font-size: 14px;
	color: #666;
	margin: 0 0 30px 0;
}

.allegati-modal-download-btn {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	padding: 12px 24px;
	background: var(--colore2, #7E98BF);
	color: white;
	text-decoration: none;
	border-radius: 6px;
	font-weight: 600;
	transition: all 0.2s ease;
}

.allegati-modal-download-btn:hover {
	background: var(--colore3, #7E98BF);
	transform: translateY(-2px);
	box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.allegati-modal-error {
	text-align: center;
	padding: 40px;
	color: #999;
}

/* ===== FOOTER MODAL ===== */

.allegati-modal-footer {
	background: white;
	border-top: 1px solid #e0e0e0;
	padding: 15px 20px;
	display: flex;
	flex-direction: column;
	gap: 12px;
}

.allegati-modal-info {
	flex: 1;
	min-width: 0;
	display: flex;
	flex-direction: column;
	gap: 4px;
}

.allegati-modal-filename {
	font-size: 14px;
	font-weight: 600;
	color: var(--colore1, #7E98BF);
	display: block;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.allegati-modal-details {
	font-size: 12px;
	color: #666;
	display: flex;
	gap: 12px;
	flex-wrap: wrap;
}

.allegati-modal-details span {
	display: inline-flex;
	align-items: center;
	gap: 4px;
}

.allegati-modal-counter {
	font-size: 12px;
	color: #999;
	position: fixed;
	bottom: 20px;
	right: 20px;
	background: rgba(0, 0, 0, 0.6);
	color: white;
	padding: 6px 12px;
	border-radius: 4px;
	z-index: 10001;
	font-weight: 600;
}

.allegati-modal-actions {
	display: flex;
	gap: 8px;
	flex-wrap: wrap;
}

.allegati-modal-action-btn {
	display: flex;
	align-items: center;
	gap: 6px;
	padding: 8px 16px;
	background: var(--colore5, #7E98BF);
	color: white;
	text-decoration: none;
	border: none;
	border-radius: 6px;
	font-size: 13px;
	font-weight: 600;
	transition: all 0.2s ease;
	white-space: nowrap;
	cursor: pointer;
}

.allegati-modal-action-btn:hover {
	background: var(--colore4, #7E98BF);
	transform: translateY(-1px);
}

.allegati-modal-action-btn.btn-delete {
	background: #D32F2F;
}

.allegati-modal-action-btn.btn-delete:hover {
	background: #B71C1C;
}

/* ===== RESPONSIVE ===== */

@media (max-width: 768px) {
	.allegati-modal-container {
		width: 100%;
		height: 100%;
		max-width: 100%;
		max-height: 100%;
		border-radius: 0;
	}
	
	.allegati-modal-nav {
		width: 40px;
		height: 40px;
	}
	
	.allegati-modal-prev {
		left: 10px;
	}
	
	.allegati-modal-next {
		right: 10px;
	}
	
	.allegati-modal-close {
		top: 10px;
		left: 10px;
		width: 32px;
		height: 32px;
	}
	
	.allegati-modal-footer {
		flex-direction: column;
		align-items: stretch;
		gap: 10px;
	}
	
	.allegati-modal-info {
		text-align: center;
	}
	
	.allegati-modal-actions {
		justify-content: center;
	}
}

/* ===== VISTA LISTA ===== */

.allegati-grid.allegati-list-view {
	display: grid;
	grid-template-columns: repeat(3, 1fr);
	gap: 4px;
}

.allegati-list-view .allegato-item {
	display: grid;
	grid-template-columns: 28px 1fr auto;
	grid-template-rows: 14px 14px;
	column-gap: 8px;
	row-gap: 3px;
	border-radius: 4px;
	height: 35px;
	padding: 4px 8px;
	align-items: center;
}

.allegati-list-view .allegato-item:hover {
	transform: translateX(4px);
}

.allegati-list-view .allegato-thumbnail {
	grid-column: 1;
	grid-row: 1 / 3;
	width: 24px;
	min-width: 24px;
	height: 24px;
	padding: 2px;
	flex-shrink: 0;
	margin: 0;
	align-self: center;
}

.allegati-list-view .allegato-thumbnail img {
	border: none;
	border-radius: 2px;
}

.allegati-list-view .allegato-icon {
	width: 16px;
	height: 16px;
}

.allegati-list-view .allegato-info {
	grid-column: 2;
	grid-row: 1 / 3;
	display: grid;
	grid-template-columns: 1fr;
	grid-template-rows: 14px 14px;
	gap: 0;
	padding: 0;
	min-width: 0;
	align-self: center;
}

.allegati-list-view .allegato-filename {
	grid-row: 1;
	font-size: 12px;
	font-weight: 600;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	line-height: 14px;
	align-self: center;
}

.allegati-list-view .allegato-descrizione {
	grid-row: 2;
	font-size: 10px;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	color: #999;
	line-height: 14px;
	align-self: center;
}

.allegati-list-view .allegato-meta {
	grid-column: 3;
	grid-row: 1;
	display: flex;
	flex-direction: row;
	align-items: center;
	justify-content: flex-end;
	gap: 6px;
	margin: 0;
	padding: 0;
	font-size: 10px;
	color: #666;
	white-space: nowrap;
	line-height: 14px;
	align-self: center;
}

.allegati-list-view .allegato-actions {
	grid-column: 3;
	grid-row: 2;
	display: flex;
	justify-content: flex-end;
	align-items: center;
	gap: 4px;
	padding: 0;
	margin: 0;
	align-self: center;
	position: static;
	bottom: auto;
	right: auto;
}

/* Media query per vista lista su mobile */
@media (max-width: 768px) {
	.allegati-grid.allegati-list-view {
		grid-template-columns: 1fr;
	}
	
	.allegati-list-view .allegato-info {
		flex-direction: column;
		align-items: flex-start;
		gap: 4px;
	}
	
	.allegati-list-view .allegato-filename {
		max-width: 100%;
	}
	
	.allegati-list-view .allegato-meta {
		width: 100%;
		flex-direction: column;
		align-items: flex-start;
		gap: 4px;
	}
	
	.allegati-list-view .allegato-meta-info {
		flex-direction: column;
		gap: 4px;
		align-items: flex-start;
	}
}

/* ===== ANIMAZIONI ===== */

@keyframes fadeIn {
	from {
		opacity: 0;
	}
	to {
		opacity: 1;
	}
}

@keyframes slideUp {
	from {
		transform: translateY(20px);
		opacity: 0;
	}
	to {
		transform: translateY(0);
		opacity: 1;
	}
}

.allegato-item {
	animation: slideUp 0.3s ease forwards;
}

.allegato-item:nth-child(1) { animation-delay: 0.05s; }
.allegato-item:nth-child(2) { animation-delay: 0.1s; }
.allegato-item:nth-child(3) { animation-delay: 0.15s; }
.allegato-item:nth-child(4) { animation-delay: 0.2s; }
.allegato-item:nth-child(5) { animation-delay: 0.25s; }
.allegato-item:nth-child(6) { animation-delay: 0.3s; }

/* ========== MODAL UPLOAD ========== */

.allegati-upload-modal {
	display: none;
	position: fixed;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	z-index: 10000;
	align-items: center;
	justify-content: center;
	opacity: 0;
	transition: opacity 0.3s ease;
}

.allegati-upload-modal.open {
	opacity: 1;
}

.allegati-upload-overlay {
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	background: rgba(0, 0, 0, 0.7);
}

.allegati-upload-container {
	position: relative;
	background: white;
	border-radius: 12px;
	width: 90%;
	max-width: 600px;
	max-height: 90vh;
	display: flex;
	flex-direction: column;
	box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

.allegati-upload-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 20px 24px;
	border-bottom: 1px solid #e0e0e0;
}

.allegati-upload-header h3 {
	margin: 0;
	font-size: 20px;
	font-weight: 600;
}

.allegati-upload-close {
	background: transparent;
	border: none;
	cursor: pointer;
	padding: 4px;
	display: flex;
	align-items: center;
	justify-content: center;
	border-radius: 4px;
	transition: background-color 0.2s;
}

.allegati-upload-close:hover {
	background: #f5f5f5;
}

.allegati-upload-body {
	padding: 24px;
	overflow-y: auto;
	flex: 1;
}

.allegati-upload-field {
	margin-bottom: 20px;
}

.allegati-upload-field label {
	display: block;
	font-weight: 600;
	margin-bottom: 8px;
	color: #333;
}

.allegati-upload-field textarea,
.allegati-upload-field select {
	width: 100%;
	padding: 10px;
	border: 1px solid #ddd;
	border-radius: 6px;
	font-size: 14px;
	font-family: inherit;
	transition: border-color 0.2s;
}

.allegati-upload-field textarea:focus,
.allegati-upload-field select:focus {
	outline: none;
	border-color: var(--colore2, #0066cc);
}

/* Dropzone */
.allegati-upload-dropzone {
	border: 2px dashed #ddd;
	border-radius: 8px;
	padding: 40px 20px;
	text-align: center;
	cursor: pointer;
	transition: all 0.2s;
	background: #fafafa;
}

.allegati-upload-dropzone:hover {
	border-color: var(--colore2, #0066cc);
	background: #f0f7ff;
}

.allegati-upload-dropzone.dragover {
	border-color: var(--colore2, #0066cc);
	background: #e3f2fd;
}

.allegati-dropzone-content svg {
	color: #999;
	margin-bottom: 12px;
}

.allegati-dropzone-content p {
	margin: 0;
	color: #666;
	font-size: 14px;
}

.allegati-browse-link {
	color: var(--colore2, #0066cc);
	text-decoration: underline;
	cursor: pointer;
}

.allegati-browse-link:hover {
	text-decoration: none;
}

/* Lista file selezionati */
.allegati-files-list {
	margin-bottom: 20px;
}

.allegati-files-header {
	font-weight: 600;
	margin-bottom: 10px;
	color: #333;
}

.allegati-file-item {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 10px;
	background: #f5f5f5;
	border-radius: 6px;
	margin-bottom: 8px;
}

.allegati-file-info {
	display: flex;
	flex-direction: column;
	flex: 1;
	min-width: 0;
}

.allegati-file-name {
	font-size: 14px;
	color: #333;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.allegati-file-size {
	font-size: 12px;
	color: #666;
	margin-top: 2px;
}

.allegati-file-remove {
	background: transparent;
	border: none;
	cursor: pointer;
	padding: 4px;
	display: flex;
	align-items: center;
	justify-content: center;
	border-radius: 4px;
	margin-left: 8px;
	transition: background-color 0.2s;
}

.allegati-file-remove:hover {
	background: #e0e0e0;
}

.allegati-file-remove svg {
	color: #666;
}

/* Info e Warning */
.allegati-upload-info {
	padding: 12px;
	background: #e3f2fd;
	border-left: 4px solid var(--colore2, #0066cc);
	border-radius: 4px;
	font-size: 14px;
	margin-bottom: 12px;
}

.allegati-upload-warning {
	padding: 12px;
	background: #fff3e0;
	border-left: 4px solid #ff9800;
	border-radius: 4px;
	font-size: 14px;
	margin-bottom: 12px;
	display: none;
}

.allegati-upload-limits {
	padding: 8px 12px;
	background: #f5f5f5;
	border-radius: 4px;
	margin-top: 16px;
	text-align: center;
}

.allegati-upload-limits small {
	font-size: 12px;
	color: #666;
}

.allegati-upload-limits span {
	font-weight: 600;
	color: #333;
}

/* Footer */
.allegati-upload-footer {
	display: flex;
	align-items: center;
	justify-content: flex-end;
	gap: 12px;
	padding: 16px 24px;
	border-top: 1px solid #e0e0e0;
}

.allegati-upload-btn-cancel,
.allegati-upload-btn-submit {
	padding: 10px 20px;
	border: none;
	border-radius: 6px;
	font-size: 14px;
	font-weight: 600;
	cursor: pointer;
	transition: all 0.2s;
}

.allegati-upload-btn-cancel {
	background: white;
	color: #666;
	border: 1px solid #ddd;
}

.allegati-upload-btn-cancel:hover {
	background: #f5f5f5;
}

.allegati-upload-btn-submit {
	background: var(--colore2, #0066cc);
	color: white;
}

.allegati-upload-btn-submit:hover:not(:disabled) {
	background: var(--colore3, #0052a3);
}

.allegati-upload-btn-submit:disabled {
	background: #ccc;
	cursor: not-allowed;
	opacity: 0.6;
}

/* ===== EDITOR IMMAGINI ===== */

/* Toggle button per editor */
.allegati-editor-toggle {
	position: fixed;
	top: 52px;
	right: 10px;
	width: 32px;
	height: 32px;
	background: rgba(0, 0, 0, 0.5);
	border: none;
	color: white;
	cursor: pointer;
	transition: all 0.2s ease;
	z-index: 10001;
	display: none;
	align-items: center;
	justify-content: center;
	border-radius: 50%;
}

.allegati-editor-toggle.active {
	display: flex;
}

.allegati-editor-toggle:hover {
	background: var(--colore1, #04475F);
}

.allegati-editor-toggle svg {
	width: 18px;
	height: 18px;
	stroke: white;
}

/* Container per tutte le toolbar */
.allegati-editor-toolbars-container {
	display: none;
	flex-direction: row;
	align-items: flex-start;
	justify-content: center;
	flex-wrap: wrap;
	gap: 8px;
	margin: 12px auto 10px;
	width: auto;
	max-width: 100%;
	position: relative;
	z-index: 10;
}

.allegati-image-editor-toolbar.visible ~ .allegati-editor-toolbars-container,
.allegati-editor-toolbars-container:has(.allegati-image-editor-toolbar.visible) {
	display: flex;
}

/* Toolbar editor */
.allegati-image-editor-toolbar {
	display: none;
	align-items: center;
	justify-content: center;
	flex-wrap: nowrap;
	gap: 6px;
	padding: 10px 16px;
	background: rgba(0, 0, 0, 0.8);
	border-radius: 8px;
	width: auto;
	position: relative;
	flex-shrink: 0;
}

.allegati-image-editor-toolbar.visible {
	display: flex;
}

.allegati-image-editor-btn {
	display: flex;
	align-items: center;
	gap: 6px;
	padding: 8px 12px;
	background: rgba(255, 255, 255, 0.1);
	color: white;
	border: 1px solid rgba(255, 255, 255, 0.2);
	border-radius: 6px;
	font-size: 13px;
	font-weight: 600;
	cursor: pointer;
	transition: all 0.2s ease;
	white-space: nowrap;
}

.allegati-image-editor-btn:hover {
	background: rgba(255, 255, 255, 0.2);
	border-color: rgba(255, 255, 255, 0.4);
	transform: translateY(-1px);
}

.allegati-image-editor-btn.active {
	background: var(--colore2, #94C11F);
	border-color: var(--colore2, #94C11F);
}

.allegati-image-editor-btn svg {
	width: 18px;
	height: 18px;
}

/* Separator */
.allegati-editor-separator {
	width: 1px;
	height: 24px;
	background: rgba(255, 255, 255, 0.3);
}

/* Canvas container */
.allegati-modal-image-container {
	position: relative;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: flex-start;
	width: 100%;
	height: 100%;
	padding: 20px 20px 10px 20px;
	overflow-y: auto;
	overflow-x: hidden;
	gap: 0;
}

.allegati-image-canvas-wrapper {
	position: relative;
	display: flex;
	align-items: center;
	justify-content: center;
	max-width: 100%;
	width: 100%;
	flex: 1;
	min-height: 0;
}

.allegati-image-canvas {
	display: none;
	max-width: 100%;
	max-height: 100%;
	cursor: crosshair;
}

.allegati-image-canvas.active {
	display: block;
}

.allegati-modal-image {
	max-width: 100%;
	max-height: calc(100vh - 300px);
	object-fit: contain;
	display: block;
}

.allegati-modal-image.editing {
	display: none;
}

/* Crop overlay */
.allegati-crop-overlay {
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	background: rgba(0, 0, 0, 0.5);
	display: none;
	cursor: crosshair;
}

.allegati-crop-overlay.active {
	display: block;
}

.allegati-crop-selection {
	position: absolute;
	border: 2px dashed var(--colore2, #94C11F);
	background: rgba(148, 193, 31, 0.1);
	pointer-events: none;
}

/* Container per toolbar + controlli aggiuntivi */
.allegati-editor-controls-wrapper {
	display: flex;
	flex-direction: row;
	align-items: center;
	justify-content: center;
	gap: 8px;
	flex-shrink: 0;
	flex-wrap: wrap;
}

/* Controlli crop */
.allegati-crop-controls {
	display: none;
	align-items: center;
	justify-content: center;
	gap: 12px;
	padding: 10px 16px;
	background: rgba(0, 0, 0, 0.8);
	border-radius: 8px;
	flex-shrink: 0;
}

.allegati-crop-controls.active {
	display: flex;
}

.allegati-crop-btn {
	padding: 8px 16px;
	border: none;
	border-radius: 6px;
	font-size: 13px;
	font-weight: 600;
	cursor: pointer;
	transition: all 0.2s ease;
}

.allegati-crop-btn-apply {
	background: var(--colore2, #94C11F);
	color: white;
}

.allegati-crop-btn-apply:hover {
	background: var(--colore3, #62914F);
}

.allegati-crop-btn-cancel {
	background: #666;
	color: white;
}

.allegati-crop-btn-cancel:hover {
	background: #444;
}

/* Controlli colore e dimensione */
.allegati-drawing-controls {
	display: none;
	align-items: center;
	justify-content: center;
	flex-wrap: nowrap;
	gap: 12px;
	padding: 10px 16px;
	background: rgba(0, 0, 0, 0.8);
	border-radius: 8px;
	flex-shrink: 0;
}

.allegati-drawing-controls.active {
	display: flex;
}

.allegati-drawing-control-group {
	display: flex;
	align-items: center;
	gap: 8px;
}

.allegati-drawing-control-label {
	color: white;
	font-size: 13px;
	font-weight: 600;
	white-space: nowrap;
}

.allegati-drawing-color {
	width: 40px;
	height: 32px;
	border: 2px solid white;
	border-radius: 4px;
	cursor: pointer;
	padding: 0;
}

.allegati-drawing-size {
	width: 100px;
	height: 32px;
	padding: 0 8px;
	border: 1px solid rgba(255, 255, 255, 0.3);
	border-radius: 4px;
	background: rgba(255, 255, 255, 0.1);
	color: white;
	font-size: 13px;
	cursor: pointer;
}

/* Controlli testo */
.allegati-text-controls {
	display: none;
	align-items: center;
	justify-content: center;
	flex-wrap: nowrap;
	gap: 12px;
	padding: 10px 16px;
	background: rgba(0, 0, 0, 0.8);
	border-radius: 8px;
	flex-shrink: 0;
}

.allegati-text-controls.active {
	display: flex;
}

.allegati-text-input {
	padding: 8px 12px;
	border: 1px solid rgba(255, 255, 255, 0.3);
	border-radius: 4px;
	background: rgba(255, 255, 255, 0.15);
	color: white;
	font-size: 13px;
	min-width: 200px;
}

.allegati-text-input:focus {
	outline: none;
	border-color: rgba(255, 255, 255, 0.5);
	background: rgba(255, 255, 255, 0.2);
	color: white;
}

.allegati-text-input::placeholder {
	color: rgba(255, 255, 255, 0.6);
}

.allegati-text-size {
	width: 80px;
	padding: 8px;
	border: 1px solid rgba(255, 255, 255, 0.3);
	border-radius: 4px;
	background: rgba(255, 255, 255, 0.15);
	color: white;
	font-size: 13px;
}

.allegati-text-size:focus {
	outline: none;
	border-color: rgba(255, 255, 255, 0.5);
	background: rgba(255, 255, 255, 0.2);
	color: white;
}

/* Stato di salvataggio */
.allegati-save-status {
	display: none;
	align-items: center;
	gap: 8px;
	padding: 8px 16px;
	background: rgba(0, 0, 0, 0.8);
	border-radius: 6px;
	color: white;
	font-size: 13px;
	font-weight: 600;
	position: fixed;
	bottom: 80px;
	right: 20px;
	z-index: 10002;
}

.allegati-save-status.active {
	display: flex;
}

.allegati-save-status.success {
	background: var(--colore2, #94C11F);
}

.allegati-save-status.error {
	background: #D32F2F;
}

.allegati-save-spinner {
	width: 16px;
	height: 16px;
	border: 2px solid rgba(255, 255, 255, 0.3);
	border-top-color: white;
	border-radius: 50%;
	animation: spin 0.8s linear infinite;
}

@keyframes spin {
	to { transform: rotate(360deg); }
}

/* ===== RAGGRUPPAMENTO PER IMPRESA ===== */

.allegati-impresa-group {
	margin-bottom: 24px;
	border: 1px solid #e0e0e0;
	border-radius: 8px;
	padding: 16px;
	background: #fafafa;
}

.allegati-impresa-title {
	margin: 0 0 16px 0;
	padding: 0 0 12px 0;
	font-size: 16px;
	font-weight: 600;
	color: var(--colore1, #005a9c);
	border-bottom: 2px solid var(--colore2, #94C11F);
	display: flex;
	align-items: center;
	gap: 8px;
	position: relative;
}

.allegati-impresa-name {
	flex: 0 0 auto;
}

.allegati-impresa-count {
	flex: 0 0 auto;
	font-size: 14px;
	font-weight: 400;
	color: #666;
}

.allegati-impresa-next {
	margin-left: auto;
	width: 28px;
	height: 28px;
	padding: 0;
	border: none;
	background: var(--colore2, #94C11F);
	color: white;
	border-radius: 50%;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: all 0.2s ease;
	flex-shrink: 0;
}

.allegati-impresa-next:hover {
	background: var(--colore3, #62914F);
	transform: scale(1.1);
}

.allegati-impresa-next svg {
	width: 16px;
	height: 16px;
}

.allegati-impresa-items {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
	gap: 16px;
}

/* Vista lista per items raggruppati */
.allegati-list-view .allegati-impresa-items {
	grid-template-columns: 1fr;
}

/* Meta informazioni con nome impresa */
.allegato-impresa {
	display: inline-block;
	padding: 2px 8px;
	background: var(--colore2, #94C11F);
	color: white;
	border-radius: 4px;
	font-size: 11px;
	font-weight: 500;
	margin-left: 4px;
}

/* Responsive per raggruppamento */
@media (max-width: 1200px) {
	.allegati-impresa-items {
		grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
	}
}

@media (max-width: 768px) {
	.allegati-impresa-items {
		grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
	}
	
	.allegati-impresa-title {
		font-size: 14px;
	}
}

@media (max-width: 480px) {
	.allegati-impresa-items {
		grid-template-columns: 1fr;
	}
}
