/* ==========================================================================
   PACK.CSS - ESTILOS PARA PÁGINA DE EXPEDICIÓN
   Color primario: Naranja (#fd7e14)
   ========================================================================== */

/* ==========================================================================
   CUSTOM PROPERTIES
   ========================================================================== */
:root {
  --pack-primary: #fd7e14;
  --pack-primary-dark: #e86c05;
  --pack-primary-light: #ffe4cc;
  --pack-primary-rgb: 253, 126, 20;
  --pack-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
  --pack-shadow-lg: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
  --pack-radius: 0.75rem;
  --pack-transition: all 0.3s ease;
}

/* ==========================================================================
   OVERRIDE BOOTSTRAP PRIMARY COLOR
   ========================================================================== */
.btn-primary {
  --bs-btn-bg: var(--pack-primary);
  --bs-btn-border-color: var(--pack-primary);
  --bs-btn-hover-bg: var(--pack-primary-dark);
  --bs-btn-hover-border-color: var(--pack-primary-dark);
  --bs-btn-active-bg: var(--pack-primary-dark);
  --bs-btn-active-border-color: var(--pack-primary-dark);
}

.btn-outline-primary {
  --bs-btn-color: var(--pack-primary);
  --bs-btn-border-color: var(--pack-primary);
  --bs-btn-hover-bg: var(--pack-primary);
  --bs-btn-hover-border-color: var(--pack-primary);
  --bs-btn-active-bg: var(--pack-primary);
  --bs-btn-active-border-color: var(--pack-primary);
}

.text-primary {
  color: var(--pack-primary) !important;
}

.bg-primary {
  background-color: var(--pack-primary) !important;
}

.border-primary {
  border-color: var(--pack-primary) !important;
}

.badge.bg-primary {
  background-color: var(--pack-primary) !important;
}

/* ==========================================================================
   PRODUCT GALLERY - PROPORCIÓN 4:3
   ========================================================================== */
.product-gallery {
  border-radius: var(--pack-radius);
  overflow: hidden;
  box-shadow: var(--pack-shadow-lg);
}

.gallery-main {
  aspect-ratio: 4/3;
  width: 100%;
  position: relative;
}

.gallery-main .carousel-item {
  height: 100%;
  background: #f8f9fa;
}

.gallery-main .carousel-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  cursor: pointer;
  transition: var(--pack-transition);
}

.gallery-main .carousel-item img:hover {
  transform: scale(1.02);
}

/* Video containers en galería principal */
.gallery-main .video-container {
  width: 100%;
  height: 100%;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.gallery-main .video-container iframe {
  width: 100%;
  height: 100%;
  border: 0;
}

/* Controles del carousel */
.gallery-main .carousel-control-prev,
.gallery-main .carousel-control-next {
  width: 8%;
  background: linear-gradient(to right, rgba(0, 0, 0, 0.3), transparent);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.gallery-main .carousel-control-next {
  background: linear-gradient(to left, rgba(0, 0, 0, 0.3), transparent);
}

.product-gallery:hover .carousel-control-prev,
.product-gallery:hover .carousel-control-next {
  opacity: 1;
}

.gallery-main .carousel-control-prev-icon,
.gallery-main .carousel-control-next-icon {
  width: 2.5rem;
  height: 2.5rem;
  background-color: rgba(255, 255, 255, 0.9);
  border-radius: 50%;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

/* ==========================================================================
   GALLERY THUMBNAILS
   ========================================================================== */
.gallery-thumbnails {
  margin-top: 1rem;
}

.gallery-thumbnail {
  aspect-ratio: 4/3;
  overflow: hidden;
  border-radius: 0.5rem;
  cursor: pointer;
  transition: var(--pack-transition);
  border: 2px solid transparent;
  position: relative;
  background: #f8f9fa;
}

.gallery-thumbnail:hover {
  border-color: var(--pack-primary);
  transform: scale(1.05);
  box-shadow: var(--pack-shadow-lg);
}

.gallery-thumbnail.active {
  border-color: var(--pack-primary);
  box-shadow: 0 0 0 2px rgba(var(--pack-primary-rgb), 0.25);
}

.gallery-thumbnail img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  transition: var(--pack-transition);
}

/* Video indicator en thumbnails */
.video-indicator {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: white;
  font-size: 1.5rem;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.6);
  pointer-events: none;
  z-index: 2;
}

.gallery-thumbnail:hover .video-indicator {
  color: var(--pack-primary);
  transform: translate(-50%, -50%) scale(1.1);
}

/* ==========================================================================
   PRODUCT INFO CARD
   ========================================================================== */
.product-info .card {
  border: none;
  border-radius: var(--pack-radius);
  box-shadow: var(--pack-shadow-lg);
  transition: var(--pack-transition);
}

.product-info .card:hover {
  transform: translateY(-2px);
  box-shadow: 0 1rem 2rem rgba(0, 0, 0, 0.15);
}

.detail-item {
  padding: 0.5rem 0;
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
  font-size: 0.9rem;
}

.detail-item:last-child {
  border-bottom: none;
}

.detail-item i {
  font-size: 1rem;
}

/* ==========================================================================
   PRICING SECTION
   ========================================================================== */
.price-container {
  background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
  border: 1px solid rgba(var(--pack-primary-rgb), 0.2);
  border-radius: var(--pack-radius);
  transition: var(--pack-transition);
}

.price-container:hover {
  border-color: var(--pack-primary);
  box-shadow: var(--pack-shadow);
}

.original-price {
  font-size: 1.1rem;
}

.current-price {
  font-size: 2rem !important;
  line-height: 1.2;
  color: var(--pack-primary) !important;
}

.pricing-options .list-group-item {
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 0.5rem;
  margin-bottom: 0.5rem;
  transition: var(--pack-transition);
}

.pricing-options .list-group-item:hover {
  background-color: var(--pack-primary-light);
  border-color: var(--pack-primary);
  transform: translateX(5px);
}

/* ==========================================================================
   ACTION BUTTONS
   ========================================================================== */
.action-form .btn {
  border-radius: 2rem;
  font-weight: 600;
  transition: var(--pack-transition);
  position: relative;
  overflow: hidden;
}

.action-form .btn:hover {
  transform: translateY(-2px);
  box-shadow: var(--pack-shadow-lg);
}

.action-form .btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
  transition: left 0.5s ease;
}

.action-form .btn:hover::before {
  left: 100%;
}

/* ==========================================================================
   PRODUCT NAVIGATION TABS
   ========================================================================== */
.product-nav {
  background: white;
  border-radius: var(--pack-radius);
  box-shadow: var(--pack-shadow);
  padding: 0.5rem;
  position: sticky;
  top: 1rem;
  z-index: 1020;
  margin-bottom: 2rem;
}

.product-nav .nav-link {
  border-radius: 0.5rem;
  font-weight: 500;
  transition: var(--pack-transition);
  margin: 0 0.25rem;
  position: relative;
}

.product-nav .nav-link:hover {
  background-color: var(--pack-primary-light);
  transform: translateY(-1px);
}

.product-nav .nav-link.active {
  background: linear-gradient(135deg, var(--pack-primary) 0%, var(--pack-primary-dark) 100%);
  color: white !important;
  box-shadow: var(--pack-shadow);
}

.product-nav .nav-link i {
  font-size: 1.1rem;
}

/* ==========================================================================
   TAB CONTENT
   ========================================================================== */
.tab-content {
  background: white;
  border-radius: var(--pack-radius);
  box-shadow: var(--pack-shadow);
  padding: 2rem;
}

.content-section {
  line-height: 1.7;
  color: #495057;
}

.content-section h1,
.content-section h2,
.content-section h3,
.content-section h4,
.content-section h5,
.content-section h6 {
  color: #212529;
  margin-bottom: 1rem;
}

.content-section p {
  margin-bottom: 1.25rem;
}

.content-section ul,
.content-section ol {
  margin-bottom: 1.25rem;
  padding-left: 2rem;
}

.content-section li {
  margin-bottom: 0.5rem;
}

/* ==========================================================================
   DIFFICULTY SECTION - IMÁGENES HORIZONTALES
   ========================================================================== */
.difficulty-content {
  width: 100%;
}

.difficulty-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  justify-content: center;
  align-items: center;
  margin-bottom: 2rem;
  padding: 1.5rem;
  background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
  border-radius: var(--pack-radius);
  border: 1px solid rgba(var(--pack-primary-rgb), 0.2);
}

.difficulty-btn {
  display: inline-block;
  padding: 0.75rem;
  border-radius: 0.75rem;
  transition: var(--pack-transition);
  background: white;
  border: 2px solid transparent;
  text-decoration: none;
  box-shadow: var(--pack-shadow);
}

.difficulty-btn:hover {
  border-color: var(--pack-primary);
  transform: translateY(-3px) scale(1.1);
  box-shadow: var(--pack-shadow-lg);
  background: var(--pack-primary-light);
}

.difficulty-img {
  width: 60px;
  height: 60px;
  object-fit: contain;
  display: block;
  transition: var(--pack-transition);
}

.difficulty-btn:hover .difficulty-img {
  transform: scale(1.1);
}

.difficulty-definitions {
  background: white;
  padding: 1.5rem;
  border-radius: var(--pack-radius);
  border: 1px solid #dee2e6;
}

/* ==========================================================================
   EQUIPMENT SECTION
   ========================================================================== */
.equipment-rental,
.related-products {
  margin-top: 2rem;
}

.equipment-rental h4,
.related-products h4 {
  background: linear-gradient(135deg, var(--pack-primary) 0%, var(--pack-primary-dark) 100%);
  color: white;
  padding: 1rem;
  border-radius: var(--pack-radius);
  text-align: center;
  margin-bottom: 1.5rem;
  box-shadow: var(--pack-shadow);
}

/* ==========================================================================
   ELEVATION CHART
   ========================================================================== */
.elevation-chart {
  background: white;
  padding: 1.5rem;
  border-radius: var(--pack-radius);
  border: 1px solid #dee2e6;
  box-shadow: var(--pack-shadow);
}

.chart-container {
  position: relative;
  height: 300px;
  width: 100%;
}

#elevationChart {
  max-width: 100%;
  height: auto;
}

/* ==========================================================================
   SERVICES SECTIONS
   ========================================================================== */
.services-included,
.services-not-included,
.additional-notes {
  margin-top: 1.5rem;
}

.services-included .content-section {
  background: rgba(25, 135, 84, 0.05);
}

.services-not-included .content-section {
  background: rgba(255, 193, 7, 0.05);
}

.additional-notes .content-section {
  background: rgba(13, 202, 240, 0.05);
}

/* ==========================================================================
   GALLERY MODAL
   ========================================================================== */
.modal-gallery-image {
  max-height: 80vh;
  max-width: 100%;
  object-fit: contain;
}

#galleryModal .modal-content {
  background: #000;
  border: none;
}

#galleryModal .carousel-control-prev-icon,
#galleryModal .carousel-control-next-icon {
  width: 3rem;
  height: 3rem;
  background-color: rgba(255, 255, 255, 0.8);
  border-radius: 50%;
}

/* ==========================================================================
   BADGES Y ELEMENTOS DESTACADOS
   ========================================================================== */
.z-index-high {
  z-index: 10;
}

.badge {
  font-weight: 500;
  border-radius: 0.5rem;
}

/* Badge de descuento */
.badge.bg-danger {
  background: linear-gradient(135deg, #dc3545, #c82333) !important;
  animation: pulse 2s infinite;
}

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

/* ==========================================================================
   RESPONSIVE DESIGN
   ========================================================================== */

/* Tablets */
@media (max-width: 992px) {
  .product-nav {
    position: static;
    margin-bottom: 1rem;
  }
  
  .gallery-main {
    aspect-ratio: 16/10;
  }
  
  .difficulty-buttons {
    gap: 0.75rem;
    padding: 1rem;
  }
  
  .difficulty-img {
    width: 50px;
    height: 50px;
  }
}

/* Mobile */
@media (max-width: 768px) {
  .product-header h1 {
    font-size: 1.75rem;
  }
  
  .product-header .lead {
    font-size: 1rem;
  }
  
  .gallery-main {
    aspect-ratio: 4/3;
  }
  
  .current-price {
    font-size: 1.5rem !important;
  }
  
  .product-nav .nav-link span {
    display: none !important;
  }
  
  .product-nav .nav-link {
    padding: 0.75rem 0.5rem;
    font-size: 0.9rem;
  }
  
  .tab-content {
    padding: 1.5rem;
  }
  
  .difficulty-buttons {
    gap: 0.5rem;
    padding: 0.75rem;
    flex-wrap: wrap;
  }
  
  .difficulty-img {
    width: 40px;
    height: 40px;
  }
  
  .gallery-thumbnails .col-2 {
    flex: 0 0 auto;
    width: 16.66667%;
  }
  
  .gallery-thumbnail {
    aspect-ratio: 1/1;
  }
}

/* Mobile pequeño */
@media (max-width: 576px) {
  .product-header {
    padding: 1rem 0;
  }
  
  .product-header h1 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
  }
  
  .product-header .lead {
    font-size: 0.9rem;
    margin-bottom: 1rem;
  }
  
  .current-price {
    font-size: 1.25rem !important;
  }
  
  .product-nav .nav-link {
    padding: 0.5rem 0.25rem;
    font-size: 0.8rem;
  }
  
  .tab-content {
    padding: 1rem;
  }
  
  .difficulty-buttons {
    gap: 0.375rem;
    padding: 0.5rem;
  }
  
  .difficulty-img {
    width: 35px;
    height: 35px;
  }
  
  .gallery-thumbnails .col-2 {
    width: 20%;
  }
  
  .detail-item {
    font-size: 0.8rem;
  }
  
  .detail-item i {
    font-size: 0.9rem;
  }
}

/* ==========================================================================
   ACCESSIBILITY
   ========================================================================== */
.gallery-thumbnail:focus,
.difficulty-btn:focus {
  outline: 2px solid var(--pack-primary);
  outline-offset: 2px;
}

.btn:focus {
  outline: 2px solid var(--pack-primary);
  outline-offset: 2px;
}

/* High contrast mode */
@media (prefers-contrast: high) {
  .gallery-thumbnail,
  .difficulty-btn,
  .btn {
    border-width: 2px;
  }
  
  .product-nav .nav-link {
    border: 1px solid currentColor;
  }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  
  .gallery-thumbnail:hover,
  .difficulty-btn:hover,
  .action-form .btn:hover {
    transform: none;
  }
  
  .badge.bg-danger {
    animation: none;
  }
}

/* ==========================================================================
   PRINT STYLES
   ========================================================================== */
@media print {
  .product-nav,
  .gallery-thumbnails,
  .action-form,
  .carousel-control-prev,
  .carousel-control-next {
    display: none !important;
  }
  
  .gallery-main {
    height: auto !important;
    aspect-ratio: auto;
  }
  
  .tab-content {
    box-shadow: none;
    border: 1px solid #dee2e6;
  }
  
  .difficulty-buttons {
    gap: 0.5rem;
  }
  
  .difficulty-img {
    width: 30px;
    height: 30px;
  }
}

/* ==========================================================================
   PERFORMANCE OPTIMIZATIONS
   ========================================================================== */
.gallery-main,
.gallery-thumbnail,
.difficulty-btn {
  will-change: transform;
  transform: translateZ(0);
  backface-visibility: hidden;
}

.product-gallery,
.product-info .card {
  contain: layout style paint;
}

/* ==========================================================================
   DARK MODE SUPPORT
   ========================================================================== */
@media (prefers-color-scheme: dark) {
  .tab-content,
  .product-info .card,
  .difficulty-buttons,
  .elevation-chart {
    background: #1e1e1e;
    color: #e0e0e0;
    border-color: #404040;
  }
  
  .content-section {
    color: #e0e0e0;
  }
  
  .content-section h1,
  .content-section h2,
  .content-section h3,
  .content-section h4,
  .content-section h5,
  .content-section h6 {
    color: #ffffff;
  }
}

/* ==========================================================================
   ÁLBUMES EN COLUMNAS DE 4 - GALERÍA TAB
   ========================================================================== */
#gallery .row > .col-md-3,
#gallery .row > .col-lg-3,
#gallery .row > .col-xl-3,
#gallery .row > [class*="col-3"] {
  flex: 0 0 auto;
  width: 25%;
}

#gallery .album-item {
  margin-bottom: 1.5rem;
  background: white;
  border-radius: var(--pack-radius);
  box-shadow: var(--pack-shadow);
  overflow: hidden;
  transition: var(--pack-transition);
}

#gallery .album-item:hover {
  transform: translateY(-5px);
  box-shadow: var(--pack-shadow-lg);
}

#gallery .album-item img {
  width: 100%;
  height: 200px;
  object-fit: cover;
  object-position: center;
}

#gallery .album-item .card-body {
  padding: 1rem;
}

#gallery .album-item .card-title {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: var(--pack-primary);
}

#gallery .album-item .card-text {
  font-size: 0.875rem;
  color: #6c757d;
  margin-bottom: 0.75rem;
}

#gallery .album-item .btn {
  font-size: 0.875rem;
  padding: 0.5rem 1rem;
}

/* Responsive para álbumes */
@media (max-width: 992px) {
  #gallery .row > .col-md-3,
  #gallery .row > .col-lg-3,
  #gallery .row > .col-xl-3,
  #gallery .row > [class*="col-3"] {
    width: 50%;
  }
}

@media (max-width: 576px) {
  #gallery .row > .col-md-3,
  #gallery .row > .col-lg-3,
  #gallery .row > .col-xl-3,
  #gallery .row > [class*="col-3"] {
    width: 100%;
  }
  
  #gallery .album-item img {
    height: 180px;
  }
}

<?php
// =============================================================================
// FUNCIÓN MODERNIZADA PARA MOSTRAR ÁLBUMES ASOCIADOS
// Bootstrap 5 responsive con 4 columnas y diseño moderno
// =============================================================================

function get_fotogaleria_albunes_asociados($id, $lang) {
    $link = Conectarse();
    
    // Consulta mejorada con mejor manejo de errores
    $result = mysqli_query($link, "SELECT images FROM ".DBNAME.".paquetes_es WHERE id=".$id);
    if (!$result) {
        mysqli_close($link);
        return '<div class="alert alert-warning"><i class="bi bi-exclamation-triangle me-2"></i>No se pudieron cargar los álbumes asociados.</div>';
    }
    
    if (mysqli_num_rows($result) === 0) {
        mysqli_free_result($result);
        mysqli_close($link);
        return '<div class="text-center py-4"><i class="bi bi-collection text-muted" style="font-size: 2rem;"></i><p class="text-muted mt-2 mb-0">No hay álbumes asociados a esta aventura.</p></div>';
    }
    
    $images_field = mysqli_result($result, 0, "images");
    mysqli_free_result($result);
    
    if (empty($images_field)) {
        mysqli_close($link);
        return '<div class="text-center py-4"><i class="bi bi-collection text-muted" style="font-size: 2rem;"></i><p class="text-muted mt-2 mb-0">No hay álbumes configurados para esta aventura.</p></div>';
    }
    
    $idsAlbunes = explode(",", $images_field);
    $nroAlbunes = count($idsAlbunes);
    
    if ($nroAlbunes === 0) {
        mysqli_close($link);
        return '<div class="text-center py-4"><i class="bi bi-collection text-muted" style="font-size: 2rem;"></i><p class="text-muted mt-2 mb-0">No hay álbumes disponibles.</p></div>';
    }
    
    // Contenedor responsivo moderno
    $html = '<div class="albums-gallery-container">';
    $html .= '<div class="row g-4">'; // gap-4 para mejor espaciado
    
    $albums_found = 0;
    
    for ($index = 0; $index < $nroAlbunes; $index++) {
        $idAlbum = trim($idsAlbunes[$index]);
        
        if ($idAlbum != 0 && !empty($idAlbum)) {
            // Consulta mejorada con LEFT JOIN para manejar álbumes sin imágenes
            $query = "SELECT 
                        a.nombre, 
                        a.name, 
                        a.descripcion_album, 
                        a.description_album,
                        i.nombre_file,
                        i.descripcion as imagen_descripcion
                      FROM ".DBNAME.".albunes a 
                      LEFT JOIN ".DBNAME.".imagenes_album i ON a.id_album = i.id_album 
                      WHERE a.id_album = '".$idAlbum."' 
                      LIMIT 1";
            
            $result_img = mysqli_query($link, $query);
            
            if ($result_img && mysqli_num_rows($result_img) > 0) {
                $row = mysqli_fetch_assoc($result_img);
                
                // Seleccionar contenido según idioma
                if ($lang === 'es') {
                    $nombreAlbum = $row["nombre"] ?: "Álbum sin título";
                    $descAlbum = $row["descripcion_album"] ?: "";
                } else {
                    $nombreAlbum = $row["name"] ?: $row["nombre"] ?: "Album without title";
                    $descAlbum = $row["description_album"] ?: $row["descripcion_album"] ?: "";
                }
                
                // Imagen del álbum
                $nombreI = $row["nombre_file"] ?: "no_image.jpg";
                $descI = $row["imagen_descripcion"] ?: $nombreAlbum;
                
                // URLs
                $urlAlbum = DOMAIN.DOMAINWEB."/album/".urls_amigables($nombreAlbum)."-".$_SESSION["language"]."-".$idAlbum.".php";
                $imagenUrl = DOMAIN.DOMAINWEB.IMAGEDIRALBUM."imagenes_pequena.php?ruta=".$nombreI;
                
                // Card moderna responsive
                $html .= '<div class="col-lg-3 col-md-4 col-sm-6 col-12">';
                $html .= '  <div class="album-card card h-100 shadow-sm border-0 overflow-hidden">';
                
                // Contenedor de imagen con overlay
                $html .= '    <div class="album-image-container position-relative">';
                $html .= '      <a href="'.$urlAlbum.'" title="'.htmlspecialchars($nombreAlbum).'" class="d-block">';
                $html .= '        <img src="'.$imagenUrl.'" ';
                $html .= '             class="card-img-top album-image" ';
                $html .= '             alt="'.htmlspecialchars($descI).'" ';
                $html .= '             loading="lazy" ';
                $html .= '             onerror="this.src=\''.DOMAIN.DOMAINWEB.IMAGEDIRALBUM.'no_image.jpg\'">';
                $html .= '        <div class="album-overlay position-absolute top-0 start-0 w-100 h-100 d-flex align-items-center justify-content-center">';
                $html .= '          <div class="album-play-icon text-white">';
                $html .= '            <i class="bi bi-collection-play fs-1"></i>';
                $html .= '          </div>';
                $html .= '        </div>';
                $html .= '      </a>';
                $html .= '    </div>';
                
                // Cuerpo de la card
                $html .= '    <div class="card-body d-flex flex-column p-3">';
                $html .= '      <h5 class="album-title card-title mb-2 fw-bold">';
                $html .= '        <a href="'.$urlAlbum.'" class="text-decoration-none text-dark stretched-link" title="'.htmlspecialchars($nombreAlbum).'">';
                $html .= '          '.htmlspecialchars($nombreAlbum);
                $html .= '        </a>';
                $html .= '      </h5>';
                
                if (!empty($descAlbum)) {
                    $html .= '      <p class="album-description card-text text-muted small mb-0 flex-grow-1">';
                    $html .= '        '.htmlspecialchars($descAlbum);
                    $html .= '      </p>';
                }
                
                $html .= '      <div class="album-meta mt-2 pt-2 border-top">';
                $html .= '        <small class="text-muted d-flex align-items-center">';
                $html .= '          <i class="bi bi-images me-1"></i>';
                $html .= '          <span>Ver galería completa</span>';
                $html .= '        </small>';
                $html .= '      </div>';
                $html .= '    </div>';
                $html .= '  </div>';
                $html .= '</div>';
                
                $albums_found++;
                mysqli_free_result($result_img);
            }
        }
    }
    
    $html .= '</div>'; // Cierre row
    
    // Si no se encontraron álbumes válidos
    if ($albums_found === 0) {
        $html .= '<div class="text-center py-4">';
        $html .= '  <i class="bi bi-collection text-muted" style="font-size: 2rem;"></i>';
        $html .= '  <p class="text-muted mt-2 mb-0">No hay álbumes disponibles en este momento.</p>';
        $html .= '</div>';
    }
    
    $html .= '</div>'; // Cierre container
    
    mysqli_close($link);
    return $html;
}
?>

<!-- ESTILOS CSS PARA ÁLBUMES - Agregar al final del <style> de viewpack.php -->
<style>
/* ==========================================================================
   ESTILOS PARA GALERÍA DE ÁLBUMES MODERNA
   ========================================================================== */

.albums-gallery-container {
    margin-top: 1rem;
    padding: 0;
}

.album-card {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 0.75rem !important;
    background: white;
    position: relative;
}

.album-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 1rem 3rem rgba(0, 0, 0, 0.175) !important;
}

.album-image-container {
    overflow: hidden;
    height: 200px;
    background: #f8f9fa;
}

.album-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.album-card:hover .album-image {
    transform: scale(1.08);
}

.album-overlay {
    background: linear-gradient(135deg, rgba(0, 0, 0, 0.3) 0%, rgba(0, 0, 0, 0.1) 100%);
    opacity: 0;
    transition: opacity 0.3s ease;
    backdrop-filter: blur(2px);
}

.album-card:hover .album-overlay {
    opacity: 1;
}

.album-play-icon {
    transform: scale(0.8);
    transition: transform 0.3s ease;
}

.album-card:hover .album-play-icon {
    transform: scale(1);
}

.album-title {
    font-size: 1rem;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: 2.8rem;
}

.album-title a {
    color: var(--bs-dark) !important;
    transition: color 0.3s ease;
}

.album-card:hover .album-title a {
    color: var(--product-primary-color) !important;
}

.album-description {
    font-size: 0.875rem;
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    max-height: 2.625rem;
}

.album-meta {
    border-top: 1px solid rgba(0, 0, 0, 0.05) !important;
}

.album-meta small {
    font-size: 0.75rem;
    font-weight: 500;
}

/* Estados de error para imágenes */
.album-image[src*="no_image.jpg"],
.album-image[alt="Error"] {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    position: relative;
}

.album-image[src*="no_image.jpg"]::after {
    content: '\f3f3'; /* Bootstrap icon camera */
    font-family: 'bootstrap-icons';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 2rem;
    color: #adb5bd;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .album-image-container {
        height: 180px;
    }
    
    .album-title {
        font-size: 0.9rem;
        min-height: 2.4rem;
    }
    
    .album-description {
        font-size: 0.8rem;
        -webkit-line-clamp: 1;
        max-height: 1.2rem;
    }
    
    .album-card .card-body {
        padding: 0.875rem !important;
    }
}

@media (max-width: 576px) {
    .albums-gallery-container .row {
        --bs-gutter-x: 1rem;
    }
    
    .album-image-container {
        height: 160px;
    }
    
    .album-title {
        font-size: 0.85rem;
        min-height: 2rem;
    }
    
    .album-card .card-body {
        padding: 0.75rem !important;
    }
}

/* Loading state */
.album-card.loading {
    opacity: 0.6;
    pointer-events: none;
}

.album-card.loading .album-image {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
}

@keyframes loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Accessibility improvements */
.album-card a:focus {
    outline: 2px solid var(--product-primary-color);
    outline-offset: 2px;
    border-radius: 0.375rem;
}

/* High contrast mode */
@media (prefers-contrast: high) {
    .album-card {
        border: 2px solid #000 !important;
    }
    
    .album-title a {
        text-decoration: underline !important;
    }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    .album-card,
    .album-image,
    .album-overlay,
    .album-play-icon {
        transition: none !important;
        animation: none !important;
        transform: none !important;
    }
    
    .album-card:hover {
        transform: none !important;
    }
    
    .album-card:hover .album-image {
        transform: none !important;
    }
}

/* Print styles */
@media print {
    .album-overlay,
    .album-play-icon {
        display: none !important;
    }
    
    .album-card {
        break-inside: avoid;
        box-shadow: none !important;
        border: 1px solid #000 !important;
    }
}

/* ==========================================================================
   SISTEMA DE DIFICULTAD MODERNO - ESTILOS PARA product-view.css
   ========================================================================== */

/* Contenedor principal del sistema de dificultad */
.difficulty-system-modern {
    margin: 2rem 0;
    padding: 1.5rem;
    background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
    border-radius: 1rem;
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
    border: 1px solid rgba(0, 0, 0, 0.05);
}

/* Header de la sección */
.difficulty-header h3 {
    color: var(--product-primary-color);
    font-weight: 700;
    position: relative;
}

.difficulty-header h3::after {
    content: '';
    position: absolute;
    bottom: -0.5rem;
    left: 50%;
    transform: translateX(-50%);
    width: 60px;
    height: 3px;
    background: linear-gradient(90deg, var(--product-primary-color), var(--product-primary-dark));
    border-radius: 2px;
}

/* Grid de indicadores */
.difficulty-indicators {
    margin-bottom: 1.5rem;
    display: flex;
    justify-content: center;
    align-items: stretch;
}
.difficulty-indicators .row {
    width: 100%;
    max-width: 1000px;
    margin: 0 auto;
    justify-content: center;
}

/* Cards de dificultad */
.difficulty-card {
    cursor: pointer;
    transition: var(--product-transition);
    height: 100%;
}

.difficulty-card:hover {
    transform: translateY(-8px);
}

.difficulty-card .card {
    transition: var(--product-transition);
    border-radius: 1rem !important;
    position: relative;
    overflow: hidden;
}

.difficulty-card:hover .card {
    box-shadow: 0 1rem 3rem rgba(0, 0, 0, 0.175) !important;
    border-color: var(--product-primary-color) !important;
}

/* Círculo de progreso moderno */
.progress-circle {
    position: relative;
    width: 80px;
    height: 80px;
}

.progress-circle-inner {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2;
}

.progress-percentage {
    font-size: 0.875rem;
    font-weight: 700;
}

.progress-ring {
    position: absolute;
    top: 0;
    left: 0;
    transform: rotate(-90deg);
    z-index: 1;
}

.progress-ring-circle {
    stroke: #e9ecef;
    stroke-linecap: round;
    transition: stroke-dasharray 0.5s ease-in-out;
}

/* Colores dinámicos para los círculos */
.difficulty-card[data-bs-target="#difficultyModalActivity"] .progress-ring-circle {
    stroke: var(--bs-primary);
}

.difficulty-card[data-bs-target="#difficultyModalPhysical"] .progress-ring-circle {
    stroke: var(--bs-success);
}

.difficulty-card[data-bs-target="#difficultyModalTechnical"] .progress-ring-circle {
    stroke: var(--bs-info);
}

.difficulty-card[data-bs-target="#difficultyModalPsychological"] .progress-ring-circle {
    stroke: var(--bs-warning);
}

.difficulty-card[data-bs-target="#difficultyModalAltitude"] .progress-ring-circle {
    stroke: var(--bs-danger);
}

/* Imágenes de dificultad */
.difficulty-image {
    transition: var(--product-transition);
}

.difficulty-card:hover .difficulty-image {
    transform: scale(1.1);
}

.difficulty-image img {
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
    transition: var(--product-transition);
}

.difficulty-card:hover .difficulty-image img {
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.2));
}

/* Indicador de click */
.click-indicator {
    opacity: 0;
    transform: translateY(10px);
    transition: var(--product-transition);
}

.difficulty-card:hover .click-indicator {
    opacity: 1;
    transform: translateY(0);
}

/* Títulos de las cards */
.difficulty-card .card-title {
    color: var(--bs-dark);
    transition: color 0.3s ease;
    font-size: 0.875rem;
    line-height: 1.2;
    min-height: 2.4rem;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.difficulty-card:hover .card-title {
    color: var(--product-primary-color);
}

/* Texto descriptivo */
.difficulty-card .card-text {
    line-height: 1.3;
    min-height: 3rem;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Modales mejorados */
.modal-content {
    border-radius: 1rem;
    border: none;
    box-shadow: 0 2rem 4rem rgba(0, 0, 0, 0.2);
}

.modal-header {
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    border-radius: 1rem 1rem 0 0;
}

.modal-title {
    color: var(--product-primary-color);
}

.modal-body {
    padding: 1.5rem;
}

/* Contenido de descripciones en modales */
.description-section {
    margin-bottom: 1.5rem;
}

.description-section h4 {
    color: var(--product-primary-color);
    font-weight: 700;
    margin-bottom: 1rem;
}

.description-section p {
    line-height: 1.6;
    color: var(--bs-dark);
}

/* Niveles de dificultad */
.difficulty-levels {
    margin-top: 1.5rem;
}

.difficulty-level {
    background: rgba(248, 249, 250, 0.5);
    transition: var(--product-transition-fast);
    border: 1px solid rgba(0, 0, 0, 0.05) !important;
}

.difficulty-level:hover {
    background: rgba(253, 126, 20, 0.05);
    border-color: var(--product-primary-color) !important;
    transform: translateX(5px);
}

.difficulty-level .badge {
    font-weight: 600;
    min-width: 60px;
    text-align: center;
}

/* Copyright */
.difficulty-copyright {
    border-top: 1px solid rgba(0, 0, 0, 0.1) !important;
}

.difficulty-copyright small {
    font-size: 0.75rem;
    line-height: 1.4;
}

/* Efectos de hover especiales */
.difficulty-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s;
    z-index: 1;
}

.difficulty-card:hover::before {
    left: 100%;
}

/* Responsive design */
@media (max-width: 992px) {
    .difficulty-system-modern {
        padding: 1rem;
        margin: 1.5rem 0;
    }
    
    .difficulty-indicators {
        margin-bottom: 1rem;
    }
    
    .progress-circle {
        width: 70px;
        height: 70px;
    }
    
    .progress-ring {
        width: 70px;
        height: 70px;
    }
    
    .progress-ring-circle {
        cx: 35;
        cy: 35;
        r: 28;
    }
    
    .progress-percentage {
        font-size: 0.75rem;
    }
    
    .difficulty-card .card-body {
        padding: 0.875rem !important;
    }
    
    .difficulty-image img {
        height: 35px !important;
    }
}

@media (max-width: 768px) {
    .difficulty-header h3 {
        font-size: 1.25rem;
    }
    
    .progress-circle {
        width: 60px;
        height: 60px;
    }
    
    .progress-ring {
        width: 60px;
        height: 60px;
    }
    
    .progress-ring-circle {
        cx: 30;
        cy: 30;
        r: 24;
        stroke-width: 4;
    }
    
    .progress-percentage {
        font-size: 0.7rem;
    }
    
    .difficulty-card .card-title {
        font-size: 0.8rem;
        min-height: 2rem;
    }
    
    .difficulty-card .card-text {
        font-size: 0.7rem;
        min-height: 2.5rem;
        -webkit-line-clamp: 2;
    }
    
    .click-indicator small {
        font-size: 0.65rem;
    }
    
    .modal-body {
        padding: 1rem;
    }
    
    .description-section .row .col-auto img {
        height: 50px !important;
        width: 50px !important;
    }
}

@media (max-width: 576px) {
    .difficulty-system-modern {
        margin: 1rem -0.5rem;
        border-radius: 0.75rem;
    }
    
    .difficulty-indicators .col-6 {
        padding: 0.375rem;
    }
    
    .progress-circle {
        width: 50px;
        height: 50px;
    }
    
    .progress-ring {
        width: 50px;
        height: 50px;
    }
    
    .progress-ring-circle {
        cx: 25;
        cy: 25;
        r: 20;
        stroke-width: 3;
    }
    
    .progress-percentage {
        font-size: 0.65rem;
    }
    
    .difficulty-card .card-body {
        padding: 0.75rem !important;
    }
    
    .difficulty-image img {
        height: 30px !important;
    }
    
    .difficulty-card .card-title {
        font-size: 0.75rem;
        min-height: 1.8rem;
    }
    
    .difficulty-card .card-text {
        font-size: 0.65rem;
        min-height: 2rem;
        -webkit-line-clamp: 2;
    }
    
    .click-indicator {
        display: none;
    }
    
    .modal-dialog {
        margin: 0.5rem;
    }
}

/* Animaciones de carga */
@keyframes progressFill {
    from {
        stroke-dasharray: 0 251.2;
    }
    to {
        stroke-dasharray: var(--progress-value) 251.2;
    }
}

.progress-ring-circle.animate {
    animation: progressFill 1s ease-out forwards;
}

/* Estados de accesibilidad */
.difficulty-card:focus {
    outline: 2px solid var(--product-primary-color);
    outline-offset: 2px;
}

.difficulty-card:focus .card {
    box-shadow: 0 0 0 3px rgba(253, 126, 20, 0.25);
}

/* High contrast mode */
@media (prefers-contrast: high) {
    .difficulty-card .card {
        border-width: 2px !important;
    }
    
    .difficulty-level {
        border-width: 2px !important;
    }
    
    .progress-ring-circle {
        stroke-width: 4;
    }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    .difficulty-card,
    .difficulty-image,
    .click-indicator,
    .progress-ring-circle {
        transition: none !important;
        animation: none !important;
    }
    
    .difficulty-card:hover {
        transform: none !important;
    }
    
    .difficulty-card::before {
        display: none;
    }
}

/* Print styles */
@media print {
    .difficulty-system-modern {
        background: white !important;
        box-shadow: none !important;
        border: 1px solid #000 !important;
        break-inside: avoid;
    }
    
    .click-indicator {
        display: none !important;
    }
    
    .difficulty-card:hover {
        transform: none !important;
    }
    
    .modal {
        display: none !important;
    }
}

/* Mejoras de performance */
.difficulty-card {
    will-change: transform;
    backface-visibility: hidden;
    transform-style: preserve-3d;
}

.progress-circle {
    contain: layout style paint;
}

/* Estados específicos por tipo de actividad */
.difficulty-card[data-bs-target="#difficultyModalActivity"]:hover {
    background: linear-gradient(135deg, rgba(13, 110, 253, 0.05), transparent);
}

.difficulty-card[data-bs-target="#difficultyModalPhysical"]:hover {
    background: linear-gradient(135deg, rgba(25, 135, 84, 0.05), transparent);
}

.difficulty-card[data-bs-target="#difficultyModalTechnical"]:hover {
    background: linear-gradient(135deg, rgba(13, 202, 240, 0.05), transparent);
}

.difficulty-card[data-bs-target="#difficultyModalPsychological"]:hover {
    background: linear-gradient(135deg, rgba(255, 193, 7, 0.05), transparent);
}

.difficulty-card[data-bs-target="#difficultyModalAltitude"]:hover {
    background: linear-gradient(135deg, rgba(220, 53, 69, 0.05), transparent);
}

/* Estilos adicionales para el tab de dificultad */
.difficulty-tab-content {
    background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
    border-radius: 1rem;
    padding: 1.5rem;
    margin: -0.5rem;
}

.recommendation-card {
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.recommendation-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    transition: left 0.8s;
}

.recommendation-card:hover::before {
    left: 100%;
}

.recommendation-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
}

@media (max-width: 768px) {
    .difficulty-tab-content {
        padding: 1rem;
        margin: 0;
        border-radius: 0.75rem;
    }
    
    .recommendation-card {
        margin-top: 1rem;
    }
    
    .recommendation-card .d-flex {
        flex-direction: column;
        text-align: center;
    }
    
    .recommendation-card .fs-4 {
        font-size: 2rem !important;
        margin-bottom: 0.5rem;
    }
}