/* --- ESTILOS DEL MODAL (ELEMENTO DIALOG) --- */

.modal-dialog {
  position: fixed;
  border: none;
  background: transparent;
  padding: 0;
  margin: auto;
  max-width: 95%; /* Margen de seguridad */
  width: 70vw; /* 70% del ancho de pantalla */
  overflow: visible;
  outline: none;
  
  /* Se muestra inmediatamente para que la animación del contenedor interno pueda fluir */
  transition: display 0.64s ease-in-out allow-discrete;
}

/* Backdrop (Fondo translúcido) */
.modal-dialog::backdrop {
  background-color: rgba(15, 23, 42, 0); /* Empieza transparente */
  backdrop-filter: blur(0px); /* Empieza sin desenfoque */
  transition: background-color 0.64s ease-in-out, backdrop-filter 0.64s ease-in-out, display 0.64s ease-in-out allow-discrete;
}

.modal-dialog[open]::backdrop {
  background-color: rgba(15, 23, 42, 0.85); /* Azul-gris oscuro profundo */
  backdrop-filter: blur(8px); /* Efecto Glassmorphism */
}

/* Contenedor Interno (Formato Dashboard) */
.modal-container {
  position: relative;
  width: 100%;
  height: 80vh; /* 80% del alto de la pantalla */
  background-color: #ffffff;
  display: flex;
  flex-direction: row; /* Lado a lado */
  overflow: hidden;
  border-radius: 16px; /* Bordes premium redondeados */
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  
  /* Animación espectacular angular y rotación (tipo popup-inner) */
  opacity: 0;
  transform: translate(80vw, 80vh) rotate(32deg);
  transition: transform 0.64s cubic-bezier(0.25, 1, 0.5, 1), opacity 0.64s ease-in-out;
}

.modal-dialog[open] .modal-container {
  opacity: 1;
  transform: translate(0, 0) rotate(0deg);
}

@starting-style {
  .modal-dialog[open] .modal-container {
    opacity: 0;
    transform: translate(80vw, 80vh) rotate(32deg);
  }
}

/* Botón Cerrar (X) sobresalido */
.modal-close-btn {
  position: absolute;
  top: -15px; /* Sobresale por arriba */
  right: -15px; /* Sobresale por la derecha */
  background: #0f172a; /* Color oscuro sólido */
  color: #ffffff;
  border: 2px solid #ffffff; /* Borde blanco para resaltar */
  width: 38px;
  height: 38px;
  border-radius: 50%;
  font-size: 22px;
  font-weight: bold;
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 160; /* Encima de todo */
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
  
  /* Animación de opacidad al abrir/cerrar */
  opacity: 0;
  pointer-events: none;
  transition: background-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease, opacity 0.64s ease-in-out;
}

.modal-dialog[open] .modal-close-btn {
  opacity: 1;
  pointer-events: auto;
}

@starting-style {
  .modal-dialog[open] .modal-close-btn {
    opacity: 0;
  }
}

.modal-close-btn:hover {
  background: var(--sdib-blue-light);
  transform: scale(1.1);
  box-shadow: 0 4px 12px rgba(0, 168, 232, 0.4);
}

/* Sección izquierda (Visualización Multimedia) */
.modal-media-side {
  flex: 1.1;
  background-color: #0f172a; /* Fondo oscuro elegante */
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
  overflow: hidden;
  height: 100%;
}

/* Fondo degradado premium si no hay media */
.modal-media-side.media-placeholder {
  background: linear-gradient(135deg, var(--sdib-blue-dark) 0%, #00152b 100%);
}

.modal-media-side img,
.modal-media-side video,
.modal-media-side iframe {
  width: 100%;
  height: 100%;
  display: block;
  border: none;
}

.modal-media-side img {
  object-fit: cover;
}

.modal-media-side video,
.modal-media-side iframe {
  object-fit: contain;
  background-color: #000000;
}

/* Carrusel Swiper Modal */
.modal-swiper {
  width: 100%;
  height: 100%;
}

.modal-swiper .swiper-slide {
  display: flex;
  justify-content: center;
  align-items: center;
  background-color: #000000;
  width: 100%;
  height: 100%;
}

.modal-swiper .swiper-button-next,
.modal-swiper .swiper-button-prev {
  color: var(--sdib-blue-light);
  background-color: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(4px);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  transition: background-color 0.2s;
}

.modal-swiper .swiper-button-next:hover,
.modal-swiper .swiper-button-prev:hover {
  background-color: rgba(255, 255, 255, 0.25);
}

.modal-swiper .swiper-button-next::after,
.modal-swiper .swiper-button-prev::after {
  font-size: 14px;
  font-weight: bold;
}

.modal-swiper .swiper-pagination-bullet {
  background-color: #ffffff;
  opacity: 0.5;
}

.modal-swiper .swiper-pagination-bullet-active {
  background-color: var(--sdib-blue-light);
  opacity: 1;
}

/* Sección derecha (Detalles del proyecto) */
.modal-content-side {
  flex: 1.2;
  padding: 30px;
  display: flex;
  flex-direction: column;
  background-color: #ffffff;
  height: 100%;
  overflow-y: auto;
}

.modal-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}

.modal-tags .tag {
  margin-bottom: 0;
  border-radius: 4px;
}

.modal-title {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--sdib-blue-dark);
  margin-top: 0;
  margin-bottom: 15px;
  line-height: 1.25;
}

/* --- CONTROLADORES DE PESTAÑAS (TABS) --- */
.modal-tabs-header {
  display: flex;
  border-bottom: 2px solid #e2e8f0;
  margin-bottom: 20px;
  gap: 15px;
  overflow-x: auto;
}

.modal-tabs-header::-webkit-scrollbar {
  height: 3px;
}

.tab-btn {
  background: transparent;
  border: none;
  padding: 10px 5px;
  font-size: 0.9rem;
  font-weight: 600;
  color: #64748b;
  cursor: pointer;
  position: relative;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: color 0.2s;
  white-space: nowrap;
  outline: none;
}

.tab-btn .tab-icon {
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.tab-btn:hover {
  color: var(--sdib-blue-light);
}

.tab-btn.active {
  color: var(--sdib-blue-light);
}

.tab-btn.active::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 100%;
  height: 2.5px;
  background-color: var(--sdib-blue-light);
  border-radius: 2px;
}

/* Contenedores de pestañas */
.tab-pane {
  display: none;
}

.tab-pane.active {
  display: flex;
  flex-direction: column;
}

/* Pestaña Resumen */
.modal-text {
  font-size: 0.92rem;
  line-height: 1.6;
  color: #475569;
  margin-top: 0;
  margin-bottom: 15px;
}

/* Contenedor de video superpuesto en el panel media */
.modal-video-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: #000000;
  z-index: 10;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

.video-wrapper {
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
}

.btn-close-video {
  position: absolute;
  top: 15px;
  left: 15px;
  background: rgba(15, 23, 42, 0.85);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.25);
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  z-index: 20;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  align-items: center;
  gap: 6px;
  backdrop-filter: blur(8px);
  outline: none;
}

.btn-close-video:hover {
  background: var(--sdib-blue-light);
  border-color: var(--sdib-blue-light);
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(0, 168, 232, 0.3);
}

/* Placeholder cuando no hay multimedia */
.modal-placeholder-container {
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  background: linear-gradient(135deg, var(--sdib-blue-dark) 0%, #00152b 100%);
}

/* Contenedor de detalles de texto dinámicos */
.modal-text-details {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 20px;
}

.modal-text-detail {
  font-size: 0.88rem;
  line-height: 1.6;
  color: #334155;
  background-color: #f8fafc;
  border-left: 3px solid var(--sdib-blue-light);
  padding: 10px 14px;
  border-radius: 0 6px 6px 0;
  margin: 0;
}

.modal-text-detail strong {
  color: var(--sdib-blue-dark);
  font-weight: 700;
}

/* Botones de acción en la pestaña */
.modal-tab-actions {
  display: flex;
  gap: 15px;
  margin-top: auto;
}

.modal-tab-actions .btn {
  flex: 1;
  margin: 0;
  border-radius: 8px;
  padding: 11px;
  font-size: 0.85rem;
  font-weight: bold;
  text-transform: uppercase;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
}

.modal-tab-actions .btn-view {
  border: 2px solid #3b82f6;
  color: #3b82f6;
  background: transparent;
}

.modal-tab-actions .btn-view:hover {
  background-color: #3b82f6;
  color: #ffffff;
}

.modal-tab-actions .btn-download {
  background-color: #3b82f6;
  color: #ffffff;
  border: 2px solid #3b82f6;
}

.modal-tab-actions .btn-download:hover {
  background-color: #2563eb;
  border-color: #2563eb;
}

/* Grillas y Listas Multimedia de las otras pestañas */
.tab-gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 15px;
  max-height: 350px;
  overflow-y: auto;
  padding: 5px;
}

.tab-list-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 350px;
  overflow-y: auto;
  padding: 5px;
}

.tab-media-card {
  display: flex;
  align-items: center;
  gap: 12px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 8px 12px;
  cursor: pointer;
  transition: all 0.2s;
  background-color: #ffffff;
}

.tab-media-card:hover {
  border-color: #3b82f6;
  background-color: #f8fafc;
}

.tab-media-card-thumb {
  width: 54px;
  height: 40px;
  border-radius: 6px;
  overflow: hidden;
  background-color: #f1f5f9;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
}

.tab-media-card-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.tab-media-card-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.tab-media-card-title {
  font-size: 0.82rem;
  font-weight: 700;
  color: #0f172a;
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tab-media-card-desc {
  font-size: 0.74rem;
  color: #64748b;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* --- BOTONES DE NAVEGACIÓN FLOTANTES --- */
.modal-nav-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(15, 23, 42, 0.6);
  color: #ffffff;
  border: none;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  font-size: 36px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 150;
  backdrop-filter: blur(4px);
  outline: none;
  user-select: none;
  
  /* Animación de opacidad al abrir/cerrar */
  opacity: 0;
  pointer-events: none;
  transition: background-color 0.25s cubic-bezier(0.4, 0, 0.2, 1), transform 0.25s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.25s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.64s ease-in-out;
}

.modal-dialog[open] .modal-nav-btn {
  opacity: 1;
  pointer-events: auto;
}

@starting-style {
  .modal-dialog[open] .modal-nav-btn {
    opacity: 0;
  }
}

.modal-nav-btn:hover {
  background: var(--sdib-blue-light);
  transform: translateY(-50%) scale(1.1);
  box-shadow: 0 4px 15px rgba(0, 168, 232, 0.4);
}

.modal-nav-prev {
  left: -70px;
}

.modal-nav-next {
  right: -70px;
}

/* Responsividad para botones de navegación */
@media (max-width: 1024px) {
  .modal-nav-prev {
    left: 10px;
    background: rgba(15, 23, 42, 0.85);
  }
  
  .modal-nav-next {
    right: 10px;
    background: rgba(15, 23, 42, 0.85);
  }
  
  .modal-nav-btn {
    width: 44px;
    height: 44px;
    font-size: 30px;
  }
}

/* --- ANIMACIONES INTERNAS EN CASCADA --- */

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

@keyframes modalMediaSlideIn {
  from {
    opacity: 0;
    transform: translateX(-30px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.animate-media {
  animation: modalMediaSlideIn 0.6s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.animate-content .modal-tags {
  animation: modalContentSlideIn 0.5s cubic-bezier(0.16, 1, 0.3, 1) both;
  animation-delay: 0.05s;
}

.animate-content .modal-title {
  animation: modalContentSlideIn 0.5s cubic-bezier(0.16, 1, 0.3, 1) both;
  animation-delay: 0.1s;
}

.animate-content .modal-tabs-header {
  animation: modalContentSlideIn 0.5s cubic-bezier(0.16, 1, 0.3, 1) both;
  animation-delay: 0.15s;
}

.animate-content .modal-tabs-content {
  animation: modalContentSlideIn 0.5s cubic-bezier(0.16, 1, 0.3, 1) both;
  animation-delay: 0.2s;
}

/* --- RESPONSIVIDAD (MÓVILES) --- */
@media (max-width: 768px) {
  .modal-dialog {
    width: 95%;
    max-width: 95%;
  }
  
  .modal-container {
    flex-direction: column;
    height: 90vh;
    overflow-y: auto;
  }
  
  .modal-media-side {
    height: 250px;
    flex: none;
  }
  
  .modal-content-side {
    padding: 20px 15px;
    height: auto;
    overflow-y: visible;
    flex: 1;
  }
  
  .modal-title {
    font-size: 1.4rem;
  }
  
  .modal-features-grid {
    grid-template-columns: 1fr;
  }
  
  .modal-tab-actions {
    flex-direction: column;
    gap: 10px;
  }
  
  .modal-close-btn {
    top: 10px;
    right: 10px;
    border: none;
    background: rgba(15, 23, 42, 0.85);
    box-shadow: none;
  }
}

/* --- LIGHTBOX DE MULTIMEDIA --- */
.media-lightbox-dialog {
  position: fixed;
  border: none;
  background: rgba(0, 0, 0, 0.95);
  padding: 0;
  margin: auto;
  width: 80vw;
  max-width: 950px;
  height: 80vh;
  border-radius: 12px;
  overflow: visible;
  outline: none;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  
  transition: display 0.4s ease-in-out allow-discrete, opacity 0.4s ease-in-out;
  opacity: 0;
}

.media-lightbox-dialog[open] {
  opacity: 1;
}

@starting-style {
  .media-lightbox-dialog[open] {
    opacity: 0;
  }
}

.media-lightbox-dialog::backdrop {
  background-color: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(10px);
  transition: background-color 0.4s ease-in-out, backdrop-filter 0.4s ease-in-out, display 0.4s ease-in-out allow-discrete;
}

.lightbox-content {
  width: 100%;
  height: 100%;
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
  box-sizing: border-box;
}

.lightbox-media-wrapper {
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  border-radius: 8px;
  overflow: hidden;
}

.lightbox-media-wrapper iframe,
.lightbox-media-wrapper video,
.lightbox-media-wrapper img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  border: none;
  display: block;
}

.lightbox-media-wrapper iframe {
  width: 100%;
  height: 100%;
}

.lightbox-close-btn {
  position: absolute;
  top: -45px;
  right: 0;
  background: transparent;
  color: #ffffff;
  border: none;
  font-size: 32px;
  cursor: pointer;
  outline: none;
  transition: transform 0.2s ease, color 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lightbox-close-btn:hover {
  color: var(--sdib-blue-light);
  transform: scale(1.1);
}

/* Botones de navegación en el lightbox (para recorrer imágenes) */
.lightbox-nav-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(15, 23, 42, 0.6);
  color: #ffffff;
  border: none;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  font-size: 36px;
  line-height: 1;
  cursor: pointer;
  display: none; /* Se muestra por JS si hay más de una imagen */
  justify-content: center;
  align-items: center;
  z-index: 150;
  backdrop-filter: blur(4px);
  outline: none;
  user-select: none;
  transition: background-color 0.25s, transform 0.25s, box-shadow 0.25s;
}

.lightbox-nav-btn:hover {
  background: var(--sdib-blue-light);
  transform: translateY(-50%) scale(1.1);
  box-shadow: 0 4px 15px rgba(0, 168, 232, 0.4);
}

.lightbox-nav-prev {
  left: 20px;
}

.lightbox-nav-next {
  right: 20px;
}

@media (max-width: 768px) {
  .media-lightbox-dialog {
    width: 95%;
    height: 70vh;
  }
  .lightbox-close-btn {
    top: 10px;
    right: 10px;
    background: rgba(15, 23, 42, 0.85);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    font-size: 24px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
  }
  .lightbox-nav-btn {
    width: 40px;
    height: 40px;
    font-size: 28px;
  }
  .lightbox-nav-prev {
    left: 10px;
  }
  .lightbox-nav-next {
    right: 10px;
  }
}

/* Alineación y tamaño de iconos en botones circulares */
.modal-close-btn i,
.modal-nav-btn i,
.lightbox-close-btn i,
.lightbox-nav-btn i {
  font-size: 1.1rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}