/* Estilos para la galería Polaroid */
#gallery {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
  padding: 20px;
  max-width: 1200px;
  margin: 0 auto;
}

.gallery-item {
  position: relative;
  background: white;
  padding: 15px 15px 40px 15px;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
  transform: rotate(0deg);
  transition: all 0.3s ease;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* Efecto de inclinación aleatoria para efecto Polaroid más auténtico */
.gallery-item:nth-child(odd) {
  transform: rotate(-1deg);
}
.gallery-item:nth-child(even) {
  transform: rotate(1deg);
}
.gallery-item:hover {
  transform: rotate(0deg) scale(1.02);
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
}

/* Contenedor de la imagen */
.gallery-item .media-container {
  width: 100%;
  overflow: hidden;
}

/* Estilos para imágenes y videos */
.gallery-item img, 
.gallery-item video {
  width: 100%;
  height: auto;
  display: block;
  object-fit: cover;
  aspect-ratio: 1/1;
  transition: transform 0.3s ease;
}

/* Estilos para la vista expandida */
.gallery-item.expanded {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1000;
  background: rgba(0, 0, 0, 0.9);
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 0;
  margin: 0;
  transform: none !important;
  box-shadow: none;
  cursor: zoom-out;
}

.gallery-item.expanded .media-container {
  max-width: 90%;
  max-height: 90%;
}

.gallery-item.expanded img,
.gallery-item.expanded video {
  max-width: 100%;
  max-height: 90vh;
  aspect-ratio: auto;
  object-fit: contain;
}

/* Asegurar que los elementos sean clickeables */
.gallery-item {
  cursor: pointer;
}

/* Los elementos multimedia dentro NO deben ser clickeables directamente */
.gallery-item .media-container * {
  pointer-events: none;
}

/* Excepto los controles de video */
.gallery-item video::-webkit-media-controls {
  pointer-events: auto;
}

/* Estilos para expanded */
.gallery-item.expanded {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1000;
  background: rgba(0, 0, 0, 0.9);
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 0;
  margin: 0;
  cursor: default;
}

.gallery-item.expanded .media-container {
  max-width: 90%;
  max-height: 90%;
}

.gallery-item.expanded .media-container * {
  max-width: 100%;
  max-height: 90vh;
  object-fit: contain;
}

/* Estilos base de la galería */
#gallery {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
  padding: 20px;
  max-width: 1200px;
  margin: 0 auto;
}

.gallery-item {
  position: relative;
  background: white;
  padding: 15px 15px 40px 15px;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
  transform: rotate(0deg);
  transition: all 0.3s ease;
  cursor: zoom-in;
  display: flex;
  flex-direction: column;
  align-items: center;
  will-change: transform, opacity; /* Optimización para animaciones */
}

/* Contenedor de la imagen con transición */
.gallery-item .media-container {
  width: 100%;
  overflow: hidden;
  transition: transform 0.3s ease;
}

.gallery-item img, 
.gallery-item video {
  width: 100%;
  height: auto;
  display: block;
  object-fit: cover;
  aspect-ratio: 1/1;
  transition: transform 0.4s cubic-bezier(0.165, 0.84, 0.44, 1);
}

/* Estado expandido con animación */
.gallery-item.expanded {
  position: fixed;
  top: 12%;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1000;
  background: rgba(0, 0, 0, 0);
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 0;
  margin: 0;
  cursor: zoom-out;
  animation: fadeInBackground 0.3s forwards;
}

.gallery-item.expanded .media-container {
  animation: zoomIn 0.4s cubic-bezier(0.165, 0.84, 0.44, 1) forwards;
  max-width: 90vw;
  max-height: 90vh;
}

.gallery-item.expanded img,
.gallery-item.expanded video {
  object-fit: contain;
  animation: none; /* Desactivamos animación en el elemento hijo */
}

/* Animaciones */
@keyframes zoomIn {
  from {
    transform: scale(0.8);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

@keyframes fadeInBackground {
  to {
    background: rgba(0, 0, 0, 0.6);
  }
}

/* Animación al cerrar */
.gallery-item.closing {
  animation: fadeOutBackground 0.3s forwards;
}

.gallery-item.closing .media-container {
  animation: zoomOut 0.3s cubic-bezier(0.165, 0.84, 0.44, 1) forwards;
}

@keyframes zoomOut {
  from {
    transform: scale(1);
    opacity: 1;
  }
  to {
    transform: scale(0.8);
    opacity: 0;
  }
}

@keyframes fadeOutBackground {
  from {
    background: rgba(0, 0, 0, 0.9);
  }
  to {
    background: rgba(0, 0, 0, 0);
  }
}

/* Estilos para el contenedor de previsualización */
.file-preview-container {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 20px;
  padding: 10px;
  border: 1px dashed #ccc;
  border-radius: 8px;
  min-height: 80px;
}

/* Miniaturas de previsualización */
.file-thumbnail {
  position: relative;
  width: 80px;
  height: 80px;
  border-radius: 4px;
  overflow: hidden;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.file-thumbnail img, 
.file-thumbnail video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.file-thumbnail .file-name {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(0,0,0,0.7);
  color: white;
  font-size: 10px;
  padding: 2px 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-thumbnail .remove-btn {
    position: absolute;
    top: 2px;
    right: 2px;
    background: rgba(255, 0, 0, 0.7);
    color: white;
    border: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    font-size: 20px;
    display: flex
;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: unset;
}

/* Barra de progreso */
.progress-container {
  margin-top: 20px;
  width: 100%;
}

.progress-bar {
  height: 10px;
  background: #f0f0f0;
  border-radius: 5px;
  overflow: hidden;
  margin-bottom: 5px;
}

.progress-fill {
  height: 100%;
  background: #4CAF50;
  width: 0%;
  transition: width 0.3s ease;
}

.progress-text {
  text-align: center;
  font-size: 14px;
  color: #555;
}

.progress-time {
  margin-top: 5px;
  font-size: 12px;
  color: #666;
  text-align: center;
}

/* Efectos hover para miniaturas */
.file-thumbnail:hover {
  transform: scale(1.05);
  transition: transform 0.2s ease;
}

.file-preview-container {
    display: none; /* Oculta inicialmente el contenedor */
}
