/* ========== MODAL POPUP ========== */

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(7, 43, 79, 0.85);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  animation: fadeIn 0.3s ease;
}

.modal-overlay.hidden {
  display: none;
}

.modal-container {
  background: white;
  border-radius: 16px;
  max-width: 700px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  position: relative;
  animation: slideUp 0.4s ease;
}

.modal-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: rgba(255, 255, 255, 0.95);
  border: none;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1.5rem;
  line-height: 1;
  color: var(--blue-900);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  transition: all 0.2s ease;
  z-index: 10;
}

.modal-close:hover {
  background: #fff;
  transform: rotate(90deg);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

/* Sobrescreve estilos de galeria que podem estar conflitando */
.modal-overlay .modal-content {
  padding: 0;
  margin: 0;
  position: static !important;
  transform: none !important;
  top: auto !important;
  left: auto !important;
  max-width: none !important;
  max-height: none !important;
  display: block !important;
  box-shadow: none !important;
  border-radius: 0 !important;
  animation: none !important;
}

/* 1. O container de mídia
   Mantém o arredondamento no topo e garante 
   que o vídeo (ou imagem) fica contido.
*/
.modal-overlay .modal-media {
  width: 100%;
  border-radius: 16px 16px 0 0;
  overflow: hidden;
  background: #000;
}

.modal-overlay .modal-media img {
  width: 100%;
  height: auto;
  max-height: 400px;
  object-fit: cover;
  display: block;
  margin: 0;
  padding: 0;
}

/* 2. O container do vídeo (Corrigido)
   Removemos o 'padding: 0' e o 'border-radius' daqui.
*/
.modal-overlay .modal-video {
  position: relative;
  width: 100%;
  padding-bottom: 56.25%; /* Proporção 16:9 */
  height: 0;
  overflow: hidden;
  background: #000;
}

/* 3. O iframe (mantém-se igual) */
.modal-overlay .modal-video iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

.modal-overlay .modal-body {
  padding: 2rem;
}

.modal-overlay .modal-title {
  margin: 0 0 1rem;
  font-size: 1.75rem;
  color: var(--blue-900);
  font-weight: 600;
}

.modal-overlay .modal-description {
  margin: 0 0 1.5rem;
  color: var(--blue-700);
  font-size: 1.05rem;
  line-height: 1.6;
  white-space: pre-wrap;
}

.modal-overlay .modal-actions {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

.modal-overlay .modal-link {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  background: linear-gradient(135deg, var(--blue-700), var(--blue-500));
  color: white;
  text-decoration: none;
  border-radius: 8px;
  font-weight: 600;
  transition: all 0.3s ease;
  box-shadow: 0 4px 12px rgba(42, 135, 198, 0.3);
}

.modal-overlay .modal-link:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(42, 135, 198, 0.4);
}

.modal-overlay .modal-close-button {
  padding: 0.75rem 1.5rem;
  background: #f0f0f0;
  color: var(--blue-700);
  text-decoration: none;
  border: none;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.modal-overlay .modal-close-button:hover {
  background: #e0e0e0;
}

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

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

@media (max-width: 768px) {
  .modal-overlay .modal-container {
    max-width: 95%;
    border-radius: 12px;
  }

  .modal-overlay .modal-body {
    padding: 1.5rem;
  }

  .modal-overlay .modal-title {
    font-size: 1.4rem;
  }

  .modal-overlay .modal-description {
    font-size: 1rem;
  }

  .modal-overlay .modal-media img {
    max-height: 250px;
  }
}
