/* =====================================================
   ESTILOS PARA VIDEOS DE YOUTUBE EN PRODUCTOS - SITIO PÚBLICO
   Fecha: 2025-08-01
   Archivo: site/pages/productdet.css (se carga automáticamente)
   ===================================================== */

/* Contenedor principal de video embebido */
.product-video-container {
    position: relative;
    width: 100%;
    margin: 1.5rem 0;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    background: #000;
}

.product-video-container iframe {
    width: 100%;
    height: 100%;
    border: none;
    display: block;
}

/* Galería de videos */
.product-video-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
    margin: 2rem 0;
}

.video-gallery-item {
    background: #ffffff;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
    cursor: pointer;
    border: 1px solid #e5e7eb;
}

.video-gallery-item:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

/* Contenedor del thumbnail */
.video-thumbnail-container {
    position: relative;
    width: 100%;
    height: 180px;
    overflow: hidden;
    background: #f3f4f6;
}

.video-thumbnail {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.video-gallery-item:hover .video-thumbnail {
    transform: scale(1.05);
}

/* Overlay de reproducción */
.video-play-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(255, 0, 0, 0.9);
    color: white;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    transition: all 0.3s ease;
    opacity: 0.8;
}

.video-gallery-item:hover .video-play-overlay {
    transform: translate(-50%, -50%) scale(1.1);
    opacity: 1;
    background: rgba(255, 0, 0, 1);
}

/* Badge de video principal */
.video-main-badge {
    position: absolute;
    top: 8px;
    left: 8px;
    background: #fbbf24;
    color: #92400e;
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    z-index: 10;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Información del video */
.video-info {
    padding: 1rem;
}

.video-title {
    font-size: 1rem;
    font-weight: 600;
    color: #1f2937;
    margin: 0 0 0.5rem 0;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.video-description {
    font-size: 0.875rem;
    color: #6b7280;
    margin: 0;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Modal para video embebido */
.video-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.video-modal.active {
    opacity: 1;
    visibility: visible;
}

.video-modal-content {
    position: relative;
    width: 90%;
    max-width: 800px;
    background: #000;
    border-radius: 12px;
    overflow: hidden;
    transform: scale(0.8);
    transition: transform 0.3s ease;
}

.video-modal.active .video-modal-content {
    transform: scale(1);
}

.video-modal-content iframe {
    width: 100%;
    height: 450px;
    border: none;
}

.video-modal-close {
    position: absolute;
    top: -40px;
    right: 0;
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: background-color 0.3s ease;
}

.video-modal-close:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Variaciones de diseño */
.product-video-gallery.compact {
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.product-video-gallery.compact .video-thumbnail-container {
    height: 120px;
}

.product-video-gallery.compact .video-info {
    padding: 0.75rem;
}

.product-video-gallery.compact .video-title {
    font-size: 0.875rem;
}

.product-video-gallery.compact .video-description {
    font-size: 0.8rem;
}

/* Lista de videos vertical */
.product-video-gallery.vertical {
    grid-template-columns: 1fr;
    max-width: 600px;
}

.product-video-gallery.vertical .video-gallery-item {
    display: flex;
    align-items: center;
}

.product-video-gallery.vertical .video-thumbnail-container {
    width: 200px;
    height: 120px;
    flex-shrink: 0;
}

.product-video-gallery.vertical .video-info {
    flex-grow: 1;
    padding: 1rem;
}

/* Video destacado */
.featured-video {
    margin: 2rem 0;
    text-align: center;
}

.featured-video .product-video-container {
    max-width: 800px;
    margin: 1rem auto;
}

.featured-video-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: #1f2937;
    margin-bottom: 0.5rem;
}

.featured-video-description {
    font-size: 1rem;
    color: #6b7280;
    margin-bottom: 1.5rem;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
}

/* Sección de videos en templates */
.product-template .video-section {
    margin: 3rem 0;
    padding: 2rem 0;
    border-top: 1px solid #e5e7eb;
}

.product-template .video-section-title {
    font-size: 1.5rem;
    font-weight: 600;
    text-align: center;
    margin-bottom: 2rem;
    color: #1f2937;
}

.video-section-title {
    font-size: 1.5rem;
    font-weight: 600;
    text-align: center;
    margin-bottom: 2rem;
    color: #1f2937;
}

/* Estados de carga */
.video-loading {
    background: #f3f4f6;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 180px;
    color: #9ca3af;
}

.video-loading i {
    font-size: 24px;
    animation: videoSpin 1s linear infinite;
}

@keyframes videoSpin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Efectos y animaciones */
@keyframes videoFadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.video-gallery-item {
    animation: videoFadeInUp 0.5s ease forwards;
}

.video-gallery-item:nth-child(2) {
    animation-delay: 0.1s;
}

.video-gallery-item:nth-child(3) {
    animation-delay: 0.2s;
}

.video-gallery-item:nth-child(4) {
    animation-delay: 0.3s;
}

/* Responsive Design */
@media (max-width: 768px) {
    .product-video-gallery {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .video-thumbnail-container {
        height: 200px;
    }
    
    .video-modal-content {
        width: 95%;
        margin: 1rem;
    }
    
    .video-modal-content iframe {
        height: 250px;
    }
    
    .product-video-gallery.vertical .video-gallery-item {
        flex-direction: column;
    }
    
    .product-video-gallery.vertical .video-thumbnail-container {
        width: 100%;
        height: 180px;
    }
    
    .featured-video .product-video-container {
        margin: 0.5rem auto;
    }
}

@media (max-width: 480px) {
    .video-play-overlay {
        width: 50px;
        height: 50px;
        font-size: 16px;
    }
    
    .video-info {
        padding: 0.75rem;
    }
    
    .video-title {
        font-size: 0.9rem;
    }
    
    .video-description {
        font-size: 0.8rem;
    }
    
    .video-modal-content iframe {
        height: 200px;
    }
    
    .video-section-title,
    .featured-video-title {
        font-size: 1.25rem;
    }
}

/* Integración con el sistema de colores dinámico de HubbdiSite */
.video-play-overlay {
    background: var(--main-color, rgba(255, 0, 0, 0.9));
}

.video-gallery-item:hover .video-play-overlay {
    background: var(--main-color, rgba(255, 0, 0, 1));
}

.video-main-badge {
    background: var(--secondary-color, #fbbf24);
    color: var(--text-color, #92400e);
}

/* Compatibilidad con templates existentes */
.classic-template .product-video-gallery,
.modern-template .product-video-gallery,
.minimal-template .product-video-gallery,
.showcase-template .product-video-gallery,
.premium-template .product-video-gallery {
    margin: 2rem 0;
}

/* Estilos específicos para modal de videos */
.video-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    z-index: 999999;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    box-sizing: border-box;
}

.video-modal-overlay.show {
    display: flex;
}

.video-modal-content-wrapper {
    position: relative;
    background: #000;
    border-radius: 12px;
    overflow: hidden;
    width: 100%;
    max-width: 1200px;
    max-height: 90vh;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.5);
    animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: scale(0.8) translateY(-20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.video-iframe-container {
    position: relative;
    width: 100%;
    padding-bottom: 56.25%; /* 16:9 aspect ratio */
    height: 0;
    overflow: hidden;
}

.video-iframe-container iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: none;
    border-radius: 12px;
}

.video-modal-close-btn {
    position: absolute;
    top: -50px;
    right: 0;
    background: rgba(255, 255, 255, 0.9);
    border: none;
    color: #333;
    font-size: 28px;
    cursor: pointer;
    padding: 10px;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000000;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.video-modal-close-btn:hover {
    background: #fff;
    transform: scale(1.1);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
}

.video-modal-close-btn i {
    line-height: 1;
}

/* Responsive para modal */
@media (max-width: 768px) {
    .video-modal-overlay {
        padding: 15px;
    }
    
    .video-modal-content-wrapper {
        max-width: 100%;
        border-radius: 8px;
    }
    
    .video-modal-close-btn {
        top: -45px;
        right: -5px;
        width: 45px;
        height: 45px;
        font-size: 24px;
    }
    
    .video-iframe-container {
        padding-bottom: 56.25%; /* Mantener 16:9 en móvil */
    }
}

@media (max-width: 480px) {
    .video-modal-overlay {
        padding: 10px;
    }
    
    .video-modal-close-btn {
        top: -40px;
        right: -10px;
        width: 40px;
        height: 40px;
        font-size: 20px;
    }
}

/* Estilos adicionales para asegurar compatibilidad */
.video-modal-overlay * {
    box-sizing: border-box;
}

/* Prevenir scroll del body cuando el modal está abierto */
body.modal-open {
    overflow: hidden;
    height: 100vh;
}

/* Asegurar que el modal esté por encima de todo */
.video-modal-overlay {
    z-index: 2147483647; /* Valor máximo para z-index */
}

/* Fallback para navegadores que no soporten backdrop-filter */
@supports not (backdrop-filter: blur(5px)) {
    .video-modal-overlay {
        background: rgba(0, 0, 0, 0.9);
    }
}

/* Estilos para pantallas muy pequeñas */
@media (max-width: 320px) {
    .video-modal-overlay {
        padding: 5px;
    }
    
    .video-modal-close-btn {
        top: -35px;
        right: -15px;
        width: 35px;
        height: 35px;
        font-size: 18px;
    }
    
    .video-modal-content-wrapper {
        border-radius: 6px;
    }
}

/* JavaScript helpers */
.video-js-ready .video-gallery-item {
    cursor: pointer;
}

.video-js-ready .video-gallery-item:hover {
    transform: translateY(-2px);
}
