/* Gallery controls */
.gallery-controls {
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 12px 16px;
  background: #f8fafc;
}

.gallery-count {
  font-size: 14px;
  font-weight: 500;
}

.view-all-btn, .delete-all-btn {
  font-size: 13px;
  padding: 4px 8px;
}

.delete-all-btn {
  margin-left: 8px;
}

/* Gallery grid in modal */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 16px;
  padding: 16px 0;
}

.gallery-item {
  text-align: center;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 12px;
  background: #fff;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.gallery-item:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.gallery-item img {
  width: 100%;
  height: 100px;
  object-fit: cover;
  border-radius: 4px;
  margin-bottom: 8px;
  transition: transform 0.2s ease;
}

.gallery-item img:hover {
  transform: scale(1.05);
}

.file-icon {
  height: 100px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f3f4f6;
  border-radius: 4px;
  margin-bottom: 8px;
}

.file-icon i {
  font-size: 2em;
  color: #6b7280;
}

.gallery-item-name {
  font-size: 12px;
  color: #374151;
  margin-bottom: 8px;
  word-break: break-word;
  line-height: 1.3;
}

.gallery-item-actions {
  display: flex;
  gap: 4px;
  justify-content: center;
}

/* Uppy Dashboard Enhancements */
.uppy-Dashboard {
  font-family: inherit;
  border-radius: 8px;
  border: 2px dashed #d1d5db;
  transition: all 0.3s ease;
}

.uppy-Dashboard.uppy-Dashboard--isDragOver {
  border-color: #3b82f6;
  background-color: #eff6ff;
}

/* Smooth transitions for Uppy Dashboard states */
.uppy-Dashboard-inner {
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Add smooth animations for file additions/removals */
.uppy-Dashboard-Item {
  transition: all 0.3s ease;
  opacity: 1;
  transform: scale(1);
}

.uppy-Dashboard-Item--willRemove {
  opacity: 0;
  transform: scale(0.8);
}

/* Smooth dropdown animation for "Add more files" */
.uppy-Dashboard-AddFiles {
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  transform-origin: top;
}

.uppy-Dashboard-AddFiles[aria-hidden="true"] {
  transform: scaleY(0);
  opacity: 0;
  max-height: 0;
  overflow: hidden;
}

.uppy-Dashboard-AddFiles[aria-hidden="false"] {
  transform: scaleY(1);
  opacity: 1;
  max-height: 1000px;
}

/* Smooth back button animation */
.uppy-Dashboard-back {
  transition: all 0.3s ease;
}

.uppy-Dashboard-back:hover {
  transform: translateX(-2px);
}

/* Enhanced file item preview animations */
.uppy-Dashboard-Item-preview {
  transition: transform 0.2s ease;
  cursor: pointer;
}

.uppy-Dashboard-Item-preview:hover {
  transform: scale(1.02);
}

/* Clickable preview styling */
.uppy-Dashboard-Item.editable .uppy-Dashboard-Item-preview img {
  cursor: pointer;
  transition: all 0.2s ease;
}

.uppy-Dashboard-Item.editable .uppy-Dashboard-Item-preview img:hover {
  transform: scale(1.05);
  filter: brightness(1.1);
}

/* Clickable title styling */
.uppy-Dashboard-Item-name[data-clickable="true"] {
  cursor: pointer !important;
  text-decoration: underline !important;
  color: #3b82f6 !important;
  transition: color 0.2s ease;
}

.uppy-Dashboard-Item-name[data-clickable="true"]:hover {
  color: #1d4ed8 !important;
}

/* Progress bar enhancements */
.uppy-Dashboard-Item-progress {
  transition: all 0.3s ease;
}

/* Status badge improvements */
.uppy-Dashboard-Item-status {
  transition: all 0.2s ease;
}

/* Advanced Lightbox */
.lightbox {
  display: none;
  position: fixed;
  z-index: 2000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  animation: lightboxFadeIn 0.3s ease;
}

@keyframes lightboxFadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.lightbox-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.9);
  cursor: pointer;
  transition: background-color 0.3s ease;
}

.lightbox-container {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lightbox-content-wrapper {
  position: relative;
  max-width: 90%;
  max-height: 85%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lightbox-content {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  transition: all 0.3s ease;
  transform: scale(1);
}

.lightbox-content.loading {
  opacity: 0;
  transform: scale(0.9);
}

.lightbox-loader {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: none;
  align-items: center;
  justify-content: center;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid rgba(255, 255, 255, 0.2);
  border-top: 4px solid #fff;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.lightbox-close {
  position: absolute;
  top: 20px;
  right: 20px;
  width: 48px;
  height: 48px;
  background: rgba(0, 0, 0, 0.7);
  border: none;
  border-radius: 50%;
  color: white;
  font-size: 24px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  z-index: 2001;
  backdrop-filter: blur(10px);
}

.lightbox-close:hover {
  background: rgba(0, 0, 0, 0.9);
  transform: scale(1.1);
}

.lightbox-prev,
.lightbox-next {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 60px;
  height: 60px;
  background: rgba(0, 0, 0, 0.7);
  border: none;
  border-radius: 50%;
  color: white;
  font-size: 28px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  z-index: 2001;
  backdrop-filter: blur(10px);
}

.lightbox-prev { left: 30px; }
.lightbox-next { right: 30px; }

.lightbox-prev:hover,
.lightbox-next:hover {
  background: rgba(0, 0, 0, 0.9);
  transform: translateY(-50%) scale(1.1);
}

.lightbox-prev:active,
.lightbox-next:active {
  transform: translateY(-50%) scale(0.95);
}

.lightbox-info {
  position: absolute;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
  color: white;
  max-width: 80%;
}

.lightbox-title {
  background: rgba(0, 0, 0, 0.8);
  padding: 12px 20px;
  border-radius: 25px;
  font-size: 16px;
  font-weight: 500;
  margin-bottom: 8px;
  word-break: break-word;
  backdrop-filter: blur(10px);
  transition: all 0.2s ease;
}

.lightbox-counter {
  background: rgba(0, 0, 0, 0.6);
  padding: 6px 12px;
  border-radius: 15px;
  font-size: 14px;
  backdrop-filter: blur(10px);
  transition: all 0.2s ease;
}

/* File action buttons in uppy */
.edit-file-btn, 
.view-file-btn {
  margin-left: 4px;
  font-size: 12px;
  transition: all 0.2s ease;
}

.edit-file-btn {
  --bs-btn-color: #059669;
  --bs-btn-border-color: #059669;
}

.edit-file-btn:hover {
  --bs-btn-color: #fff;
  --bs-btn-bg-color: #059669;
  transform: translateY(-1px);
}

.view-file-btn {
  --bs-btn-color: #0ea5e9;
  --bs-btn-border-color: #0ea5e9;
}

.view-file-btn:hover {
  --bs-btn-color: #fff;
  --bs-btn-bg-color: #0ea5e9;
  transform: translateY(-1px);
}

/* Prevent background scroll while lightbox open */
body.lightbox-open {
  overflow: hidden;
}

/* Enhanced modal animations */
.modal.fade .modal-dialog {
  transition: transform 0.3s ease-out;
  transform: translate(0, -50px);
}

.modal.show .modal-dialog {
  transform: translate(0, 0);
}

/* Smooth button interactions */
.btn {
  transition: all 0.2s ease;
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.btn:active {
  transform: translateY(0);
}

/* Missing file indicator */
.uppy-Dashboard-Item.missing {
  opacity: 0.6;
  border: 2px dashed #ef4444;
}

.uppy-Dashboard-Item.missing::after {
  content: "File mancante";
  position: absolute;
  top: 5px;
  right: 5px;
  background: #ef4444;
  color: white;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 500;
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .gallery-grid {
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 12px;
  }
  
  .gallery-item {
    padding: 8px;
  }
  
  .gallery-item img { height: 80px; }
  .file-icon { height: 80px; }
  
  .lightbox-content {
    max-width: 95%;
    max-height: 95%;
  }
  
  .lightbox-close {
    top: 10px;
    right: 15px;
    width: 35px;
    height: 35px;
    font-size: 20px;
  }
  
  .lightbox-prev,
  .lightbox-next {
    width: 45px;
    height: 45px;
    font-size: 20px;
  }
  
  .lightbox-prev { left: 15px; }
  .lightbox-next { right: 15px; }
  
  .lightbox-info {
    bottom: 15px;
    max-width: 90%;
  }
  
  .lightbox-title {
    font-size: 14px;
    padding: 8px 16px;
  }
  
  .lightbox-counter {
    font-size: 12px;
    padding: 4px 8px;
  }
}

/* Focus styles for accessibility */
.lightbox-close:focus,
.lightbox-prev:focus,
.lightbox-next:focus {
  outline: 2px solid #3b82f6;
  outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  .lightbox-overlay {
    background: rgba(0, 0, 0, 0.95);
  }
  
  .lightbox-close,
  .lightbox-prev,
  .lightbox-next {
    background: rgba(0, 0, 0, 0.9);
    border: 1px solid #fff;
  }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  .lightbox,
  .lightbox-content,
  .uppy-Dashboard-Item,
  .uppy-Dashboard-AddFiles,
  .btn,
  .gallery-item,
  .gallery-item img {
    animation: none;
    transition: none;
  }
}

.no-info .uppy-Dashboard-Item-name{
  pointer-events: none;
  text-decoration: none !important;
  color: #1d2630 !important;
}

.no-info .uppy-Dashboard-Item-name::after{
  display: none !important;
}