/* --- Estilos de la App Principal (Feed) con Animaciones --- */

@keyframes slideInUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes pulse {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.05);
  }
}

@keyframes heartBeat {
  0%, 100% {
    transform: scale(1);
  }
  25% {
    transform: scale(1.2);
  }
  50% {
    transform: scale(1);
  }
  75% {
    transform: scale(1.1);
  }
}

#logout-button {
  background: linear-gradient(135deg, #47b806, #5cd60a);
  color: white;
  border: none;
  padding: 0.6rem 1.2rem;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 2px 8px rgba(71, 184, 6, 0.3);
  white-space: nowrap;
}

#logout-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(71, 184, 6, 0.4);
}

.app-content h2 {
  font-size: 1.2rem;
  color: #666;
  margin-bottom: 1rem;
}

.create-post-container {
  width: 100%;
  max-width: 600px;
  margin-top: 80px;
  padding: 1rem;
  box-sizing: border-box;
  animation: slideInUp 0.5s ease-out;
  position: relative;
  z-index: 2; /* ⭐ Importante: Por encima del canvas */
}

#create-post-form {
  background-color: rgba(255, 255, 255, 0.98); /* ⭐ Aumentar opacidad */
  backdrop-filter: blur(10px); /* ⭐ Efecto glassmorphism */
  -webkit-backdrop-filter: blur(10px);
  border-radius: 12px;
  padding: 1.5rem;
  box-shadow: 
    0 4px 12px rgba(0, 0, 0, 0.08),
    0 1px 3px rgba(0, 0, 0, 0.05);
  transition: all 0.3s ease;
  border: 1px solid rgba(71, 184, 6, 0.1); /* ⭐ Borde sutil verde */
  position: relative;
  z-index: 2;
}

#create-post-form:hover {
  box-shadow: 
    0 8px 24px rgba(71, 184, 6, 0.12),
    0 4px 12px rgba(0, 0, 0, 0.1);
  transform: translateY(-2px);
  border-color: rgba(71, 184, 6, 0.2);
}

#create-post-form h3 {
  margin: 0 0 1rem 0;
  text-align: center;
}

#create-post-form textarea {
  width: 100%;
  min-height: 80px;
  border: 1px solid #ddd;
  border-radius: 6px;
  padding: 10px;
  font-family: inherit;
  font-size: 1rem;
  box-sizing: border-box;
  margin-bottom: 1rem;
  resize: vertical;
  transition: all 0.3s ease;
}

#create-post-form textarea:focus {
  border-color: #1877f2;
  box-shadow: 0 0 0 3px rgba(24, 119, 242, 0.1);
  outline: none;
}

/* Estilos para la Tarjeta de Mascota */
.pet-card {
  display: flex;
  align-items: flex-start;
  gap: 1.5rem;
  padding: 1rem;
  border-bottom: 1px solid #eee;
  transition: all 0.3s ease;
  animation: slideInUp 0.4s ease-out;
}

.pet-card:hover {
  background-color: #f8f9fa;
  transform: translateX(5px);
}

.pet-card:last-child {
  border-bottom: none;
}

.pet-card img {
  width: 100px;
  height: 100px;
  border-radius: 8px;
  object-fit: cover;
  background-color: #f0f2f5;
  border: 1px solid #ddd;
  transition: all 0.3s ease;
}

.pet-card img:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.pet-card-info {
  flex: 1;
}

.pet-card-info h3 {
  margin: 0 0 0.5rem 0;
}

.pet-card-info p {
  margin: 0.25rem 0;
  font-size: 0.9rem;
  color: #555;
}

.upload-form {
  margin-top: 1rem;
}

.upload-form input[type="file"] {
  font-size: 0.8rem;
}

.upload-form button {
  width: auto;
  padding: 0.3rem 0.8rem;
  font-size: 0.8rem;
  margin-left: 0.5rem;
}

/* --- Estilos de Etiquetado de Mascotas --- */
.post-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 0.5rem;
}

#tag-pet-button {
  width: auto;
  padding: 0.5rem 0.8rem;
  font-size: 1.2rem;
  font-weight: bold;
  background-color: #f0f2f5;
  color: #555;
  flex-grow: 0;
  transition: all 0.3s ease;
}

#tag-pet-button:hover {
  background-color: #e4e6eb;
  transform: rotate(5deg);
}

.submit-post-button {
  flex-grow: 1;
  margin-left: 0.5rem;
  transition: all 0.3s ease;
}

/* Estilos para las "píldoras" de etiquetas */
#pet-tags-container {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.pet-tag-pill {
  display: inline-flex;
  align-items: center;
  background-color: #e7f3ff;
  color: #1877f2;
  border-radius: 15px;
  padding: 0.25rem 0.75rem;
  font-size: 0.9rem;
  font-weight: 500;
  animation: slideInUp 0.3s ease-out;
  transition: all 0.3s ease;
}

.pet-tag-pill:hover {
  background-color: #d0e7ff;
  transform: translateY(-2px);
}

.pet-tag-remove-btn {
  background: none;
  border: none;
  color: #1877f2;
  font-weight: bold;
  font-size: 1.1rem;
  margin-left: 0.25rem;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  transition: all 0.2s ease;
}

.pet-tag-remove-btn:hover {
  transform: rotate(90deg);
  color: #d93025;
}

/* Estilos para el Modal (Menú) */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 100;
  animation: fadeInOverlay 0.3s ease-out forwards;
}

@keyframes fadeInOverlay {
  to {
    background-color: rgba(0, 0, 0, 0.5);
  }
}

.modal-content {
  background-color: white;
  padding: 1.5rem;
  border-radius: 8px;
  width: 90%;
  max-width: 400px;
  animation: slideInUp 0.3s ease-out;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}

#pet-selection-list {
  max-height: 200px;
  overflow-y: auto;
  margin: 1rem 0;
  border: 1px solid #ddd;
  border-radius: 6px;
}

.pet-selection-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem;
  cursor: pointer;
  transition: all 0.3s ease;
}

.pet-selection-item:hover {
  background-color: #f0f2f5;
  transform: translateX(5px);
}

.pet-selection-item img {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  transition: transform 0.3s ease;
}

.pet-selection-item:hover img {
  transform: scale(1.1);
}

/* --- Estilos de Subida de Media --- */
#add-media-button {
  width: auto;
  padding: 0.5rem 0.8rem;
  font-size: 1.5rem;
  font-weight: bold;
  background-color: #f0f2f5;
  color: #555;
  flex-grow: 0;
  margin-left: 0.5rem;
  transition: all 0.3s ease;
}

#add-media-button:hover {
  background-color: #e4e6eb;
  transform: rotate(90deg);
}

/* Estilos para cada "Tarjeta" de Post */
.post-card {
  background-color: rgba(255, 255, 255, 0.98); /* ⭐ Aumentar opacidad */
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-radius: 12px;
  padding: 1.5rem;
  margin-bottom: 1rem;
  box-shadow: 
    0 2px 8px rgba(0, 0, 0, 0.08),
    0 1px 3px rgba(0, 0, 0, 0.05);
  position: relative;
  animation: slideInUp 0.5s ease-out;
  transition: all 0.3s ease;
  border: 1px solid rgba(71, 184, 6, 0.08);
  z-index: 2; /* ⭐ Por encima del canvas */
}

.post-card:hover {
  box-shadow: 
    0 8px 24px rgba(71, 184, 6, 0.1),
    0 4px 16px rgba(0, 0, 0, 0.12);
  transform: translateY(-3px);
  border-color: rgba(71, 184, 6, 0.15);
}

.post-card .post-author {
  font-weight: bold;
  font-size: 1.1rem;
  color: #333;
}

.post-card .post-pet {
  font-size: 0.9rem;
  color: #1877f2;
  font-weight: 500;
  margin-bottom: 1rem;
}

.post-card .post-content {
  font-size: 1rem;
  color: #1c1e21;
  line-height: 1.4;
  margin-bottom: 1rem;
}

.post-card .post-timestamp {
  font-size: 0.6rem;
  color: #888;
}

/* --- Estilos del Formulario de Crear Post --- */
#post-media-preview-container {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.media-preview-item {
  position: relative;
  width: 80px;
  height: 80px;
  animation: slideInUp 0.3s ease-out;
}

.media-preview-item img,
.media-preview-item video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid #ddd;
  transition: transform 0.3s ease;
}

.media-preview-item:hover img,
.media-preview-item:hover video {
  transform: scale(1.05);
}

.media-preview-remove-btn {
  position: absolute;
  top: -5px;
  right: -5px;
  background-color: rgba(0, 0, 0, 0.7);
  color: white;
  border: none;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  font-size: 14px;
  font-weight: bold;
  cursor: pointer;
  line-height: 20px;
  text-align: center;
  padding: 0;
  transition: all 0.3s ease;
}

.media-preview-remove-btn:hover {
  background-color: #d93025;
  transform: rotate(90deg);
}

/* Estilos para el Media en el Feed */
.post-media-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.25rem;
  margin-top: 1rem;
  border-radius: 8px;
  overflow: hidden;
}

.post-media-item img,
.post-media-item video {
  width: 100%;
  height: 100%;
  max-height: 300px;
  object-fit: cover;
  background-color: #f0f2f5;
  transition: all 0.3s ease;
}

.post-media-item:hover img,
.post-media-item:hover video {
  transform: scale(1.02);
  filter: brightness(1.1);
}

.post-media-container.count-1 { grid-template-columns: 1fr; }

.post-media-container.count-3 {
  grid-template-columns: 1fr 1fr;
}

.post-media-container.count-3 .post-media-item:first-child {
  grid-column: 1 / 3;
  grid-row: 1 / 2;
}

.post-media-container.count-4 { grid-template-columns: 1fr 1fr; }

/* --- Estilos del Botón "Me Gusta" --- */
.post-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 1px solid #eee;
}

.toggle-comments-btn {
  background: none;
  border: 1px solid #ddd;
  border-radius: 20px;
  padding: 0.4rem 0.8rem;
  font-size: 0.85rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.3rem;
  color: #555;
  font-weight: 500;
  transition: all 0.3s ease;
}

.toggle-comments-btn:hover {
  background-color: #f0f2f5;
  border-color: #1877f2;
  color: #1877f2;
  transform: translateY(-2px);
}

.comment-count-display {
  font-size: 0.85rem;
  font-weight: bold;
}

.post-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.like-button {
  background: none;
  border: none;
  font-size: 1.25rem;
  cursor: pointer;
  padding: 0.25rem;
  line-height: 1;
  transition: transform 0.1s ease;
}

.like-button:hover {
  transform: scale(0.8);
}

.like-button:active {
  animation: heartBeat 0.5s ease;
}

.like-button.liked {
  filter: grayscale(0%);
  animation: pulse 0.5s ease;
}

.like-button.not-liked {
  filter: grayscale(100%);
  opacity: 0.7;
}

.like-count {
  font-size: 0.7rem;
  font-weight: bold;
  color: #555;
  transition: all 0.3s ease;
}

.like-button:hover + .like-count {
  color: #1877f2;
  transform: scale(1.1);
}

/* Estilo para botón Eliminar Post*/
.post-header {
  display: flex;
  margin-right: 2rem;
  align-items: flex-start;
  margin-bottom: 0.5rem;
}

.delete-post-btn {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  width: 28px;
  height: 28px;
  padding: 0;
  margin: 0;
  background: none;
  border: none;
  color: #888;
  font-size: 1.5rem;
  font-weight: bold;
  line-height: 28px;
  text-align: center;
  cursor: pointer;
  border-radius: 4px;
  z-index: 2; /* ← Importante para que esté encima */
  flex-shrink: 0;
  flex-grow: 0;
  transition: all 0.3s ease;
}

.delete-post-btn:hover {
  color: #d93025;
  background-color: #f0f2f5;
  transform: rotate(90deg);
}


.delete-post-btn:hover {
  color: #d93025;
  background-color: #f0f2f5;
  transform: rotate(90deg);
}

.post-header {
  margin-right: 35px;
}

/* --- Estilos de Comentarios --- */
.comments-section {
  margin-top: 1rem;
  border-top: 1px solid #eee;
  padding-top: 1rem;
  animation: slideInUp 0.4s ease-out;
}

.comment-list {
  max-height: 200px;
  overflow-y: auto;
  margin-bottom: 1rem;
}

.comment-item {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  font-size: 0.85rem;
  animation: slideInUp 0.3s ease-out;
  transition: all 0.3s ease;
}

.comment-item:hover {
  background-color: #f8f9fa;
  padding: 0.5rem;
  border-radius: 6px;
}

.comment-author {
  font-weight: bold;
  color: #333;
  flex-shrink: 0;
}

.comment-content {
  color: #1c1e21;
  word-break: break-word;
}

.comment-timestamp {
  font-size: 0.5rem;
  color: #888;
  margin-left: 0.5rem;
  flex-shrink: 0;
}

.comment-form {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.comment-input {
  flex-grow: 1;
  padding: 8px 10px;
  border: 1px solid #ddd;
  border-radius: 15px;
  font-size: 0.8rem;
  transition: all 0.3s ease;
}

.comment-input:focus {
  border-color: #1877f2;
  box-shadow: 0 0 0 3px rgba(24, 119, 242, 0.1);
  outline: none;
}

.comment-submit-btn {
  width: 20%;
  height: 30%;
  padding: 8px 12px;
  font-size: 0.8rem;
  background-color: #e7f3ff;
  color: #1877f2;
  flex-shrink: 0;
  transition: all 0.3s ease;
}

.comment-submit-btn:hover {
  background-color: #d0e7ff;
  transform: translateY(-2px);
}

.comment-submit-btn:disabled {
  background-color: #f0f2f5;
  color: #aaa;
  cursor: default;
}

@media (max-width: 600px) {
  .post-card {
    padding: 1rem;
    font-size: 0.9rem;
  }

  .post-card .post-author {
    font-size: 1rem;
  }

  .post-card .post-content {
    font-size: 0.9rem;
  }

  .post-footer {
    flex-direction: row; /* Mantener horizontal */
    gap: 0.5rem;
  }

  .toggle-comments-btn {
    font-size: 0.8rem;
    padding: 0.3rem 0.6rem;
  }

  .like-button {
    font-size: 1.1rem;
  }

  .like-count {
    font-size: 0.8rem;
  }

  .post-media-container {
    grid-template-columns: 1fr !important;
    max-height: 350px;
  }

  .post-media-container.count-3 .post-media-item:first-child {
    grid-column: auto;
    grid-row: auto;
  }

  .post-media-item img, .post-media-item video {
    max-height: 350px;
  }

  #create-post-form {
    padding: 1rem;
  }

  #create-post-form h3 {
    font-size: 1.1rem;
  }

  #post-media-preview-container {
    gap: 0.3rem;
  }

  .media-preview-item {
    width: 60px;
    height: 60px;
  }
}
