/* ============================================
   TUBELIO - VIDEO PLAYER MODAL
   Sistema de preview on hover + modal fullscreen
   ============================================ */

/* ========== OVERLAY Y MODAL BASE ========== */

.video-modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(10px);
    z-index: 9998;
    animation: fadeIn 0.3s ease-out;
}

.video-modal-overlay.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.video-modal {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: #1a1a1a;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    z-index: 9999;
    overflow: hidden;
    animation: modalIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.video-modal.active {
    display: block;
}

@keyframes modalIn {
    from {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}

/* ========== ESTADOS DEL MODAL ========== */

/* Normal (Desktop) */
.video-modal.normal {
    width: 90%;
    max-width: 900px;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Maximizado */
.video-modal.maximized {
    width: 95vw;
    height: 95vh;
    max-width: none;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ========== HEADER DEL MODAL ========== */

.video-modal-header {
    background: rgba(42, 42, 42, 0.95);
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.video-modal-controls {
    display: flex;
    gap: 10px;
    align-items: center;
}

.modal-btn {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.8);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}

.modal-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    transform: scale(1.1);
}

.modal-btn-close:hover {
    background: #ff0000;
    color: white;
}

/* ========== CONTENIDO DEL MODAL ========== */

.video-modal-content {
    position: relative;
    background: #000;
}

.video-modal-player {
    position: relative;
    padding-bottom: 56.25%; /* 16:9 ratio */
    height: 0;
    overflow: hidden;
}

.video-modal.maximized .video-modal-player {
    padding-bottom: 0;
    height: calc(95vh - 120px); /* Menos header y footer */
}

.video-modal-player iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: none;
}

/* Loading spinner */
.video-modal-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1;
}

.modal-spinner {
    border: 4px solid rgba(255, 255, 255, 0.1);
    border-top: 4px solid #ff0000;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ========== FOOTER DEL MODAL ========== */

.video-modal-footer {
    background: #2a2a2a;
    padding: 20px;
    color: white;
}

.video-modal-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

.video-modal-channel-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    object-fit: cover;
}

.video-modal-details {
    flex: 1;
}

.video-modal-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 5px;
    color: white;
}

.video-modal-channel {
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.7);
}

.video-modal-stats {
    display: flex;
    gap: 15px;
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.6);
    margin-top: 5px;
}

/* ========== PREVIEW ON HOVER (DESKTOP) ========== */

.video-card {
    position: relative;
}

/* Wrapper para el preview */
.video-preview-wrapper {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: none;
    z-index: 50;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
    animation: previewIn 0.3s ease-out;
}

.video-preview-wrapper.active {
    display: block;
}

@keyframes previewIn {
    from {
        opacity: 0;
        transform: scale(0.98);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.video-preview-iframe {
    width: 100%;
    height: 100%;
    border: none;
}

/* Indicador de preview */
.video-preview-indicator {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.8), transparent);
    padding: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    color: white;
    font-size: 0.85rem;
    font-weight: 500;
    z-index: 51;
}

.video-preview-indicator svg {
    width: 16px;
    height: 16px;
}

/* Hover effect en la miniatura */
.video-card:hover .video-thumbnail {
    transform: scale(1.02);
    transition: transform 0.3s ease;
}

/* Indicador de mute */
.video-mute-indicator {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 5px;
    z-index: 52;
}

/* ========== RESPONSIVE ========== */

/* Tablet */
@media (max-width: 1024px) {
    .video-modal.normal {
        width: 95%;
    }
    
    .video-modal-header {
        padding: 12px 15px;
    }
    
    .video-modal-footer {
        padding: 15px;
    }
}

/* Móvil */
@media (max-width: 768px) {
    /* En móvil, el modal siempre es fullscreen */
    .video-modal.normal,
    .video-modal.maximized {
        width: 100vw;
        height: 100vh;
        max-width: none;
        border-radius: 0;
        top: 0;
        left: 0;
        transform: none;
    }
    
    .video-modal-player {
        padding-bottom: 0;
        height: auto;
        min-height: 250px;
    }
    
    .video-modal.normal .video-modal-player,
    .video-modal.maximized .video-modal-player {
        height: calc(100vh - 140px);
    }
    
    .modal-btn {
        width: 32px;
        height: 32px;
        font-size: 1rem;
    }
    
    .video-modal-title {
        font-size: 1rem;
    }
    
    .video-modal-channel-avatar {
        width: 40px;
        height: 40px;
    }
    
    /* NO preview en móvil */
    .video-preview-wrapper {
        display: none !important;
    }
}

/* ========== UTILIDADES ========== */

.no-scroll {
    overflow: hidden;
}

/* Cursor personalizado durante preview */
.video-card.previewing {
    cursor: pointer;
}

.video-card.previewing .video-thumbnail {
    opacity: 0;
}

/* Evitar selección de texto durante interacciones */
.video-modal,
.video-preview-wrapper {
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
}

/* ========== ANIMACIÓN DE SALIDA ========== */

.video-modal.closing {
    animation: modalOut 0.25s ease-in forwards;
}

@keyframes modalOut {
    from {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
    to {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.95);
    }
}

.video-modal-overlay.closing {
    animation: fadeOut 0.25s ease-in forwards;
}

@keyframes fadeOut {
    from {
        opacity: 1;
    }
    to {
        opacity: 0;
    }
}

/* ========== ACCESIBILIDAD ========== */

.modal-btn:focus {
    outline: 2px solid #ff0000;
    outline-offset: 2px;
}

/* Alto contraste para mejor visibilidad */
@media (prefers-contrast: high) {
    .video-modal-header {
        background: #000;
        border-bottom: 2px solid #fff;
    }
    
    .modal-btn {
        border: 1px solid rgba(255, 255, 255, 0.5);
    }
}

/* Reducción de movimiento para accesibilidad */
@media (prefers-reduced-motion: reduce) {
    .video-modal,
    .video-modal-overlay,
    .video-preview-wrapper,
    .modal-btn {
        animation: none;
        transition: none;
    }
}